diff options
author | Martin Odersky <odersky@gmail.com> | 2013-12-19 14:26:07 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2013-12-19 14:26:07 +0100 |
commit | 44ddd2ec207d08faa74e43661da664975a588e84 (patch) | |
tree | bd3b8d70e1aa87ea967ee67a07ee1610f085e459 /src/dotty/tools/dotc/typer | |
parent | c0ce16a03645056016636d7cda514daed2b7ab70 (diff) | |
download | dotty-44ddd2ec207d08faa74e43661da664975a588e84.tar.gz dotty-44ddd2ec207d08faa74e43661da664975a588e84.tar.bz2 dotty-44ddd2ec207d08faa74e43661da664975a588e84.zip |
Change to computing arguments in a pattern match.
Previously, if the result of an unapply arg type is a type with isDefined and get methods, we proceed as follows:
if the get result type is a product: take the produce argument types
otherwise take the get result type itself
The problem is if the get result type is an empty product. We solve this by demanding that the get result type is a ProductN type, not just a subclass of product.
Diffstat (limited to 'src/dotty/tools/dotc/typer')
-rw-r--r-- | src/dotty/tools/dotc/typer/Applications.scala | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/dotty/tools/dotc/typer/Applications.scala b/src/dotty/tools/dotc/typer/Applications.scala index 4202e05e1..ad6bdd787 100644 --- a/src/dotty/tools/dotc/typer/Applications.scala +++ b/src/dotty/tools/dotc/typer/Applications.scala @@ -612,13 +612,13 @@ trait Applications extends Compatibility { self: Typer => } def seqSelector = defn.RepeatedParamType.appliedTo(unapplyResult.elemType :: Nil) def getSelectors(tp: Type): List[Type] = - if (tp derivesFrom defn.ProductClass) productSelectors(tp) else tp :: Nil + if (defn.isProductSubType(tp)) productSelectors(tp) else tp :: Nil def getTp = extractorMemberType(unapplyResult, nme.get) // println(s"unapply $unapplyResult ${extractorMemberType(unapplyResult, nme.isDefined)}") if (extractorMemberType(unapplyResult, nme.isDefined) isRef defn.BooleanClass) { if (getTp.exists) return getSelectors(getTp) - else if (unapplyResult derivesFrom defn.ProductClass) return productSelectors(unapplyResult) + else if (defn.isProductSubType(unapplyResult)) return productSelectors(unapplyResult) } if (unapplyResult derivesFrom defn.SeqClass) seqSelector :: Nil else if (unapplyResult isRef defn.BooleanClass) Nil |