Skip to content

Commit ccb7b13

Browse files
authored
Merge pull request #7658 from dotty-staging/fix-7067
Fix #7067: type avoidance should handle both ThisType and TypeRef
2 parents e476fe8 + 4de8096 commit ccb7b13

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

compiler/src/dotty/tools/dotc/typer/TypeAssigner.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,9 @@ trait TypeAssigner {
7070
parent
7171
}
7272

73-
def close(tp: Type) = RecType.closeOver(rt => tp.substThis(cls, rt.recThis))
73+
def close(tp: Type) = RecType.closeOver { rt =>
74+
tp.subst(cls :: Nil, rt.recThis :: Nil).substThis(cls, rt.recThis)
75+
}
7476

7577
def isRefinable(sym: Symbol) = !sym.is(Private) && !sym.isConstructor
7678
val refinableDecls = info.decls.filter(isRefinable)

tests/pos/i7067.scala

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
abstract class Foo[T] {
2+
type Species
3+
def foo(s: Species): Nothing = ???
4+
}
5+
6+
class Test {
7+
def species[T] = {
8+
class FooT extends Foo[T] {
9+
type Species = FooT
10+
}
11+
new FooT()
12+
}
13+
}

0 commit comments

Comments
 (0)