Skip to content

Commit eacd2f4

Browse files
committed
Teach TypeComparer that compiletime ops returns singletons
1 parent 223f17a commit eacd2f4

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1498,10 +1498,14 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
14981498
* Delegates to compareS if `tycon` is scala.compiletime.S. Otherwise, constant folds if possible.
14991499
*/
15001500
def compareCompiletimeAppliedType(tp: AppliedType, other: Type, fromBelow: Boolean): Boolean = {
1501-
if (defn.isCompiletime_S(tp.tycon.typeSymbol)) compareS(tp, other, fromBelow)
1502-
else {
1501+
defn.isCompiletime_S(tp.tycon.typeSymbol) && compareS(tp, other, fromBelow)
1502+
|| {
15031503
val folded = tp.tryCompiletimeConstantFold
15041504
if (fromBelow) recur(other, folded) else recur(folded, other)
1505+
} || other.match {
1506+
case other: TypeRef if !fromBelow && other.symbol == defn.SingletonClass =>
1507+
true // Even if not declared, the result of a compiletime operator is a constant type
1508+
case _ => false
15051509
}
15061510
}
15071511

0 commit comments

Comments
 (0)