Skip to content

Extension methods don't get resolved on type inferred by GADT matching #16603

@felher

Description

@felher

Compiler version

3.2.1

Minimized code

trait MyData

object MyData:
  extension (m: MyData)
    def printIt() = println("hey from my data")

enum MyTag[A]:
  case MyDataTag extends MyTag[MyData]


def callExtension[A](tag: MyTag[A], a:A): Unit =
  tag match
    case MyTag.MyDataTag => a.printIt()

Output

Compiler error:

value printIt is not a member of A, but could be made available as an extension method.

Expectation

Should compile fine. If you annotate the type it does compile. I.e. (a: MyData).printIt() works like a charm.
Maybe related to #16590 ?

Scastie Link

https://scastie.scala-lang.org/xUDIWg9zSje6JqPNbkiuHg

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions