summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/typechecker/Typers.scala
diff options
context:
space:
mode:
authorEugene Burmako <xeno.by@gmail.com>2015-02-24 16:25:06 +0100
committerEugene Burmako <xeno.by@gmail.com>2015-02-24 16:40:45 +0100
commitbb7f2b8d98243c2d67ff1835fcfb1df5dbea9bb6 (patch)
treef760a1a54597db28a398c66ad228588cad128927 /src/compiler/scala/tools/nsc/typechecker/Typers.scala
parentdff479907919f59f35c4efa75e46950d8a239b5b (diff)
downloadscala-bb7f2b8d98243c2d67ff1835fcfb1df5dbea9bb6.tar.gz
scala-bb7f2b8d98243c2d67ff1835fcfb1df5dbea9bb6.tar.bz2
scala-bb7f2b8d98243c2d67ff1835fcfb1df5dbea9bb6.zip
better errors for macro applications with wrong number of arguments
The tryNamesDefaults branch of application typechecking contains the checkNotMacro check, which errors out when we try to do named/default arguments for macros (that's not supported yet, see SI-5920 for discussion). Unfortunately, the check activates too early, because it turns out that we can also enter tryNamesDefaults when the user just provides insufficient number of arguments to a method by mistake, without expecting any default arguments at all. This leads to really confusing errors, which can luckily be fixed in a very simple way by moving the checkNotMacro check down the happy path of named/default typechecking.
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/Typers.scala')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index 3a85d16f55..d4756f0af3 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -3387,7 +3387,6 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
// defaults are needed. they are added to the argument list in named style as
// calls to the default getters. Example:
// foo[Int](a)() ==> foo[Int](a)(b = foo$qual.foo$default$2[Int](a))
- checkNotMacro()
// SI-8111 transformNamedApplication eagerly shuffles around the application to preserve
// evaluation order. During this process, it calls `changeOwner` on symbols that
@@ -3434,6 +3433,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
duplErrTree
} else if (lencmp2 == 0) {
// useful when a default doesn't match parameter type, e.g. def f[T](x:T="a"); f[Int]()
+ checkNotMacro()
context.diagUsedDefaults = true
doTypedApply(tree, if (blockIsEmpty) fun else fun1, allArgs, mode, pt)
} else {