Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tryCompiletimeConstantFold in disjointnessBoundary #20168

Merged
merged 1 commit into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions compiler/src/dotty/tools/dotc/core/TypeComparer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2902,6 +2902,8 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
tp
case tp: ConstantType =>
tp
case tp: AppliedType if tp.tryCompiletimeConstantFold.exists =>
tp.tryCompiletimeConstantFold
case tp: HKTypeLambda =>
tp
case tp: ParamRef =>
Expand Down
24 changes: 24 additions & 0 deletions tests/pos/i20166.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import scala.compiletime.ops.int.*

// NOTE ops.int.S is documented as equivalent to MyS

type MyS[X] = X match
case 0 => 1
case 1 => 2
case 2 => 3

type M[I <: Int] = 4 match
case 1 - 1 => "0"
case MyS[I] => "2"
case S[I] => "2" // Not provablyDisjoint before changes
case 2 + I => "3"
case I + 3 => "4"

val _: M[1] = "4"


type M2[I <: Int, P] = I match
case P => "b"
case _ => "c"

val _: M2[5, 2 + 3] = "b"
Loading