From 98e2f26000aaaf5abb527f776426c4759b95cde8 Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Wed, 21 Aug 2013 23:29:11 +0200 Subject: Use @uncheckedBounds to avoid introducing refchecks errors ... in code that would otherwise have smuggled through these slack LUBs in the types of trees but never in a TypeTree. More details in SI-7694. Fixes #29 --- .../run/uncheckedBounds/UncheckedBoundsSpec.scala | 57 ++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 src/test/scala/scala/async/run/uncheckedBounds/UncheckedBoundsSpec.scala (limited to 'src/test/scala/scala/async/run/uncheckedBounds/UncheckedBoundsSpec.scala') 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") + } + } + } +} -- cgit v1.2.3