From 143cd7a307706a8884c9352e64addf6e9be0a181 Mon Sep 17 00:00:00 2001 From: Eugene Burmako Date: Sat, 5 Jan 2013 02:11:47 +0300 Subject: macroExpandAll is now triggered by typed Previously delayed macro expansions (the sole purpose of macroExpandAll) were triggered by `typedArgs`. Probably I wanted to save CPU cycles on not checking whether we have pending macro expansions on every iteration of typecheck. However this optimization is uncalled for, because the check just entails reading a var, therefore benefits of the current approach are negliible, whereas the robustness hit is tangible. After delayed macro expansion mechanism became more robust, it exposed a bug, well-hidden before. If one first delays a macro and then finds out that the expandee is erroneous, subsequent `macroExpandAll` will crash, because it expects a macro runtime attachment to be present. Previously the erroneous code path never got triggered, because the macro expansion never commenced. Luckily the fix was easy. --- test/files/neg/t5353.check | 4 ---- test/files/neg/t5353.scala | 3 --- test/files/run/t5353.check | 2 ++ test/files/run/t5353.scala | 9 +++++++++ 4 files changed, 11 insertions(+), 7 deletions(-) delete mode 100644 test/files/neg/t5353.check delete mode 100644 test/files/neg/t5353.scala create mode 100644 test/files/run/t5353.check create mode 100644 test/files/run/t5353.scala (limited to 'test/files') diff --git a/test/files/neg/t5353.check b/test/files/neg/t5353.check deleted file mode 100644 index bc3f77a4d6..0000000000 --- a/test/files/neg/t5353.check +++ /dev/null @@ -1,4 +0,0 @@ -t5353.scala:2: error: macro has not been expanded - def f(x: Boolean) = if (x) Array("abc") else Array() - ^ -one error found diff --git a/test/files/neg/t5353.scala b/test/files/neg/t5353.scala deleted file mode 100644 index 1ee869aac1..0000000000 --- a/test/files/neg/t5353.scala +++ /dev/null @@ -1,3 +0,0 @@ -class A { - def f(x: Boolean) = if (x) Array("abc") else Array() -} diff --git a/test/files/run/t5353.check b/test/files/run/t5353.check new file mode 100644 index 0000000000..a2906793ed --- /dev/null +++ b/test/files/run/t5353.check @@ -0,0 +1,2 @@ +1 +[Ljava.lang.Object; cannot be cast to [Ljava.lang.String; diff --git a/test/files/run/t5353.scala b/test/files/run/t5353.scala new file mode 100644 index 0000000000..5208fe527f --- /dev/null +++ b/test/files/run/t5353.scala @@ -0,0 +1,9 @@ +object Test extends App { + def f(x: Boolean) = if (x) Array("abc") else Array() + try { + println(f(true).length) + println(f(false).length) + } catch { + case ex: Throwable => println(ex.getMessage) + } +} -- cgit v1.2.3