From 2e664079445549288789ad24a95ce7d583ae205c Mon Sep 17 00:00:00 2001 From: Eugene Burmako Date: Tue, 31 Jan 2012 11:30:41 +0100 Subject: Introduce getAnnotations that triggers symbol completion Default getter for annotations doesn't perform initialization, hence we've faced the following bug: https://issues.scala-lang.org/browse/SI-5423. One of the approaches to fixing it would be to auto-complete on getter, but according to Martin we'd better not do that because of cycles. That's why I'm just introducing a new, eager, variation of `annotations' and redirecting public API to it. Review by @odersky. --- test/files/run/t5423.check | 1 + test/files/run/t5423.scala | 12 ++++++++++++ 2 files changed, 13 insertions(+) create mode 100644 test/files/run/t5423.check create mode 100644 test/files/run/t5423.scala (limited to 'test/files') diff --git a/test/files/run/t5423.check b/test/files/run/t5423.check new file mode 100644 index 0000000000..ae3d3fb82b --- /dev/null +++ b/test/files/run/t5423.check @@ -0,0 +1 @@ +List(table) \ No newline at end of file diff --git a/test/files/run/t5423.scala b/test/files/run/t5423.scala new file mode 100644 index 0000000000..2139773ff1 --- /dev/null +++ b/test/files/run/t5423.scala @@ -0,0 +1,12 @@ +import java.lang.Class +import scala.reflect.mirror._ +import scala.reflect.runtime.Mirror.ToolBox +import scala.reflect.Code + +final class table extends StaticAnnotation +@table class A + +object Test extends App{ + val s = classToSymbol(classOf[A]) + println(s.getAnnotations) +} -- cgit v1.2.3 From 556dc8c5406f9ab9c9470ff22d430693f00d2807 Mon Sep 17 00:00:00 2001 From: Grzegorz Kossakowski Date: Wed, 1 Feb 2012 17:32:48 +0100 Subject: Added a test-case for switches with Yvirtpatmat. Added a bunch of tests that cover changes related to switches that were applied to Yvirtpatmat implementation. Note: I didn't add those tests progressively because my changes fix trees after typer phase but do not affect resulting bytecode. How come? It's because -Yvirtpatmat will emit pattern for switches and then the old pattern matcher implementation would transform them in the old fashion in explicitouter. We cannot disable the old pattern matcher in explicitouter yet because it doesn't handle patterns used for catching exceptions. Thus, consider this as a sign of the fact that Yvirtpatmat is still work in progress. --- test/files/run/virtpatmat_switch.check | 7 +++++++ test/files/run/virtpatmat_switch.flags | 1 + test/files/run/virtpatmat_switch.scala | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+) create mode 100644 test/files/run/virtpatmat_switch.check create mode 100644 test/files/run/virtpatmat_switch.flags create mode 100644 test/files/run/virtpatmat_switch.scala (limited to 'test/files') diff --git a/test/files/run/virtpatmat_switch.check b/test/files/run/virtpatmat_switch.check new file mode 100644 index 0000000000..6ded95c010 --- /dev/null +++ b/test/files/run/virtpatmat_switch.check @@ -0,0 +1,7 @@ +zero +one +many +got a +got b +got some letter +scala.MatchError: 5 (of class java.lang.Integer) \ No newline at end of file diff --git a/test/files/run/virtpatmat_switch.flags b/test/files/run/virtpatmat_switch.flags new file mode 100644 index 0000000000..9769db9257 --- /dev/null +++ b/test/files/run/virtpatmat_switch.flags @@ -0,0 +1 @@ + -Yvirtpatmat -Xexperimental diff --git a/test/files/run/virtpatmat_switch.scala b/test/files/run/virtpatmat_switch.scala new file mode 100644 index 0000000000..2e2c31e8e5 --- /dev/null +++ b/test/files/run/virtpatmat_switch.scala @@ -0,0 +1,32 @@ +object Test extends App { + def intSwitch(x: Int) = x match { + case 0 => "zero" + case 1 => "one" + case _ => "many" + } + + println(intSwitch(0)) + println(intSwitch(1)) + println(intSwitch(10)) + + def charSwitch(x: Char) = x match { + case 'a' => "got a" + case 'b' => "got b" + case _ => "got some letter" + } + + println(charSwitch('a')) + println(charSwitch('b')) + println(charSwitch('z')) + + def implicitDefault(x: Int) = x match { + case 0 => 0 + } + + try { + implicitDefault(5) + } catch { + case e: MatchError => println(e) + } + +} -- cgit v1.2.3