Skip to content

Revert <: Product requierment in pattern matching #2249

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

Merged
merged 1 commit into from
Apr 13, 2017

Conversation

OlivierBlanvillain
Copy link
Contributor

The change in question broke the following pattern, commonly used in name based pattern matching:

object ProdEmpty {
  def _1: Int = ???
  def _2: String = ???
  def isEmpty = true
  def get = this
}

This type define both _1 and get + isEmpty (but is not <: Product). After #1938, ProdEmpty became eligibles for both product and name based pattern. Because "in case of ambiguities, Product Pattern is preferred over Name Based Pattern", isEmpty wouldn't be used, breaking the scalac semantics.

Since this issue is blocker for cross compiling the back-end, I propose to first merge the revert, and discuss possible alternatives later.

The change in question broke the following pattern, commonly used in name based pattern matching:

```scala
object ProdEmpty {
  def _1: Int = ???
  def _2: String = ???
  def isEmpty = true
  def get = this
}
```

This type define both `_1` and `get` + `isEmpty` (but is not <: Product). After scala#1938, `ProdEmpty` became eligibles for both product and name based pattern. Because "in case of ambiguities, *Product Pattern* is preferred over *Name Based Pattern*", isEmpty wouldn't be used, breaking the scalac semantics.
@odersky
Copy link
Contributor

odersky commented Apr 13, 2017

LGTM

@odersky odersky merged commit b8ed254 into scala:master Apr 13, 2017
@allanrenucci allanrenucci deleted the revert-product branch December 14, 2017 19:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants