summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/typechecker/Typers.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2011-10-15 21:59:37 +0000
committerPaul Phillips <paulp@improving.org>2011-10-15 21:59:37 +0000
commit5575b8c36859bc5d5f3a33b4491b98eed0260b8a (patch)
tree624b16e2f9aae20f1c36c0639c1227b770c47a48 /src/compiler/scala/tools/nsc/typechecker/Typers.scala
parent5690452698acafe6e4843bb08a14f6ca1cc55f8a (diff)
downloadscala-5575b8c36859bc5d5f3a33b4491b98eed0260b8a.tar.gz
scala-5575b8c36859bc5d5f3a33b4491b98eed0260b8a.tar.bz2
scala-5575b8c36859bc5d5f3a33b4491b98eed0260b8a.zip
Harden the typer against surprise unapply types.
Closes SI-5078, no review.
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/Typers.scala')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index 0ecb8efea8..7373501951 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -2588,7 +2588,7 @@ trait Typers extends Modes with Adaptations {
if (args.length > MaxTupleArity)
error(fun.pos, "too many arguments for unapply pattern, maximum = "+MaxTupleArity)
- def freshArgType(tp: Type): (Type, List[Symbol]) = (tp: @unchecked) match {
+ def freshArgType(tp: Type): (Type, List[Symbol]) = tp match {
case MethodType(param :: _, _) =>
(param.tpe, Nil)
case PolyType(tparams, restype) =>
@@ -2597,6 +2597,9 @@ trait Typers extends Modes with Adaptations {
case OverloadedType(_, _) =>
error(fun.pos, "cannot resolve overloaded unapply")
(ErrorType, Nil)
+ case _ =>
+ error(fun.pos, "an unapply method must accept a single argument.")
+ (ErrorType, Nil)
}
val unapp = unapplyMember(otpe)