aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/typer/Applications.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2014-01-06 08:58:31 +0100
committerMartin Odersky <odersky@gmail.com>2014-01-06 08:58:39 +0100
commit6b3f2225a8d6de898ca9a2299570056807de1a92 (patch)
treec9bf818777819c7a6e748033cf1bf571e428d60a /src/dotty/tools/dotc/typer/Applications.scala
parent7b30d5b7a9fe7d89a252d8d9a07fd4c009e49a0d (diff)
downloaddotty-6b3f2225a8d6de898ca9a2299570056807de1a92.tar.gz
dotty-6b3f2225a8d6de898ca9a2299570056807de1a92.tar.bz2
dotty-6b3f2225a8d6de898ca9a2299570056807de1a92.zip
Change to computing of unapply patterns.
If scrutinee has a get method with a product result type, assume the product members as pattern arguments only if there are more than one argument patterns. Without this tweak, the pattern Some((x, y)) would not typecheck, as the extractor result type is Option[(S, T)], so normally two patterns of type S and T would be expected. Interestingly, with the tweak we still get a sort of auto-detupling. Some(x, y) would also work (did before the change, and still does now).
Diffstat (limited to 'src/dotty/tools/dotc/typer/Applications.scala')
-rw-r--r--src/dotty/tools/dotc/typer/Applications.scala3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/dotty/tools/dotc/typer/Applications.scala b/src/dotty/tools/dotc/typer/Applications.scala
index 47b10c4aa..6514a6a01 100644
--- a/src/dotty/tools/dotc/typer/Applications.scala
+++ b/src/dotty/tools/dotc/typer/Applications.scala
@@ -598,7 +598,8 @@ trait Applications extends Compatibility { self: Typer =>
}
def seqSelector = defn.RepeatedParamType.appliedTo(unapplyResult.elemType :: Nil)
def getSelectors(tp: Type): List[Type] =
- if (defn.isProductSubType(tp)) productSelectors(tp) else tp :: Nil
+ if (defn.isProductSubType(tp) && args.length > 1) productSelectors(tp)
+ else tp :: Nil
def getTp = extractorMemberType(unapplyResult, nme.get)
// println(s"unapply $unapplyResult ${extractorMemberType(unapplyResult, nme.isDefined)}")