Skip to content

Commit 1c75447

Browse files
committed
Teach TypeComparer that compiletime ops returns singletons
1 parent fa89ac4 commit 1c75447

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1487,10 +1487,15 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
14871487
* Delegates to compareS if `tycon` is scala.compiletime.S. Otherwise, constant folds if possible.
14881488
*/
14891489
def compareCompiletimeAppliedType(tp: AppliedType, other: Type, fromBelow: Boolean): Boolean = {
1490-
if (defn.isCompiletime_S(tp.tycon.typeSymbol)) compareS(tp, other, fromBelow)
1491-
else {
1490+
defn.isCompiletime_S(tp.tycon.typeSymbol) && compareS(tp, other, fromBelow)
1491+
|| {
14921492
val folded = tp.tryCompiletimeConstantFold
14931493
if (fromBelow) recur(other, folded) else recur(folded, other)
1494+
} || other.match {
1495+
case other: TypeRef if !fromBelow && other.symbol == defn.SingletonClass =>
1496+
tp.args.forall(arg => isSubType(arg, defn.SingletonType))
1497+
// Compile-time operations with singleton arguments are singletons
1498+
case _ => false
14941499
}
14951500
}
14961501

0 commit comments

Comments
 (0)