Skip to content

Commit da514ce

Browse files
committed
Avoid comparing unkown atoms of non-singleton types
1 parent 528bb7e commit da514ce

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1589,7 +1589,11 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
15891589
Some(verified(false))
15901590
else
15911591
None
1592-
case _ => Some(verified(recur(tp1, NothingType)))
1592+
case Atoms.Unknown =>
1593+
if knownSingletons then
1594+
Some(verified(recur(tp1, NothingType)))
1595+
else
1596+
None
15931597
case _ => None
15941598

15951599
/** Subtype test for corresponding arguments in `args1`, `args2` according to

tests/pos/16583.scala

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import compiletime.constValueTuple
2+
3+
val ll0: Tuple3["one", "two", "three"] = constValueTuple[("one", "two", "three")]
4+
val ll1 = constValueTuple[("one", "two", "three")].toList
5+
val ll3: List["one" | ("two" | ("three" | Nothing))] = constValueTuple[("one", "two", "three")].toList
6+
val ll4: List["one" | ("two" | "three")] = constValueTuple[("one", "two", "three")].toList
7+
8+
inline def labels[Labels <: Tuple](using ev: Tuple.Union[Labels] <:< String): List[String] =
9+
val tmp = constValueTuple[Labels].toList
10+
ev.substituteCo( tmp )
11+
12+
def test = labels[("one", "two", "three")].mkString("<", ", ", ">")
13+
14+
def test2(tup: ("one", "two", "three")) = tup.toList

0 commit comments

Comments
 (0)