File tree Expand file tree Collapse file tree 2 files changed +20
-11
lines changed
compiler/src/dotty/tools/dotc/core Expand file tree Collapse file tree 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) {
7070 def realizability (tp : Type ): Realizability = tp.dealias match {
7171 case tp : TermRef =>
7272 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+ }
8385 }
84- }
86+ if (r == Realizable || tp.info.isStableRealizable) Realizable else r
8587 case _ : SingletonType | NoPrefix =>
8688 Realizable
8789 case tp =>
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ import Denotations._
1818import Periods ._
1919import util .Stats ._
2020import util .SimpleIdentitySet
21+ import CheckRealizable ._
2122import reporting .diagnostic .Message
2223import ast .tpd ._
2324import ast .TreeTypeMap
@@ -157,6 +158,12 @@ object Types {
157158 case _ => false
158159 }
159160
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+
160167 /** Is this type a (possibly refined or applied or aliased) type reference
161168 * to the given type symbol?
162169 * @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