From 907d6ea06ee2e2116dc24838b73990dca3d4c651 Mon Sep 17 00:00:00 2001 From: Eugene Burmako Date: Fri, 16 Nov 2012 14:13:33 +0100 Subject: SI-6673 fixes macro problems with eta expansions Eta expansions previously caused the typer to disable macros. That was done in order to detect eta expansion of macro defs and show the user an appropriate error message. Macros were disabled because to find out whether we're expanding a macro def, we need to get its symbol, and to get a symbol of something we need to typecheck that something. However typechecking automatically expands macros, so, unless we disable macros, after a typecheck we won't be able to analyze macro occurrences anymore. Unfortunately this solution has a fatal flaw. By disabling macros we not only prevent the eta-expandee from macro expanding, but also all the subtrees of that eta-expandee (see SI-6673). This commit adds a mechanism for fine-grained control over macro expansion. Now it's possible to prohibit only the node, but not its children from macro expanding. --- test/files/run/t6673.check | 1 + test/files/run/t6673.scala | 5 +++++ 2 files changed, 6 insertions(+) create mode 100644 test/files/run/t6673.check create mode 100644 test/files/run/t6673.scala (limited to 'test') diff --git a/test/files/run/t6673.check b/test/files/run/t6673.check new file mode 100644 index 0000000000..ef2aa551dc --- /dev/null +++ b/test/files/run/t6673.check @@ -0,0 +1 @@ +List(x) diff --git a/test/files/run/t6673.scala b/test/files/run/t6673.scala new file mode 100644 index 0000000000..115bbdf234 --- /dev/null +++ b/test/files/run/t6673.scala @@ -0,0 +1,5 @@ +object Test extends App { + def foo(f: String => Array[String])(s: String) = f(s) + val test = foo(Array(_)) _ + println(test("x").toList) +} \ No newline at end of file -- cgit v1.2.3