Skip to content

Commit 2ec3b9a

Browse files
committed
Handle type aliases in contextFunctionResultTypeAfter
Closes #21433
1 parent 5e83606 commit 2ec3b9a

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

compiler/src/dotty/tools/dotc/transform/ContextFunctionResults.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,9 @@ object ContextFunctionResults:
101101
def contextFunctionResultTypeAfter(meth: Symbol, depth: Int)(using Context) =
102102
def recur(tp: Type, n: Int): Type =
103103
if n == 0 then tp
104-
else tp match
104+
else tp.dealias match
105105
case defn.FunctionTypeOfMethod(mt) => recur(mt.resType, n - 1)
106+
case _ => tp
106107
recur(meth.info.finalResultType, depth)
107108

108109
/** Should selection `tree` be eliminated since it refers to an `apply`

tests/pos/i21433.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
trait A[T]:
2+
type R = T ?=> Unit
3+
def f: R = ()
4+
5+
class B extends A[Int]:
6+
override def f: R = ()

0 commit comments

Comments
 (0)