File tree 7 files changed +57
-30
lines changed
compiler/src/dotty/tools/dotc/core
7 files changed +57
-30
lines changed Original file line number Diff line number Diff line change @@ -600,7 +600,7 @@ object SymDenotations {
600
600
601
601
/** Is this a denotation of a stable term (or an arbitrary type)? */
602
602
final def isStable (implicit ctx : Context ) =
603
- isType || is(Stable ) || ! (is(UnstableValue ) || info.isInstanceOf [ExprType ])
603
+ isType || ! is(Erased ) && (is( Stable ) || ! (is(UnstableValue ) || info.isInstanceOf [ExprType ]) )
604
604
605
605
/** Is this a "real" method? A real method is a method which is:
606
606
* - not an accessor
Original file line number Diff line number Diff line change
1
+ // Could become a run test if we had totality checking for erased arguments
2
+
3
+ object Test {
4
+
5
+ def main (args : Array [String ]): Unit = {
6
+ println(fun(new Bar ))
7
+ }
8
+
9
+ def fun (erased foo : Foo ): foo.X = { // error
10
+ null .asInstanceOf [foo.X ] // error
11
+ }
12
+
13
+ def fun2 (erased foo : Foo )(erased bar : foo.B ): bar.X = { // error // error
14
+ null .asInstanceOf [bar.X ] // error
15
+ }
16
+ }
17
+
18
+ class Foo {
19
+ type X
20
+ type B <: Bar
21
+ }
22
+
23
+ class Bar extends Foo {
24
+ type X = String
25
+ }
Original file line number Diff line number Diff line change
1
+ // Could become a neg test if we had totality checking for erased arguments
2
+
1
3
object Test {
2
4
3
5
fun1(new Bar )
4
6
fun2(new Bar )
5
7
fun3(new Bar )
6
8
7
- def fun1 [F >: Bar <: Foo ](erased f : F ): f.X = null .asInstanceOf [f.X ]
8
- def fun2 [F >: Bar <: Foo ](erased f : F )(erased bar : f.B ): f.B = null .asInstanceOf [f.B ]
9
- def fun3 [F >: Bar <: Foo ](erased f : F )(erased b : f.B ): b.X = null .asInstanceOf [b.X ]
9
+ def fun1 [F >: Bar <: Foo ](erased f : F ): f.X = null .asInstanceOf [f.X ] // error // error
10
+ def fun2 [F >: Bar <: Foo ](erased f : F )(erased bar : f.B ): f.B = null .asInstanceOf [f.B ] // error // error // error
11
+ def fun3 [F >: Bar <: Foo ](erased f : F )(erased b : f.B ): b.X = null .asInstanceOf [b.X ] // error // error // error
10
12
}
11
13
12
14
class Foo {
Original file line number Diff line number Diff line change
1
+ // Could become a neg test if we had totality checking for erased arguments
2
+
1
3
object Test {
2
4
3
5
type F >: Bar <: Foo
4
6
5
7
class A (erased val f : F ) {
6
- type F1 <: f.X
7
- type F2 [Z <: f.X ]
8
+ type F1 <: f.X // error
9
+ type F2 [Z <: f.X ] // error
8
10
}
9
11
10
12
}
Original file line number Diff line number Diff line change
1
+ class X { type R }
2
+ class T (erased val a : X )(val value : a.R ) // error
3
+
4
+ object App {
5
+ def coerce [U , V ](u : U ): V = {
6
+ trait X { type R >: U }
7
+ trait Y { type R = V }
8
+
9
+ class T [A <: X ](erased val a : A )(val value : a.R ) // error
10
+
11
+ object O { lazy val x : Y & X = ??? } // warning
12
+
13
+ val a = new T [Y & X ](O .x)(u)
14
+ a.value
15
+ }
16
+
17
+ def main (args : Array [String ]): Unit = {
18
+ val x : Int = coerce[String , Int ](" a" )
19
+ println(x + 1 )
20
+
21
+ }
22
+ }
Load Diff This file was deleted.
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments