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

match type failure to reduce with separate compilation #12944

Closed
soronpo opened this issue Jun 25, 2021 · 1 comment · Fixed by #13636
Closed

match type failure to reduce with separate compilation #12944

soronpo opened this issue Jun 25, 2021 · 1 comment · Fixed by #13636

Comments

@soronpo
Copy link
Contributor

soronpo commented Jun 25, 2021

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.

@griggt griggt changed the title match type failure to reduce across test dependency match type failure to reduce with separate compilation Jun 25, 2021
@griggt
Copy link
Contributor

griggt commented Jun 26, 2021

This looks to be a regression from 3.0.0-M2 (regressed in #7389)

@soronpo soronpo added the regression This worked in a previous version but doesn't anymore label Jul 6, 2021
@dwijnand dwijnand removed the regression This worked in a previous version but doesn't anymore label Aug 28, 2021
OlivierBlanvillain added a commit to dotty-staging/dotty that referenced this issue Sep 29, 2021
@OlivierBlanvillain OlivierBlanvillain linked a pull request Sep 29, 2021 that will close this issue
OlivierBlanvillain added a commit that referenced this issue Sep 30, 2021
olsdavis pushed a commit to olsdavis/dotty that referenced this issue Apr 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants