Closed
Description
It seems that match types behave differently across test dependency and fails to reduce (possibly any kind of different module dependency is affected).
Compiler version
v3.0.1-RC2 (also checked on nightly)
Minimized code
Minimized project at: https://github.com/soronpo/dottybug/tree/match_type_fail
Bar.scala //main file
type ++[L, R] = (L, R) match
case (Int, Int) => 2
case (String, String) => "2"
case (String, Int) => "2"
case (Int, String) => "2"
type Bar[W <: Int] = W ++ "" ++ W
val works = summon[Bar[2] =:= "2"]
Foo.scala //test file (must be in test/scala)
object Foo:
val fails = summon[Bar[2] =:= "2"]
Output
[error] -- Error: C:\IdeaProjects\dottybug\src\test\scala\Foo.scala:2:36 ------------------------------------------------------------
[error] 2 | val fails = summon[Bar[2] =:= "2"]
[error] | ^
[error] | Cannot prove that Bar[(2 : Int)] =:= ("2" : String).
[error] |
[error] | Note: a match type could not be fully reduced:
[error] |
[error] | trying to reduce Bar[(2 : Int)]
[error] | trying to reduce (2 : Int) ++ ("" : String) ++ (2 : Int)
[error] | failed since selector ((2 : Int) ++ ("" : String), (2 : Int))
[error] | does not match case (Int, Int) => (2 : Int)
[error] | and cannot be shown to be disjoint from it either.
[error] | Therefore, reduction cannot advance to the remaining cases
[error] |
[error] | case (String, String) => ("2" : String)
[error] | case (String, Int) => ("2" : String)
[error] | case (Int, String) => ("2" : String)
Expectation
No error. Notice the same expression works within the main module and fails within the test module.