File tree 4 files changed +10
-10
lines changed
compiler/src/dotty/tools/dotc/core
4 files changed +10
-10
lines changed Original file line number Diff line number Diff line change @@ -63,10 +63,10 @@ class CheckRealizable(implicit ctx: Context) {
63
63
*/
64
64
private val checkedFields : mutable.Set [Symbol ] = mutable.LinkedHashSet [Symbol ]()
65
65
66
- /** Is symbol's definitition a lazy val?
66
+ /** Is symbol's definitition a lazy or erased val?
67
67
* (note we exclude modules here, because their realizability is ensured separately)
68
68
*/
69
- private def isLateInitialized (sym : Symbol ) = sym.is(Lazy , butNot = Module )
69
+ private def isLateInitialized (sym : Symbol ) = sym.is(Lazy | Erased , butNot = Module )
70
70
71
71
/** The realizability status of given type `tp`*/
72
72
def realizability (tp : Type ): Realizability = tp.dealias match {
@@ -156,10 +156,10 @@ class CheckRealizable(implicit ctx: Context) {
156
156
private def memberRealizability (tp : Type ) = {
157
157
def checkField (sofar : Realizability , fld : SingleDenotation ): Realizability =
158
158
sofar andAlso {
159
- if (checkedFields.contains(fld.symbol) || fld.symbol.is(Private | Mutable | Lazy ))
159
+ if (checkedFields.contains(fld.symbol) || fld.symbol.is(Private | Mutable | Lazy | Erased ))
160
160
// if field is private it cannot be part of a visible path
161
161
// if field is mutable it cannot be part of a path
162
- // if field is lazy it does not need to be initialized when the owning object is
162
+ // if field is lazy or erased it does not need to be initialized when the owning object is
163
163
// so in all cases the field does not influence realizability of the enclosing object.
164
164
Realizable
165
165
else {
Original file line number Diff line number Diff line change @@ -597,7 +597,7 @@ object SymDenotations {
597
597
598
598
/** Is this a denotation of a stable term (or an arbitrary type)? */
599
599
final def isStable (implicit ctx : Context ) =
600
- isType || ! is(Erased ) && (is( Stable ) || ! (is(UnstableValue ) || info.isInstanceOf [ExprType ]) )
600
+ isType || is(Stable ) || ! (is(UnstableValue ) || info.isInstanceOf [ExprType ])
601
601
602
602
/** Is this a "real" method? A real method is a method which is:
603
603
* - not an accessor
Original file line number Diff line number Diff line change @@ -6,11 +6,11 @@ object Test {
6
6
println(fun(new Bar ))
7
7
}
8
8
9
- def fun (erased foo : Foo ): foo.X = { // error
10
- null .asInstanceOf [foo.X ] // error
9
+ def fun (erased foo : Foo ): foo.X = { // ok
10
+ null .asInstanceOf [foo.X ] // ok
11
11
}
12
12
13
- def fun2 (erased foo : Foo )(erased bar : foo.B ): bar.X = { // error // error
13
+ def fun2 (erased foo : Foo )(erased bar : foo.B ): bar.X = { // error
14
14
null .asInstanceOf [bar.X ] // error
15
15
}
16
16
}
Original file line number Diff line number Diff line change 1
1
class X { type R }
2
- class T (erased val a : X )(val value : a.R ) // error
2
+ class T (erased val a : X )(val value : a.R )
3
3
4
4
object App {
5
5
def coerce [U , V ](u : U ): V = {
@@ -8,7 +8,7 @@ object App {
8
8
9
9
class T [A <: X ](erased val a : A )(val value : a.R ) // error
10
10
11
- object O { lazy val x : Y & X = ??? } // warning
11
+ object O { lazy val x : Y & X = ??? }
12
12
13
13
val a = new T [Y & X ](O .x)(u)
14
14
a.value
You can’t perform that action at this time.
0 commit comments