File tree 2 files changed +21
-1
lines changed
compiler/src/dotty/tools/dotc/core
2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -132,7 +132,7 @@ object Types {
132
132
case _ => this1.symbol eq sym
133
133
}
134
134
case this1 : RefinedOrRecType => this1.parent.isRef(sym)
135
- case this1 : HKApply => this1.superType .isRef(sym)
135
+ case this1 : HKApply => this1.underlying .isRef(sym)
136
136
case _ => false
137
137
}
138
138
Original file line number Diff line number Diff line change
1
+ case class Foo [+ X [_]](will : X [Int ]) {
2
+ def foo [Y [_]](right : Foo [Y ]) = Foo .doFoo(this , right)
3
+ }
4
+
5
+ class A [X ] { def crash = true }
6
+ class B [X ]
7
+
8
+ object Foo {
9
+ def doFoo [X [_]](left : Foo [X ], right : Foo [X ]): Foo [X ] = right
10
+
11
+ def main (args : Array [String ]): Unit = {
12
+ val fooA = Foo (new A [Int ])
13
+ val fooB = Foo (new B [Int ])
14
+ // The type for this is inferred correctly to Foo[A|B]
15
+ val fine = doFoo(fooA, fooB)
16
+ // This throws a ClassCastException because fooB isn't a Foo[A]
17
+ val oops : Foo [A ] = fooA.foo(fooB) // error: found: Foo[B], required: Foo[A]
18
+ println(oops.will.crash)
19
+ }
20
+ }
You can’t perform that action at this time.
0 commit comments