-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Match Types for Type Projection not working in 3.4.0-RC1 #19445
Comments
@sjrd Maybe you can respond. |
Minimized (tuples does not seem to cause any problems here): trait Foo:
case class Bar[A](value: A)
object FooBar extends Foo
type UnwrapTypes[Xs] =
Xs match
case Foo#Bar[x] => UnwrapTypes[x]
case Int => Int
val x: Int = ??? : UnwrapTypes[FooBar.Bar[Int]] |
@jchyb your code does not compile both in my environment (Ubuntu 23.10, Java 17, Scala 3.4.0-RC1) and in scastie https://scastie.scala-lang.org/IaEVOKQWSHqmoTmZH7U7zg Here's the compilation error with your code. Also, I reported the problem using type matching the Tuple type :) [error] -- [E007] Type Mismatch Error: /home/chungonn/development/experiments/scala3-types-match/src/main/scala/matchtypes/Main2.scala:14:13
[error] 14 |val x: Int = ??? : UnwrapTypes[FooBar.Bar[Int]]
[error] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[error] |Found: matchtypes.UnwrapTypes[matchtypes.FooBar.Bar[Int]]
[error] |Required: Int
[error] |
[error] |Note: a match type could not be fully reduced:
[error] |
[error] | trying to reduce matchtypes.UnwrapTypes[matchtypes.FooBar.Bar[Int]]
[error] | failed since selector matchtypes.FooBar.Bar[Int]
[error] | does not match case matchtypes.Foo#Bar[x] => matchtypes.UnwrapTypes[x]
[error] | and cannot be shown to be disjoint from it either.
[error] | Therefore, reduction cannot advance to the remaining case
[error] |
[error] | case Int => Int
[error] |
[error] | longer explanation available when compiling with `-explain`
[error] one error found
[error] (Compile / compileIncremental) Compilation failed
[error] Total time: 0 s, completed Jan 16, 2024, 6:24:27 AM Here's my original reported code in scastie https://scastie.scala-lang.org/21Lz8vxoQMOIwwCO4KySQw Both above snippet code will only compile using 3.3.1 |
Looks like a bug, indeed. |
Previously, for a `BaseTypeTest`, we explicitly checked the prefix of the type constructor for `=:=`. This is however too strict, as shown by #19445. We remove the test entirely, as the correct subprefixing test is already part of the overall `scrut <:< instantiatedPat` done at the end.
The minimized code below compiles in Scala 3.3.1 but is failing in Scala 3.4.0-RC1. Is this a bug or an expected behaviour in Scala 3.4.0? If yes, is there any workaround for this?
Output
The text was updated successfully, but these errors were encountered: