Skip to content

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

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

Closed
felher opened this issue Dec 30, 2022 · 2 comments · Fixed by #16638
Closed

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

felher opened this issue Dec 30, 2022 · 2 comments · Fixed by #16638

Comments

@felher
Copy link
Contributor

felher commented Dec 30, 2022

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

@felher felher added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Dec 30, 2022
@prolativ prolativ added area:typer area:gadt and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Jan 2, 2023
@SethTisue
Copy link
Member

SethTisue commented Jan 6, 2023

Thanks for the report and the clean minimization.

Maybe related to #16590 ?

That one looks tuple-specific, but after we fix this one, it'll be worth checking if that other one progresses.

@dwijnand dwijnand linked a pull request Jan 9, 2023 that will close this issue
@SethTisue
Copy link
Member

after we fix this one, it'll be worth checking if that other one progresses

no change

@Kordyjan Kordyjan added this to the 3.3.0 milestone Aug 1, 2023
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