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/typer/Applications.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/dotty/tools/dotc/typer/Applications.scala') 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 -- cgit v1.2.3