Skip to content

Commit

Permalink
Fix for SI-6662, macro failing too early.
Browse files Browse the repository at this point in the history
Don't give up before you try tupling. Who knows what
someone might be doing with a Unit.
  • Loading branch information
paulp authored and xeno-by committed Nov 14, 2012
1 parent 1a6c859 commit b922573
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/compiler/scala/tools/nsc/typechecker/Typers.scala
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -3078,7 +3078,7 @@ trait Typers extends Modes with Adaptations with Tags {


def checkNotMacro() = { def checkNotMacro() = {
if (fun.symbol != null && fun.symbol.filter(sym => sym != null && sym.isTermMacro && !sym.isErroneous) != NoSymbol) if (fun.symbol != null && fun.symbol.filter(sym => sym != null && sym.isTermMacro && !sym.isErroneous) != NoSymbol)
duplErrorTree(NamedAndDefaultArgumentsNotSupportedForMacros(tree, fun)) tryTupleApply getOrElse duplErrorTree(NamedAndDefaultArgumentsNotSupportedForMacros(tree, fun))
} }


if (mt.isErroneous) duplErrTree if (mt.isErroneous) duplErrTree
Expand Down
1 change: 1 addition & 0 deletions test/files/run/t6662.check
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1 @@
()
8 changes: 8 additions & 0 deletions test/files/run/t6662/Macro_1.scala
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,8 @@
import language.experimental.macros
import scala.reflect.macros.Context

object Demo {
def id[T](a: T): T = macro idImpl[T]

def idImpl[T: c.WeakTypeTag](c: Context)(a: c.Expr[T]): c.Expr[T] = a
}
8 changes: 8 additions & 0 deletions test/files/run/t6662/Test_2.scala
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,8 @@
// Macro usage:

object Test {
def main(args: Array[String]) {
val s = Demo id ()
println(s)
}
}

0 comments on commit b922573

Please sign in to comment.