diff options
author | Olivier Blanvillain <olivier.blanvillain@gmail.com> | 2017-04-13 09:18:46 +0200 |
---|---|---|
committer | Olivier Blanvillain <olivier.blanvillain@gmail.com> | 2017-04-13 10:39:29 +0200 |
commit | 3e04b6f3aa4e4088220f199bd6aa5c6644c22354 (patch) | |
tree | c2b1a480a11ea6b23b2bc2f1b322203a8425c4da /compiler/src/dotty/tools/dotc/typer/Typer.scala | |
parent | 3a9deec8e7a3a093e9b56461650857c4cb7a9d8c (diff) | |
download | dotty-3e04b6f3aa4e4088220f199bd6aa5c6644c22354.tar.gz dotty-3e04b6f3aa4e4088220f199bd6aa5c6644c22354.tar.bz2 dotty-3e04b6f3aa4e4088220f199bd6aa5c6644c22354.zip |
Revert <: Product requierment in pattern matching
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 #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.
Diffstat (limited to 'compiler/src/dotty/tools/dotc/typer/Typer.scala')
-rw-r--r-- | compiler/src/dotty/tools/dotc/typer/Typer.scala | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/compiler/src/dotty/tools/dotc/typer/Typer.scala b/compiler/src/dotty/tools/dotc/typer/Typer.scala index 4bf938fd4..02538671e 100644 --- a/compiler/src/dotty/tools/dotc/typer/Typer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Typer.scala @@ -759,7 +759,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit /** Is `formal` a product type which is elementwise compatible with `params`? */ def ptIsCorrectProduct(formal: Type) = { isFullyDefined(formal, ForceDegree.noBottom) && - Applications.canProductMatch(formal) && + defn.isProductSubType(formal) && Applications.productSelectorTypes(formal).corresponds(params) { (argType, param) => param.tpt.isEmpty || argType <:< typedAheadType(param.tpt).tpe |