aboutsummaryrefslogtreecommitdiff
path: root/src/test/scala/scala/async/run/uncheckedBounds/UncheckedBoundsSpec.scala
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/scala/scala/async/run/uncheckedBounds/UncheckedBoundsSpec.scala')
-rw-r--r--src/test/scala/scala/async/run/uncheckedBounds/UncheckedBoundsSpec.scala57
1 files changed, 57 insertions, 0 deletions
diff --git a/src/test/scala/scala/async/run/uncheckedBounds/UncheckedBoundsSpec.scala b/src/test/scala/scala/async/run/uncheckedBounds/UncheckedBoundsSpec.scala
new file mode 100644
index 0000000..5eb1f32
--- /dev/null
+++ b/src/test/scala/scala/async/run/uncheckedBounds/UncheckedBoundsSpec.scala
@@ -0,0 +1,57 @@
+package scala.async
+package run
+package uncheckedBounds
+
+import org.junit.{Test, Assert}
+import scala.async.TreeInterrogation
+
+class UncheckedBoundsSpec {
+ @Test def insufficientLub_SI_7694() {
+ suppressingFailureBefore2_10_3 {
+ eval( s"""
+ object Test {
+ import _root_.scala.async.run.toughtype._
+ import _root_.scala.async.internal.AsyncId.{async, await}
+ async {
+ (if (true) await(null: L[A, A]) else await(null: L[B, B]))
+ }
+ }
+ """, compileOptions = s"-cp ${toolboxClasspath} ")
+ }
+ }
+
+ @Test def insufficientLub_SI_7694_ScalaConcurrent() {
+ suppressingFailureBefore2_10_3 {
+ eval( s"""
+ object Test {
+ import _root_.scala.async.run.toughtype._
+ import _root_.scala.async.Async.{async, await}
+ import scala.concurrent._
+ import scala.concurrent.ExecutionContext.Implicits.global
+ async {
+ (if (true) await(null: Future[L[A, A]]) else await(null: Future[L[B, B]]))
+ }
+ }
+ """, compileOptions = s"-cp ${toolboxClasspath} ")
+ }
+ }
+
+ private def suppressingFailureBefore2_10_3(body: => Any) {
+ try {
+ body
+ } catch {
+ case x: Throwable =>
+ // @uncheckedBounds was only introduced in 2.10.3/ 2.11.0-M5, so avoid reporting this test failure in those cases.
+ scala.util.Properties.versionNumberString match {
+ case "2.10.0" | "2.10.1" | "2.10.2" | "2.11.0-M4" => // ignore, the @uncheckedBounds doesn't exist yet
+ case _ =>
+ val annotationExists =
+ reflect.runtime.currentMirror.staticClass("scala.reflect.internal.annotations.uncheckedBounds") == reflect.runtime.universe.NoSymbol
+ if (annotationExists)
+ Assert.fail("@uncheckedBounds not found in scala-reflect.jar")
+ else
+ Assert.fail(s"@uncheckedBounds exists, but it didn't prevent this failure: $x")
+ }
+ }
+ }
+}