Skip to content
This repository has been archived by the owner on Jun 5, 2023. It is now read-only.

Extractor extension methods #112

Closed
nicolasstucki opened this issue Mar 20, 2020 · 5 comments · Fixed by scala/scala3#14447
Closed

Extractor extension methods #112

nicolasstucki opened this issue Mar 20, 2020 · 5 comments · Fixed by scala/scala3#14447

Comments

@nicolasstucki
Copy link

nicolasstucki commented Mar 20, 2020

minimized code

type X
val x: X = ???
extension (x: X) def unapply(arg: Any): Boolean = true
def test =
  ??? match
    case x() =>

Compilation output

-- [E127] Syntax Error: tests/run-macros/i8530-b/Macros_1.scala:7:9 ------------
7 |    case x() =>
  |         ^
  |x cannot be used as an extractor in a pattern because it lacks an unapply or unapplySeq method

expectation

Extension methods should be taken into account for extractors. The code above should compile.

@odersky
Copy link

odersky commented Mar 20, 2020

Should this go to the feature request repo?

@abgruszecki

This comment has been minimized.

@nicolasstucki
Copy link
Author

Should this go to the feature request repo?

Not sure, it is part of supporting code that was supported in Scala 2

@nicolasstucki

This comment has been minimized.

@nicolasstucki
Copy link
Author

This feature is already supported. Adding a regression test and closing this issue in scala/scala3#14447.

olsdavis pushed a commit to olsdavis/dotty that referenced this issue Apr 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants