File tree 2 files changed +20
-11
lines changed
compiler/src/dotty/tools/dotc/core
2 files changed +20
-11
lines changed Original file line number Diff line number Diff line change @@ -70,18 +70,20 @@ class CheckRealizable(implicit ctx: Context) {
70
70
def realizability (tp : Type ): Realizability = tp.dealias match {
71
71
case tp : TermRef =>
72
72
val sym = tp.symbol
73
- if (sym.is(Stable )) realizability(tp.prefix)
74
- else {
75
- val r =
76
- if (! sym.isStable) NotStable
77
- else if (! isLateInitialized(sym)) Realizable
78
- else if (! sym.isEffectivelyFinal) new NotFinal (sym)
79
- else realizability(tp.info).mapError(r => new ProblemInUnderlying (tp.info, r))
80
- r andAlso {
81
- sym.setFlag(Stable )
82
- realizability(tp.prefix)
73
+ val r =
74
+ if (sym.is(Stable )) realizability(tp.prefix)
75
+ else {
76
+ val r =
77
+ if (! sym.isStable) NotStable
78
+ else if (! isLateInitialized(sym)) Realizable
79
+ else if (! sym.isEffectivelyFinal) new NotFinal (sym)
80
+ else realizability(tp.info).mapError(r => new ProblemInUnderlying (tp.info, r))
81
+ r andAlso {
82
+ sym.setFlag(Stable )
83
+ realizability(tp.prefix)
84
+ }
83
85
}
84
- }
86
+ if (r == Realizable || tp.info.isStableRealizable) Realizable else r
85
87
case _ : SingletonType | NoPrefix =>
86
88
Realizable
87
89
case tp =>
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ import Denotations._
18
18
import Periods ._
19
19
import util .Stats ._
20
20
import util .SimpleIdentitySet
21
+ import CheckRealizable ._
21
22
import reporting .diagnostic .Message
22
23
import ast .tpd ._
23
24
import ast .TreeTypeMap
@@ -157,6 +158,12 @@ object Types {
157
158
case _ => false
158
159
}
159
160
161
+ /** Does this type denote a realizable stable reference? Much more expensive to check
162
+ * than isStable, that's why some of the checks are done later in PostTyper.
163
+ */
164
+ final def isStableRealizable (implicit ctx : Context ): Boolean =
165
+ isStable && realizability(this ) == Realizable
166
+
160
167
/** Is this type a (possibly refined or applied or aliased) type reference
161
168
* to the given type symbol?
162
169
* @sym The symbol to compare to. It must be a class symbol or abstract type.
You can’t perform that action at this time.
0 commit comments