Skip to content

Commit

Permalink
Teach provablyDisjoint to fold compile-time constants
Browse files Browse the repository at this point in the history
  • Loading branch information
dwijnand committed Jun 20, 2023
1 parent 55898df commit 7c861cb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions compiler/src/dotty/tools/dotc/core/TypeComparer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2845,6 +2845,10 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
else
invariantDisjoint(arg1, arg2, tparam)
}
case (tp1: AppliedType, tp2) if tp1.tryCompiletimeConstantFold.exists =>
provablyDisjoint(tp1.tryCompiletimeConstantFold, tp2)
case (tp1, tp2: AppliedType) if tp2.tryCompiletimeConstantFold.exists =>
provablyDisjoint(tp1, tp2.tryCompiletimeConstantFold)
case (tp1: HKLambda, tp2: HKLambda) =>
provablyDisjoint(tp1.resType, tp2.resType)
case (_: HKLambda, _) =>
Expand Down
7 changes: 7 additions & 0 deletions tests/pos/i16596.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import scala.compiletime.ops.int, int.-

type Count[N, T] <: Tuple = (N, T) match
case (0, T) => EmptyTuple
case (N, T) => T *: Count[N - 1, T]

val a: Count[3, Int] = (1, 2, 3)

0 comments on commit 7c861cb

Please sign in to comment.