summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2013-03-25 12:57:01 -0700
committerPaul Phillips <paulp@improving.org>2013-03-25 12:57:01 -0700
commite17121d16950545d7e70ee255556ad11409bf8c3 (patch)
treee8b69d56edf45c224158981272bef69561637dff /src
parent33503d119e45379c555d6b3c9ec5c5217897126b (diff)
parentb95ca32062ae980fb45b3e93d8c90219bc1d2530 (diff)
downloadscala-e17121d16950545d7e70ee255556ad11409bf8c3.tar.gz
scala-e17121d16950545d7e70ee255556ad11409bf8c3.tar.bz2
scala-e17121d16950545d7e70ee255556ad11409bf8c3.zip
Merge pull request #2306 from retronym/ticket/7299
SI-7299 Improve error message for eta-expanding 23+ param method
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index 2458fc54e1..a98f20a971 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -4461,6 +4461,12 @@ trait Typers extends Modes with Adaptations with Tags {
treeCopy.New(tree, tpt1).setType(tp)
}
+ def functionTypeWildcard(tree: Tree, arity: Int): Type = {
+ val tp = functionType(List.fill(arity)(WildcardType), WildcardType)
+ if (tp == NoType) MaxFunctionArityError(tree)
+ tp
+ }
+
def typedEta(expr1: Tree): Tree = expr1.tpe match {
case TypeRef(_, ByNameParamClass, _) =>
val expr2 = Function(List(), expr1) setPos expr1.pos
@@ -4472,7 +4478,7 @@ trait Typers extends Modes with Adaptations with Tags {
typed1(expr2, mode, pt)
case PolyType(_, MethodType(formals, _)) =>
if (isFunctionType(pt)) expr1
- else adapt(expr1, mode, functionType(formals map (t => WildcardType), WildcardType))
+ else adapt(expr1, mode, functionTypeWildcard(expr1, formals.length))
case MethodType(formals, _) =>
if (isFunctionType(pt)) expr1
else expr1 match {
@@ -4491,7 +4497,7 @@ trait Typers extends Modes with Adaptations with Tags {
val rhs = Apply(f, args)
typed(rhs)
case _ =>
- adapt(expr1, mode, functionType(formals map (t => WildcardType), WildcardType))
+ adapt(expr1, mode, functionTypeWildcard(expr1, formals.length))
}
case ErrorType =>
expr1