Skip to content

Commit b922573

Browse files
paulpxeno-by
authored andcommitted
Fix for SI-6662, macro failing too early.
Don't give up before you try tupling. Who knows what someone might be doing with a Unit.
1 parent 1a6c859 commit b922573

File tree

4 files changed

+18
-1
lines changed

4 files changed

+18
-1
lines changed

src/compiler/scala/tools/nsc/typechecker/Typers.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3078,7 +3078,7 @@ trait Typers extends Modes with Adaptations with Tags {
30783078

30793079
def checkNotMacro() = {
30803080
if (fun.symbol != null && fun.symbol.filter(sym => sym != null && sym.isTermMacro && !sym.isErroneous) != NoSymbol)
3081-
duplErrorTree(NamedAndDefaultArgumentsNotSupportedForMacros(tree, fun))
3081+
tryTupleApply getOrElse duplErrorTree(NamedAndDefaultArgumentsNotSupportedForMacros(tree, fun))
30823082
}
30833083

30843084
if (mt.isErroneous) duplErrTree

test/files/run/t6662.check

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
()

test/files/run/t6662/Macro_1.scala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import language.experimental.macros
2+
import scala.reflect.macros.Context
3+
4+
object Demo {
5+
def id[T](a: T): T = macro idImpl[T]
6+
7+
def idImpl[T: c.WeakTypeTag](c: Context)(a: c.Expr[T]): c.Expr[T] = a
8+
}

test/files/run/t6662/Test_2.scala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Macro usage:
2+
3+
object Test {
4+
def main(args: Array[String]) {
5+
val s = Demo id ()
6+
println(s)
7+
}
8+
}

0 commit comments

Comments
 (0)