From 644099390a6957bec0ee62dacbbae3e012a6668a Mon Sep 17 00:00:00 2001 From: Joel Wilsson Date: Fri, 31 Jan 2025 22:42:33 +0100 Subject: [PATCH 1/2] Handle type aliases in contextFunctionResultTypeAfter (#21517) Closes #21433 --- .../dotty/tools/dotc/transform/ContextFunctionResults.scala | 2 +- tests/pos/i21433.scala | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 tests/pos/i21433.scala diff --git a/compiler/src/dotty/tools/dotc/transform/ContextFunctionResults.scala b/compiler/src/dotty/tools/dotc/transform/ContextFunctionResults.scala index 0bb54f8c9345..463bb68718ef 100644 --- a/compiler/src/dotty/tools/dotc/transform/ContextFunctionResults.scala +++ b/compiler/src/dotty/tools/dotc/transform/ContextFunctionResults.scala @@ -104,7 +104,7 @@ object ContextFunctionResults: def contextFunctionResultTypeAfter(meth: Symbol, depth: Int)(using Context) = def recur(tp: Type, n: Int): Type = if n == 0 then tp - else tp match + else tp.dealias match case defn.ContextFunctionType(_, resTpe) => recur(resTpe, n - 1) recur(meth.info.finalResultType, depth) diff --git a/tests/pos/i21433.scala b/tests/pos/i21433.scala new file mode 100644 index 000000000000..0efc4ac197ae --- /dev/null +++ b/tests/pos/i21433.scala @@ -0,0 +1,6 @@ +trait A[T]: + type R = T ?=> Unit + def f: R = () + +class B extends A[Int]: + override def f: R = () From e2ee55f095b9c1cea107f0a9e38b30ff2495313e Mon Sep 17 00:00:00 2001 From: Tomasz Godzik Date: Mon, 21 Apr 2025 13:54:29 +0200 Subject: [PATCH 2/2] Handle type aliases in contextFunctionResultTypeAfter (#21517) Closes #21433 [Cherry-picked 590691b09bb8554dd312a4e942f91dcd43ba6b44][modified]