From 44ddd2ec207d08faa74e43661da664975a588e84 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Thu, 19 Dec 2013 14:26:07 +0100 Subject: 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. --- src/dotty/tools/dotc/core/Definitions.scala | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/dotty/tools/dotc/core/Definitions.scala') 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)) -- cgit v1.2.3