Skip to content

Multi-module match type regression in 3.3.2 #18261

Open
@soronpo

Description

@soronpo

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.

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions