Skip to content

Commit 3c3fe0c

Browse files
committed
Teach TypeComparer that compiletime ops returns singletons
1 parent 48dca77 commit 3c3fe0c

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
@@ -1498,10 +1498,15 @@ 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+
tp.args.forall(arg => isSubType(arg, defn.SingletonType))
1508+
// Compile-time operations with singleton arguments are singletons
1509+
case _ => false
15051510
}
15061511
}
15071512

0 commit comments

Comments
 (0)