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

Multi-module match type regression in 3.3.2 #18261

Open
soronpo opened this issue Jul 21, 2023 · 4 comments · Fixed by #18398
Open

Multi-module match type regression in 3.3.2 #18261

soronpo opened this issue Jul 21, 2023 · 4 comments · Fixed by #18398
Assignees
Labels
area:match-types itype:bug regression This worked in a previous version but doesn't anymore

Comments

@soronpo
Copy link
Contributor

soronpo commented Jul 21, 2023

This compilation error requires multi-module and multi-file to trigger.

Compiler version

Last good release: 3.3.2-RC1-bin-20230630-c629090-NIGHTLY
First bad release: 3.3.2-RC1-bin-20230703-0a21ecf-NIGHTLY

Minimized code

See minimized project at: https://github.com/soronpo/dottybug/tree/matchtypebug

main/DFBits.scala

trait DFBits[W <: Int]

trait Candidate[R]:
  type OutW <: Int
object Candidate:
  given [W <: Int, R <: Foo[DFBits[W]]]: Candidate[R] with
    type OutW = W

main/Foo.scala

type Foo[T] = T match
  case Any => T

test/Test.scala

def baz[L](lhs: L)(using icL: Candidate[L]): DFBits[Int] = ???
object Test:
  val x: DFBits[8] = ???
  val z: DFBits[Int] = baz(x)
  summon[Candidate[z.type]]

Output

[error] 5 |  summon[Candidate[z.type]]
[error]   |                           ^
[error]   |No given instance of type Candidate[(Test.z : DFBits[Int])] was found for parameter x of method summon in object Predef.
[error]   |I found:
[error]   |
[error]   |    Candidate.given_Candidate_R[W, R]
[error]   |
[error]   |But given instance given_Candidate_R in object Candidate does not match type Candidate[(Test.z : DFBits[Int])].

Expectation

No error.

@soronpo soronpo added itype:bug area:match-types regression This worked in a previous version but doesn't anymore labels Jul 21, 2023
@soronpo
Copy link
Contributor Author

soronpo commented Jul 21, 2023

First bad commit: 8aec1d1

@soronpo
Copy link
Contributor Author

soronpo commented Aug 24, 2023

A minor change to the minimized example causes the issue to resurface.
Here is the update minimized example (also pushed the update to https://github.com/soronpo/dottybug/tree/matchtypebug):

main/DFBits.scala

trait DFBits[W <: Int]

trait Candidate[R]:
  type OutW <: Int
object Candidate:
  given [W <: Int, R <: Foo[DFBits[W], VAL]]: Candidate[R] with
    type OutW = W

main/Foo.scala

trait VAL

type Foo[T, M] = M match
  case VAL => T

test/Test.scala

def baz[L](lhs: L)(using icL: Candidate[L]): DFBits[Int] = ???
object Test:
  val x: DFBits[8] = ???
  val z: DFBits[Int] = baz(x)
  summon[Candidate[z.type]]

@dwijnand dwijnand linked a pull request Aug 26, 2023 that will close this issue
@dwijnand dwijnand linked a pull request Oct 29, 2023 that will close this issue
@Gedochao Gedochao assigned EugeneFlesselle and unassigned dwijnand Mar 12, 2024
@EugeneFlesselle
Copy link
Contributor

EugeneFlesselle commented Apr 24, 2024

Fixing this issue depends on #20168, #20258, #20205, #20259, #20184, #20178, #20268

@soronpo
Copy link
Contributor Author

soronpo commented Apr 24, 2024

Fixing this issue depends on #20168, #20258, #20205, #20259 #20184, #20178

😮

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:match-types itype:bug regression This worked in a previous version but doesn't anymore
Projects
None yet
3 participants