aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/Definitions.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2013-12-19 14:26:07 +0100
committerMartin Odersky <odersky@gmail.com>2013-12-19 14:26:07 +0100
commit44ddd2ec207d08faa74e43661da664975a588e84 (patch)
treebd3b8d70e1aa87ea967ee67a07ee1610f085e459 /src/dotty/tools/dotc/core/Definitions.scala
parentc0ce16a03645056016636d7cda514daed2b7ab70 (diff)
downloaddotty-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/core/Definitions.scala')
-rw-r--r--src/dotty/tools/dotc/core/Definitions.scala3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/dotty/tools/dotc/core/Definitions.scala b/src/dotty/tools/dotc/core/Definitions.scala
index ebd99ad6c..96e4f0138 100644
--- a/src/dotty/tools/dotc/core/Definitions.scala
+++ b/src/dotty/tools/dotc/core/Definitions.scala
@@ -318,6 +318,9 @@ class Definitions(implicit ctx: Context) {
arity <= MaxTupleArity && (tp isRef TupleClass(arity))
}
+ def isProductSubType(tp: Type) =
+ (tp derivesFrom ProductClass) && tp.baseClasses.exists(ProductClasses contains _)
+
def isFunctionType(tp: Type) = {
val arity = tp.dealias.typeArgs.length - 1
0 <= arity && arity <= MaxFunctionArity && (tp isRef FunctionClass(arity))