Skip to content

Commit ab06e2d

Browse files
committed
Generalize definition of Type#isStable
We now consider a type also as stable if it refers to an ExprType whose result type is stable. The previous commit made pos/z1720.scala break, because it skolemized unstable argument types. This commit makes the test pass again.
1 parent bb0faff commit ab06e2d

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

compiler/src/dotty/tools/dotc/core/Types.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,11 @@ object Types {
107107
final def isValueTypeOrLambda: Boolean = isValueType || this.isInstanceOf[TypeLambda]
108108

109109
/** Does this type denote a stable reference (i.e. singleton type)? */
110-
@tailrec final def isStable(implicit ctx: Context): Boolean = stripTypeVar match {
111-
case tp: TermRef => tp.termSymbol.isStable && tp.prefix.isStable
110+
final def isStable(implicit ctx: Context): Boolean = stripTypeVar match {
111+
case tp: TermRef => tp.termSymbol.isStable && tp.prefix.isStable || tp.info.isStable
112112
case _: SingletonType | NoPrefix => true
113113
case tp: RefinedOrRecType => tp.parent.isStable
114+
case tp: ExprType => tp.resultType.isStable
114115
case _ => false
115116
}
116117

0 commit comments

Comments
 (0)