diff options
Diffstat (limited to 'test')
232 files changed, 1764 insertions, 392 deletions
diff --git a/test/ant/test-basic/build.xml b/test/ant/test-basic/build.xml new file mode 100644 index 0000000000..acc210806f --- /dev/null +++ b/test/ant/test-basic/build.xml @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<project name="test-simple" default="compile"> + <description>Super simple test for Scala</description> + + <target name="init"> + <!-- Define project CLASSPATH. --> + <property name="base.dir" value="../../.."/> + <property name="pack.dir" value="${base.dir}/build/pack/"/> + <property name="build.dir" value="classes"/> + <property name="src.dir" value="src"/> + <property name="jvmargs" value=""/> + <path id="scala.classpath"> + <fileset dir="${pack.dir}/lib/"> <include name="*.jar" /> </fileset> + </path> + + <!-- Define scala compiler, scaladoc, etc command --> + <taskdef resource="scala/tools/ant/antlib.xml"> + <classpath refid="scala.classpath" /> + </taskdef> + </target> + + <target name="compile" depends="init"> + <mkdir dir="${build.dir}"/> + + <scalac srcdir="${src.dir}" destdir="${build.dir}" + classpathref="scala.classpath" fork="true" target="jvm-1.5" + deprecation="no" addparams="-no-specialization" + jvmargs="${jvmargs} -XX:+UseConcMarkSweepGC"> + <include name="**/*.scala"/> + </scalac> + </target> +</project> diff --git a/test/ant/test-basic/src/test-1.scala b/test/ant/test-basic/src/test-1.scala new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/ant/test-basic/src/test-1.scala diff --git a/test/files/jvm/duration-java.check b/test/files/jvm/duration-java.check index 7ae257dcc0..49d06fbe93 100644 --- a/test/files/jvm/duration-java.check +++ b/test/files/jvm/duration-java.check @@ -201,7 +201,7 @@ 6.0E7 seconds => 1000000 minutes 1.0E8 seconds => 100000000 seconds 1.0E9 seconds => 1000000000 seconds - 1.0E12 seconds => 9223372036854775807 nanoseconds + 1.0E12 seconds => class java.lang.IllegalArgumentException 0.0 minutes => 0 days 1.0 minutes => 1 minute 7.0 minutes => 7 minutes @@ -251,8 +251,8 @@ 3.0E7 minutes => 500000 hours 6.0E7 minutes => 1000000 hours 1.0E8 minutes => 100000000 minutes - 1.0E9 minutes => 9223372036854775807 nanoseconds - 1.0E12 minutes => 9223372036854775807 nanoseconds + 1.0E9 minutes => class java.lang.IllegalArgumentException + 1.0E12 minutes => class java.lang.IllegalArgumentException 0.0 hours => 0 days 1.0 hours => 1 hour 7.0 hours => 7 hours @@ -295,15 +295,15 @@ 60000.0 hours => 2500 days 100000.0 hours => 100000 hours 1000000.0 hours => 1000000 hours - 7000000.0 hours => 9223372036854775807 nanoseconds - 1.0E7 hours => 9223372036854775807 nanoseconds - 1.2E7 hours => 9223372036854775807 nanoseconds - 2.4E7 hours => 9223372036854775807 nanoseconds - 3.0E7 hours => 9223372036854775807 nanoseconds - 6.0E7 hours => 9223372036854775807 nanoseconds - 1.0E8 hours => 9223372036854775807 nanoseconds - 1.0E9 hours => 9223372036854775807 nanoseconds - 1.0E12 hours => 9223372036854775807 nanoseconds + 7000000.0 hours => class java.lang.IllegalArgumentException + 1.0E7 hours => class java.lang.IllegalArgumentException + 1.2E7 hours => class java.lang.IllegalArgumentException + 2.4E7 hours => class java.lang.IllegalArgumentException + 3.0E7 hours => class java.lang.IllegalArgumentException + 6.0E7 hours => class java.lang.IllegalArgumentException + 1.0E8 hours => class java.lang.IllegalArgumentException + 1.0E9 hours => class java.lang.IllegalArgumentException + 1.0E12 hours => class java.lang.IllegalArgumentException 0.0 days => 0 days 1.0 days => 1 day 7.0 days => 7 days @@ -345,16 +345,18 @@ 30000.0 days => 30000 days 60000.0 days => 60000 days 100000.0 days => 100000 days - 1000000.0 days => 9223372036854775807 nanoseconds - 7000000.0 days => 9223372036854775807 nanoseconds - 1.0E7 days => 9223372036854775807 nanoseconds - 1.2E7 days => 9223372036854775807 nanoseconds - 2.4E7 days => 9223372036854775807 nanoseconds - 3.0E7 days => 9223372036854775807 nanoseconds - 6.0E7 days => 9223372036854775807 nanoseconds - 1.0E8 days => 9223372036854775807 nanoseconds - 1.0E9 days => 9223372036854775807 nanoseconds - 1.0E12 days => 9223372036854775807 nanoseconds + 1000000.0 days => class java.lang.IllegalArgumentException + 7000000.0 days => class java.lang.IllegalArgumentException + 1.0E7 days => class java.lang.IllegalArgumentException + 1.2E7 days => class java.lang.IllegalArgumentException + 2.4E7 days => class java.lang.IllegalArgumentException + 3.0E7 days => class java.lang.IllegalArgumentException + 6.0E7 days => class java.lang.IllegalArgumentException + 1.0E8 days => class java.lang.IllegalArgumentException + 1.0E9 days => class java.lang.IllegalArgumentException + 1.0E12 days => class java.lang.IllegalArgumentException +10000000000000001 nanoseconds => 10000000000000001 nanoseconds +10000000000000002 nanoseconds => 10000000000000002 nanoseconds Inf => Duration.Inf -Inf => Duration.MinusInf +Inf => Duration.Inf diff --git a/test/files/jvm/duration-java/Test.java b/test/files/jvm/duration-java/Test.java index 02feb522b8..1c53ccb266 100644 --- a/test/files/jvm/duration-java/Test.java +++ b/test/files/jvm/duration-java/Test.java @@ -26,10 +26,18 @@ public class Test { for (TimeUnit t : TimeUnit.values()) { for (Double n: makeNumbers()) { String s = "" + n + " " + t.toString().toLowerCase(); - Duration d = Duration.create(n, t); - p(String.format("%25s => %s", s, d)); + String result; + try { + Duration d = Duration.create(n, t); + result = d.toString(); + } catch(Exception e) { + result = e.getClass().toString(); + } + p(String.format("%25s => %s", s, result)); } } + for (String s: new String[] {"10000000000000001 nanoseconds", "10000000000000002 nanoseconds"}) + p(String.format("%25s => %s", s, Duration.create(s))); for (String s: Arrays.asList("Inf", "-Inf", "+Inf", "PlusInf", "MinusInf")) { Duration d = Duration.create(s); p(String.format("%25s => %s", s, d)); diff --git a/test/files/jvm/duration-tck.scala b/test/files/jvm/duration-tck.scala new file mode 100644 index 0000000000..0947e84004 --- /dev/null +++ b/test/files/jvm/duration-tck.scala @@ -0,0 +1,186 @@ +/** + * Copyright (C) 2012 Typesafe Inc. <http://www.typesafe.com> + */ + +import scala.concurrent.util._ +import duration._ +import scala.reflect._ +import java.util.concurrent.TimeUnit._ +import scala.tools.partest.TestUtil.intercept + +object Test extends App { + + implicit class Assert(val left: Any) extends AnyVal { + import Duration.Undefined + def mustBe(right: Any) = right match { + case r: Double if r.isNaN => assert(left.asInstanceOf[Double].isNaN, s"$left was not NaN") + case r: Double if r == 0 && r.compareTo(0) == -1 => assert(left == 0 && left.asInstanceOf[Double].compareTo(0) == -1, s"$left was not -0.0") + case Undefined => assert(left.asInstanceOf[AnyRef] eq Undefined, s"$left was not Undefined") + case _ => assert(left == right, s"$left was not equal to $right") + } + } + + val zero = 0 seconds + val one = 1 second + val two = one + one + val three = 3 * one + val inf = Duration.Inf + val minf = Duration.MinusInf + val undef = Duration.Undefined + val inputs = List(zero, one, inf, minf, undef) + val nan = Double.NaN + + // test field ops + one.isFinite mustBe true + 0 * one mustBe zero + 2 * one mustBe two + three - two mustBe one + three / 3 mustBe one + two / one mustBe 2 + one + zero mustBe one + one / 1000000 mustBe 1.micro + + + // test infinities + + inf.isFinite mustBe false + minf.isFinite mustBe false + + inf mustBe inf + minf mustBe minf + -inf mustBe minf + -minf mustBe inf + + minf + inf mustBe undef + inf - inf mustBe undef + inf + minf mustBe undef + minf - minf mustBe undef + + inf + inf mustBe inf + inf - minf mustBe inf + minf - inf mustBe minf + minf + minf mustBe minf + + inf.compareTo(inf) mustBe 0 + inf.compareTo(one) mustBe 1 + inf.compareTo(minf) mustBe 1 + minf.compareTo(minf) mustBe 0 + minf.compareTo(one) mustBe -1 + minf.compareTo(inf) mustBe -1 + + assert(inf != minf) + assert(minf != inf) + assert(one != inf) + assert(minf != one) + + inf mustBe (minf * -1d) + inf mustBe (minf / -1d) + + one / inf mustBe 0d + -one / inf mustBe -0d + one / minf mustBe -0d + -one / minf mustBe 0d + + inputs filterNot (_.isFinite) foreach (x => x / zero mustBe x.toUnit(DAYS)) + inputs filterNot (_.isFinite) foreach (_ * 0d mustBe undef) + inputs filterNot (_.isFinite) foreach (_ * -0d mustBe undef) + inputs filterNot (_.isFinite) foreach (x => x * Double.PositiveInfinity mustBe x) + inputs filterNot (_.isFinite) foreach (x => x * Double.NegativeInfinity mustBe -x) + + inf.toUnit(SECONDS) mustBe Double.PositiveInfinity + minf.toUnit(MINUTES) mustBe Double.NegativeInfinity + Duration.fromNanos(Double.PositiveInfinity) mustBe inf + Duration.fromNanos(Double.NegativeInfinity) mustBe minf + + + // test undefined & NaN + + undef.isFinite mustBe false + -undef mustBe undef + assert(undef != undef) + assert(undef eq undef) + + inputs foreach (_ + undef mustBe undef) + inputs foreach (_ - undef mustBe undef) + inputs foreach (_ / undef mustBe nan) + inputs foreach (_ / nan mustBe undef) + inputs foreach (_ * nan mustBe undef) + inputs foreach (undef + _ mustBe undef) + inputs foreach (undef - _ mustBe undef) + inputs foreach (undef / _ mustBe nan) + undef / 1 mustBe undef + undef / nan mustBe undef + undef * 1 mustBe undef + undef * nan mustBe undef + inputs foreach (x => x / zero mustBe x.toUnit(SECONDS) / 0d) + inputs foreach (x => x / 0d mustBe Duration.fromNanos(x.toUnit(NANOSECONDS) / 0d)) + inputs foreach (x => x / -0d mustBe Duration.fromNanos(x.toUnit(NANOSECONDS) / -0d)) + + inputs filterNot (_ eq undef) foreach (_ compareTo undef mustBe -1) + inputs filterNot (_ eq undef) foreach (undef compareTo _ mustBe 1) + undef compare undef mustBe 0 + + undef.toUnit(DAYS) mustBe nan + Duration.fromNanos(nan) mustBe undef + + + // test overflow protection + for (unit ← Seq(DAYS, HOURS, MINUTES, SECONDS, MILLISECONDS, MICROSECONDS, NANOSECONDS)) { + val x = unit.convert(Long.MaxValue, NANOSECONDS) + val dur = Duration(x, unit) + val mdur = Duration(-x, unit) + -mdur mustBe (dur) + intercept[IllegalArgumentException] { Duration(x + 10000000d, unit) } + intercept[IllegalArgumentException] { Duration(-x - 10000000d, unit) } + if (unit != NANOSECONDS) { + intercept[IllegalArgumentException] { Duration(x + 1, unit) } + intercept[IllegalArgumentException] { Duration(-x - 1, unit) } + } + intercept[IllegalArgumentException] { dur + 1.day } + intercept[IllegalArgumentException] { mdur - 1.day } + intercept[IllegalArgumentException] { dur * 1.1 } + intercept[IllegalArgumentException] { mdur * 1.1 } + intercept[IllegalArgumentException] { dur * 2.1 } + intercept[IllegalArgumentException] { mdur * 2.1 } + intercept[IllegalArgumentException] { dur / 0.9 } + intercept[IllegalArgumentException] { mdur / 0.9 } + intercept[IllegalArgumentException] { dur / 0.4 } + intercept[IllegalArgumentException] { mdur / 0.4 } + Duration(x + unit.toString.toLowerCase) + Duration("-" + x + unit.toString.toLowerCase) + intercept[IllegalArgumentException] { Duration("%.0f".format(x + 10000000d) + unit.toString.toLowerCase) } + intercept[IllegalArgumentException] { Duration("-%.0f".format(x + 10000000d) + unit.toString.toLowerCase) } + } + intercept[IllegalArgumentException] { Duration.fromNanos(1e20) } + intercept[IllegalArgumentException] { Duration.fromNanos(-1e20) } + + + // test precision + 1.second + 1.millisecond mustBe 1001.milliseconds + 100000.days + 1.nanosecond mustBe 8640000000000000001L.nanoseconds + 1.5.seconds.toSeconds mustBe 1 + (-1.5).seconds.toSeconds mustBe -1 + + + // test unit stability + 1000.millis.unit mustBe MILLISECONDS + (1000.millis + 0.days).unit mustBe MILLISECONDS + 1.second.unit mustBe SECONDS + (1.second + 1.millisecond).unit mustBe MILLISECONDS + + + // test Deadline + val dead = 2.seconds.fromNow + val dead2 = 2 seconds fromNow + assert(dead.timeLeft > 1.second) + assert(dead2.timeLeft > 1.second) + Thread.sleep(1.second.toMillis) + assert(dead.timeLeft < 1.second) + assert(dead2.timeLeft < 1.second) + + + // check statically retaining finite-ness + val finiteDuration: FiniteDuration = 1.second plus 3.seconds minus 1.millisecond min 1.second max 1.second + + +} diff --git a/test/files/jvm/scala-concurrent-tck.scala b/test/files/jvm/scala-concurrent-tck.scala index ffb5608fd2..0e76b711de 100644 --- a/test/files/jvm/scala-concurrent-tck.scala +++ b/test/files/jvm/scala-concurrent-tck.scala @@ -11,6 +11,8 @@ import scala.concurrent.{ import scala.concurrent.{ future, promise, blocking } import scala.util.{ Try, Success, Failure } import scala.concurrent.util.Duration +import scala.reflect.{ classTag, ClassTag } +import scala.tools.partest.TestUtil.intercept trait TestBase { @@ -19,7 +21,7 @@ trait TestBase { body(() => sv put true) sv.take(2000) } - + // def assert(cond: => Boolean) { // try { // Predef.assert(cond) @@ -663,6 +665,29 @@ trait FutureProjections extends TestBase { case nsee: NoSuchElementException => done() } } + + def testAwaitPositiveDuration(): Unit = once { done => + val p = Promise[Int]() + val f = p.future + future { + intercept[IllegalArgumentException] { Await.ready(f, Duration.Undefined) } + p.success(0) + Await.ready(f, Duration.Zero) + Await.ready(f, Duration(500, "ms")) + Await.ready(f, Duration.Inf) + done() + } onFailure { case x => throw x } + } + + def testAwaitNegativeDuration(): Unit = once { done => + val f = Promise().future + future { + intercept[TimeoutException] { Await.ready(f, Duration.Zero) } + intercept[TimeoutException] { Await.ready(f, Duration.MinusInf) } + intercept[TimeoutException] { Await.ready(f, Duration(-500, "ms")) } + done() + } onFailure { case x => throw x } + } testFailedFailureOnComplete() testFailedFailureOnSuccess() @@ -670,6 +695,8 @@ trait FutureProjections extends TestBase { testFailedSuccessOnFailure() testFailedFailureAwait() testFailedSuccessAwait() + testAwaitPositiveDuration() + testAwaitNegativeDuration() } diff --git a/test/files/neg/deadline-inf-illegal.check b/test/files/neg/deadline-inf-illegal.check new file mode 100644 index 0000000000..2b9b25e48e --- /dev/null +++ b/test/files/neg/deadline-inf-illegal.check @@ -0,0 +1,15 @@ +deadline-inf-illegal.scala:5: error: value fromNow is not a member of scala.concurrent.util.Duration + d.fromNow + ^ +deadline-inf-illegal.scala:6: error: type mismatch; + found : scala.concurrent.util.Duration + required: scala.concurrent.util.FiniteDuration + Deadline.now + d + ^ +deadline-inf-illegal.scala:7: error: overloaded method value - with alternatives: + (other: scala.concurrent.util.Deadline)scala.concurrent.util.FiniteDuration <and> + (other: scala.concurrent.util.FiniteDuration)scala.concurrent.util.Deadline + cannot be applied to (scala.concurrent.util.Duration) + Deadline.now - d + ^ +three errors found diff --git a/test/files/neg/deadline-inf-illegal.scala b/test/files/neg/deadline-inf-illegal.scala new file mode 100644 index 0000000000..161089bfee --- /dev/null +++ b/test/files/neg/deadline-inf-illegal.scala @@ -0,0 +1,8 @@ +import concurrent.util.{ Deadline, Duration } + +class T { + val d: Duration = Duration.Zero + d.fromNow + Deadline.now + d + Deadline.now - d +} diff --git a/test/files/neg/interop_abstypetags_arenot_classmanifests.scala b/test/files/neg/interop_abstypetags_arenot_classmanifests.scala index c8567be5d4..5d88c90ffd 100644 --- a/test/files/neg/interop_abstypetags_arenot_classmanifests.scala +++ b/test/files/neg/interop_abstypetags_arenot_classmanifests.scala @@ -1,11 +1,11 @@ import scala.reflect.runtime.universe._ object Test extends App { - def absTypeTagIsnotClassManifest[T: AbsTypeTag] = { + def weakTypeTagIsnotClassManifest[T: WeakTypeTag] = { println(classManifest[T]) } - absTypeTagIsnotClassManifest[Int] - absTypeTagIsnotClassManifest[String] - absTypeTagIsnotClassManifest[Array[Int]] + weakTypeTagIsnotClassManifest[Int] + weakTypeTagIsnotClassManifest[String] + weakTypeTagIsnotClassManifest[Array[Int]] }
\ No newline at end of file diff --git a/test/files/neg/interop_abstypetags_arenot_classtags.scala b/test/files/neg/interop_abstypetags_arenot_classtags.scala index e3911c1588..de1f8657b6 100644 --- a/test/files/neg/interop_abstypetags_arenot_classtags.scala +++ b/test/files/neg/interop_abstypetags_arenot_classtags.scala @@ -2,11 +2,11 @@ import scala.reflect.runtime.universe._ import scala.reflect.{ClassTag, classTag} object Test extends App { - def absTypeTagIsnotClassTag[T: AbsTypeTag] = { + def weakTypeTagIsnotClassTag[T: WeakTypeTag] = { println(classTag[T]) } - absTypeTagIsnotClassTag[Int] - absTypeTagIsnotClassTag[String] - absTypeTagIsnotClassTag[Array[Int]] + weakTypeTagIsnotClassTag[Int] + weakTypeTagIsnotClassTag[String] + weakTypeTagIsnotClassTag[Array[Int]] }
\ No newline at end of file diff --git a/test/files/neg/interop_abstypetags_arenot_manifests.scala b/test/files/neg/interop_abstypetags_arenot_manifests.scala index 77a95048fd..1ca3673ce4 100644 --- a/test/files/neg/interop_abstypetags_arenot_manifests.scala +++ b/test/files/neg/interop_abstypetags_arenot_manifests.scala @@ -1,11 +1,11 @@ import scala.reflect.runtime.universe._ object Test extends App { - def absTypeTagIsnotManifest[T: AbsTypeTag] = { + def weakTypeTagIsnotManifest[T: WeakTypeTag] = { println(manifest[T]) } - absTypeTagIsnotManifest[Int] - absTypeTagIsnotManifest[String] - absTypeTagIsnotManifest[Array[Int]] + weakTypeTagIsnotManifest[Int] + weakTypeTagIsnotManifest[String] + weakTypeTagIsnotManifest[Array[Int]] }
\ No newline at end of file diff --git a/test/files/neg/macro-invalidsig-context-bounds.check b/test/files/neg/macro-invalidsig-context-bounds.check index 5d42ebc515..eb5d833bc0 100644 --- a/test/files/neg/macro-invalidsig-context-bounds.check +++ b/test/files/neg/macro-invalidsig-context-bounds.check @@ -1,7 +1,7 @@ Macros_Test_1.scala:2: error: macro implementation has wrong shape:
required: (c: scala.reflect.macros.Context): c.Expr[Any]
found : (c: scala.reflect.macros.Context)(implicit evidence$2: Numeric[U]): c.universe.Literal
-macro implementations cannot have implicit parameters other than AbsTypeTag evidences
+macro implementations cannot have implicit parameters other than WeakTypeTag evidences
def foo[U] = macro Impls.foo[U]
^
one error found
diff --git a/test/files/neg/macro-invalidsig-context-bounds/Impls_1.scala b/test/files/neg/macro-invalidsig-context-bounds/Impls_1.scala index 5aa9a7eaf9..c066c485b1 100644 --- a/test/files/neg/macro-invalidsig-context-bounds/Impls_1.scala +++ b/test/files/neg/macro-invalidsig-context-bounds/Impls_1.scala @@ -2,7 +2,7 @@ import scala.reflect.runtime.universe._ import scala.reflect.macros.{Context => Ctx} object Impls { - def foo[U: c.AbsTypeTag: Numeric](c: Ctx) = { + def foo[U: c.WeakTypeTag: Numeric](c: Ctx) = { import c.universe._ Literal(Constant(42)) } diff --git a/test/files/neg/macro-invalidsig-implicit-params.check b/test/files/neg/macro-invalidsig-implicit-params.check index 62156770e4..ca35e62cd7 100644 --- a/test/files/neg/macro-invalidsig-implicit-params.check +++ b/test/files/neg/macro-invalidsig-implicit-params.check @@ -1,7 +1,7 @@ Impls_Macros_1.scala:18: error: macro implementation has wrong shape:
required: (c: scala.reflect.macros.Context)(x: c.Expr[Int]): c.Expr[Unit]
found : (c: scala.reflect.macros.Context)(implicit x: c.Expr[Int]): c.Expr[Unit]
-macro implementations cannot have implicit parameters other than AbsTypeTag evidences
+macro implementations cannot have implicit parameters other than WeakTypeTag evidences
def foo_targs[U](x: Int) = macro Impls.foo_targs[T, U]
^
one error found
diff --git a/test/files/neg/macro-invalidsig-implicit-params/Impls_Macros_1.scala b/test/files/neg/macro-invalidsig-implicit-params/Impls_Macros_1.scala index f724538993..845a168ff2 100644 --- a/test/files/neg/macro-invalidsig-implicit-params/Impls_Macros_1.scala +++ b/test/files/neg/macro-invalidsig-implicit-params/Impls_Macros_1.scala @@ -2,13 +2,13 @@ import scala.reflect.runtime.universe._ import scala.reflect.macros.{Context => Ctx} object Impls { - def foo_targs[T, U: c.AbsTypeTag](c: Ctx)(implicit x: c.Expr[Int]) = { + def foo_targs[T, U: c.WeakTypeTag](c: Ctx)(implicit x: c.Expr[Int]) = { import c.{prefix => prefix} import c.universe._ val body = Block( Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("invoking foo_targs...")))), Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("type of prefix is: " + prefix.staticType)))), - Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("U is: " + implicitly[c.AbsTypeTag[U]].tpe)))), + Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("U is: " + implicitly[c.WeakTypeTag[U]].tpe)))), Literal(Constant(()))) c.Expr[Unit](body) } diff --git a/test/files/neg/macro-invalidsig-tparams-notparams-a.check b/test/files/neg/macro-invalidsig-tparams-notparams-a.check index 5aee62b9e5..5404c185f3 100644 --- a/test/files/neg/macro-invalidsig-tparams-notparams-a.check +++ b/test/files/neg/macro-invalidsig-tparams-notparams-a.check @@ -1,4 +1,4 @@ -Macros_Test_2.scala:2: error: wrong number of type parameters for method foo: [U](c: scala.reflect.macros.Context)(implicit evidence$1: c.AbsTypeTag[U])Nothing
+Macros_Test_2.scala:2: error: wrong number of type parameters for method foo: [U](c: scala.reflect.macros.Context)(implicit evidence$1: c.WeakTypeTag[U])Nothing
def foo = macro Impls.foo
^
one error found
diff --git a/test/files/neg/macro-invalidsig-tparams-notparams-a/Impls_1.scala b/test/files/neg/macro-invalidsig-tparams-notparams-a/Impls_1.scala index afbe0f0915..f8b3c92869 100644 --- a/test/files/neg/macro-invalidsig-tparams-notparams-a/Impls_1.scala +++ b/test/files/neg/macro-invalidsig-tparams-notparams-a/Impls_1.scala @@ -2,5 +2,5 @@ import scala.reflect.runtime.universe._ import scala.reflect.macros.{Context => Ctx} object Impls { - def foo[U: c.AbsTypeTag](c: Ctx) = ??? + def foo[U: c.WeakTypeTag](c: Ctx) = ??? }
\ No newline at end of file diff --git a/test/files/neg/macro-invalidsig-tparams-notparams-b.check b/test/files/neg/macro-invalidsig-tparams-notparams-b.check index e8de8a4c6b..485d4de96e 100644 --- a/test/files/neg/macro-invalidsig-tparams-notparams-b.check +++ b/test/files/neg/macro-invalidsig-tparams-notparams-b.check @@ -1,4 +1,4 @@ -Macros_Test_2.scala:3: error: wrong number of type parameters for method foo: [T, U, V](c: scala.reflect.macros.Context)(implicit evidence$1: c.AbsTypeTag[T], implicit evidence$2: c.AbsTypeTag[U], implicit V: c.AbsTypeTag[V])c.Expr[Unit]
+Macros_Test_2.scala:3: error: wrong number of type parameters for method foo: [T, U, V](c: scala.reflect.macros.Context)(implicit evidence$1: c.WeakTypeTag[T], implicit evidence$2: c.WeakTypeTag[U], implicit V: c.WeakTypeTag[V])c.Expr[Unit]
def foo[V] = macro Impls.foo
^
one error found
diff --git a/test/files/neg/macro-invalidsig-tparams-notparams-b/Impls_1.scala b/test/files/neg/macro-invalidsig-tparams-notparams-b/Impls_1.scala index b48f9d5f98..baf3aab9e3 100644 --- a/test/files/neg/macro-invalidsig-tparams-notparams-b/Impls_1.scala +++ b/test/files/neg/macro-invalidsig-tparams-notparams-b/Impls_1.scala @@ -2,9 +2,9 @@ import scala.reflect.runtime.universe._ import scala.reflect.macros.{Context => Ctx} object Impls { - def foo[T: c.AbsTypeTag, U: c.AbsTypeTag, V](c: Ctx)(implicit V: c.AbsTypeTag[V]): c.Expr[Unit] = { - println(implicitly[c.AbsTypeTag[T]]) - println(implicitly[c.AbsTypeTag[U]]) + def foo[T: c.WeakTypeTag, U: c.WeakTypeTag, V](c: Ctx)(implicit V: c.WeakTypeTag[V]): c.Expr[Unit] = { + println(implicitly[c.WeakTypeTag[T]]) + println(implicitly[c.WeakTypeTag[U]]) println(V) c.literalUnit } diff --git a/test/files/neg/macro-invalidsig-tparams-notparams-c.check b/test/files/neg/macro-invalidsig-tparams-notparams-c.check index b1078fb233..1530c35097 100644 --- a/test/files/neg/macro-invalidsig-tparams-notparams-c.check +++ b/test/files/neg/macro-invalidsig-tparams-notparams-c.check @@ -1,4 +1,4 @@ -Macros_Test_2.scala:3: error: wrong number of type parameters for method foo: [T, U, V](c: scala.reflect.macros.Context)(implicit evidence$1: c.AbsTypeTag[T], implicit evidence$2: c.AbsTypeTag[U], implicit V: c.AbsTypeTag[V])c.Expr[Unit]
+Macros_Test_2.scala:3: error: wrong number of type parameters for method foo: [T, U, V](c: scala.reflect.macros.Context)(implicit evidence$1: c.WeakTypeTag[T], implicit evidence$2: c.WeakTypeTag[U], implicit V: c.WeakTypeTag[V])c.Expr[Unit]
def foo[V] = macro Impls.foo[V]
^
one error found
diff --git a/test/files/neg/macro-invalidsig-tparams-notparams-c/Impls_1.scala b/test/files/neg/macro-invalidsig-tparams-notparams-c/Impls_1.scala index 3506bdc789..44b4ed6ab3 100644 --- a/test/files/neg/macro-invalidsig-tparams-notparams-c/Impls_1.scala +++ b/test/files/neg/macro-invalidsig-tparams-notparams-c/Impls_1.scala @@ -2,10 +2,10 @@ import scala.reflect.runtime.universe._ import scala.reflect.macros.{Context => Ctx} object Impls { - def foo[T: c.AbsTypeTag, U: c.AbsTypeTag, V](c: Ctx)(implicit V: c.AbsTypeTag[V]): c.Expr[Unit] = { + def foo[T: c.WeakTypeTag, U: c.WeakTypeTag, V](c: Ctx)(implicit V: c.WeakTypeTag[V]): c.Expr[Unit] = { import c.universe._ - println(implicitly[c.AbsTypeTag[T]]) - println(implicitly[c.AbsTypeTag[U]]) + println(implicitly[c.WeakTypeTag[T]]) + println(implicitly[c.WeakTypeTag[U]]) println(V) c.literalUnit } diff --git a/test/files/neg/macro-reify-typetag-useabstypetag/Test.scala b/test/files/neg/macro-reify-typetag-useabstypetag/Test.scala index b66ad6c523..1e7fcb3f45 100644 --- a/test/files/neg/macro-reify-typetag-useabstypetag/Test.scala +++ b/test/files/neg/macro-reify-typetag-useabstypetag/Test.scala @@ -1,7 +1,7 @@ import scala.reflect.runtime.universe._ object Test extends App { - def fooTypeTag[T: AbsTypeTag] = { + def fooTypeTag[T: WeakTypeTag] = { println(implicitly[TypeTag[T]]) println(implicitly[TypeTag[List[T]]]) } diff --git a/test/files/neg/macro-without-xmacros-a.check b/test/files/neg/macro-without-xmacros-a.check index fd2667dbb8..ae6c6c695a 100644 --- a/test/files/neg/macro-without-xmacros-a.check +++ b/test/files/neg/macro-without-xmacros-a.check @@ -1,17 +1,17 @@ -Macros_2.scala:5: error: macro definition needs to be enabled
-by making the implicit value language.experimental.macros visible.
-This can be achieved by adding the import clause 'import language.experimental.macros'
-or by setting the compiler option -language:experimental.macros.
-See the Scala docs for value scala.language.experimental.macros for a discussion
-why the feature needs to be explicitly enabled.
- def foo(x: Int): Int = macro foo_impl
- ^
-Macros_2.scala:7: error: macro definition needs to be enabled
-by making the implicit value language.experimental.macros visible.
- def bar(x: Int): Int = macro bar_impl
- ^
-Macros_2.scala:11: error: macro definition needs to be enabled
-by making the implicit value language.experimental.macros visible.
- def quux(x: Int): Int = macro quux_impl
- ^
-three errors found
+Macros_2.scala:5: error: macro definition needs to be enabled +by making the implicit value language.experimental.macros visible. +This can be achieved by adding the import clause 'import scala.language.experimental.macros' +or by setting the compiler option -language:experimental.macros. +See the Scala docs for value scala.language.experimental.macros for a discussion +why the feature needs to be explicitly enabled. + def foo(x: Int): Int = macro foo_impl + ^ +Macros_2.scala:7: error: macro definition needs to be enabled +by making the implicit value language.experimental.macros visible. + def bar(x: Int): Int = macro bar_impl + ^ +Macros_2.scala:11: error: macro definition needs to be enabled +by making the implicit value language.experimental.macros visible. + def quux(x: Int): Int = macro quux_impl + ^ +three errors found diff --git a/test/files/neg/macro-without-xmacros-b.check b/test/files/neg/macro-without-xmacros-b.check index 2d675b8319..c3cadcf36a 100644 --- a/test/files/neg/macro-without-xmacros-b.check +++ b/test/files/neg/macro-without-xmacros-b.check @@ -1,17 +1,17 @@ -Macros_2.scala:3: error: macro definition needs to be enabled
-by making the implicit value language.experimental.macros visible.
-This can be achieved by adding the import clause 'import language.experimental.macros'
-or by setting the compiler option -language:experimental.macros.
-See the Scala docs for value scala.language.experimental.macros for a discussion
-why the feature needs to be explicitly enabled.
- def foo(x: Int): Int = macro Impls.foo_impl
- ^
-Macros_2.scala:5: error: macro definition needs to be enabled
-by making the implicit value language.experimental.macros visible.
- def bar(x: Int): Int = macro Impls.bar_impl
- ^
-Macros_2.scala:9: error: macro definition needs to be enabled
-by making the implicit value language.experimental.macros visible.
- def quux(x: Int): Int = macro Impls.quux_impl
- ^
-three errors found
+Macros_2.scala:3: error: macro definition needs to be enabled +by making the implicit value language.experimental.macros visible. +This can be achieved by adding the import clause 'import scala.language.experimental.macros' +or by setting the compiler option -language:experimental.macros. +See the Scala docs for value scala.language.experimental.macros for a discussion +why the feature needs to be explicitly enabled. + def foo(x: Int): Int = macro Impls.foo_impl + ^ +Macros_2.scala:5: error: macro definition needs to be enabled +by making the implicit value language.experimental.macros visible. + def bar(x: Int): Int = macro Impls.bar_impl + ^ +Macros_2.scala:9: error: macro definition needs to be enabled +by making the implicit value language.experimental.macros visible. + def quux(x: Int): Int = macro Impls.quux_impl + ^ +three errors found diff --git a/test/files/neg/names-defaults-neg.check b/test/files/neg/names-defaults-neg.check index 2809350855..f3c45a6aa0 100644 --- a/test/files/neg/names-defaults-neg.check +++ b/test/files/neg/names-defaults-neg.check @@ -76,7 +76,7 @@ and method f in object t8 of type (a: Int, b: Object)String match argument types (a: Int,b: String) and expected result type Any println(t8.f(a = 0, b = "1")) // ambigous reference ^ -names-defaults-neg.scala:69: error: wrong number of arguments for <none>: (x: Int, y: String)A1 +names-defaults-neg.scala:69: error: wrong number of arguments for pattern A1(x: Int,y: String) A1() match { case A1(_) => () } ^ names-defaults-neg.scala:76: error: no type parameters for method test4: (x: T[T[List[T[X forSome { type X }]]]])T[T[List[T[X forSome { type X }]]]] exist so that it can be applied to arguments (List[Int]) diff --git a/test/files/neg/no-implicit-to-anyref.check b/test/files/neg/no-implicit-to-anyref.check new file mode 100644 index 0000000000..d94b57a30a --- /dev/null +++ b/test/files/neg/no-implicit-to-anyref.check @@ -0,0 +1,28 @@ +no-implicit-to-anyref.scala:11: error: type mismatch; + found : Int(1) + required: AnyRef +Note: an implicit exists from scala.Int => java.lang.Integer, but +methods inherited from Object are rendered ambiguous. This is to avoid +a blanket implicit which would convert any scala.Int to any AnyRef. +You may wish to use a type ascription: `x: java.lang.Integer`. + 1: AnyRef + ^ +no-implicit-to-anyref.scala:17: error: type mismatch; + found : Any + required: AnyRef + (null: Any): AnyRef + ^ +no-implicit-to-anyref.scala:21: error: type mismatch; + found : AnyVal + required: AnyRef + (0: AnyVal): AnyRef + ^ +no-implicit-to-anyref.scala:27: error: type mismatch; + found : Test.AV + required: AnyRef +Note that AV extends Any, not AnyRef. +Such types can participate in value classes, but instances +cannot appear in singleton types or in reference comparisons. + new AV(0): AnyRef + ^ +four errors found diff --git a/test/files/neg/no-implicit-to-anyref.scala b/test/files/neg/no-implicit-to-anyref.scala new file mode 100644 index 0000000000..3e3d373e38 --- /dev/null +++ b/test/files/neg/no-implicit-to-anyref.scala @@ -0,0 +1,29 @@ +// Checks that the state of standard implicits in Predef._ and scala._ +// doesn't allow us to unambiguously and implicitly convert AnyVal +// and subtypes to AnyRef. +// +// In the days before value classes, this was precariously held be +// the competing implicits Any => StringAdd and Any => StringFormat. +// Since then, these have both become value classes, but seeing as +// this happened simultaneously, we're still okay. +object Test { + locally { + 1: AnyRef + } + + locally { + // before this test case was added and ContextErrors was tweaked, this + // emitted: "Note that Any extends Any, not AnyRef." + (null: Any): AnyRef + } + + locally { + (0: AnyVal): AnyRef + } + + class AV(val a: Int) extends AnyVal + + locally { + new AV(0): AnyRef + } +} diff --git a/test/files/neg/override.check b/test/files/neg/override.check index fc152cb3b1..8be98bf4d0 100644 --- a/test/files/neg/override.check +++ b/test/files/neg/override.check @@ -1,5 +1,5 @@ override.scala:9: error: overriding type T in trait A with bounds >: Int <: Int; type T in trait B with bounds >: String <: String has incompatible type - lazy val x : A with B = x + lazy val x : A with B = {println(""); x} ^ one error found diff --git a/test/files/neg/override.scala b/test/files/neg/override.scala index 3e589b52e3..7975516061 100755 --- a/test/files/neg/override.scala +++ b/test/files/neg/override.scala @@ -6,7 +6,7 @@ trait X { trait Y extends X { trait B { type T >: String <: String } - lazy val x : A with B = x + lazy val x : A with B = {println(""); x} n = "foo" } diff --git a/test/files/neg/reify_ann2b.scala b/test/files/neg/reify_ann2b.scala index 2076af34c8..72d8c611cb 100644 --- a/test/files/neg/reify_ann2b.scala +++ b/test/files/neg/reify_ann2b.scala @@ -24,5 +24,5 @@ object Test extends App { println(ttree.toString) // test 3: import and compile - toolbox.runExpr(tree) + toolbox.eval(tree) }
\ No newline at end of file diff --git a/test/files/neg/reify_metalevel_breach_+0_refers_to_1.scala b/test/files/neg/reify_metalevel_breach_+0_refers_to_1.scala index 9499960480..e4d1edffc4 100644 --- a/test/files/neg/reify_metalevel_breach_+0_refers_to_1.scala +++ b/test/files/neg/reify_metalevel_breach_+0_refers_to_1.scala @@ -11,6 +11,6 @@ object Test extends App { }; val toolbox = cm.mkToolBox() - val evaluated = toolbox.runExpr(code.tree) + val evaluated = toolbox.eval(code.tree) println("evaluated = " + evaluated) }
\ No newline at end of file diff --git a/test/files/neg/reify_metalevel_breach_-1_refers_to_0_a.scala b/test/files/neg/reify_metalevel_breach_-1_refers_to_0_a.scala index e6aaeb9426..7397441586 100644 --- a/test/files/neg/reify_metalevel_breach_-1_refers_to_0_a.scala +++ b/test/files/neg/reify_metalevel_breach_-1_refers_to_0_a.scala @@ -9,6 +9,6 @@ object Test extends App { val code = reify{outer.splice.splice} val toolbox = cm.mkToolBox() - val evaluated = toolbox.runExpr(code.tree) + val evaluated = toolbox.eval(code.tree) println("evaluated = " + evaluated) }
\ No newline at end of file diff --git a/test/files/neg/reify_metalevel_breach_-1_refers_to_0_b.scala b/test/files/neg/reify_metalevel_breach_-1_refers_to_0_b.scala index 16dcae8683..4f27a44f0c 100644 --- a/test/files/neg/reify_metalevel_breach_-1_refers_to_0_b.scala +++ b/test/files/neg/reify_metalevel_breach_-1_refers_to_0_b.scala @@ -13,6 +13,6 @@ object Test extends App { } val toolbox = cm.mkToolBox() - val evaluated = toolbox.runExpr(code.tree) + val evaluated = toolbox.eval(code.tree) println("evaluated = " + evaluated) }
\ No newline at end of file diff --git a/test/files/neg/reify_metalevel_breach_-1_refers_to_1.scala b/test/files/neg/reify_metalevel_breach_-1_refers_to_1.scala index 9600489f35..2f637301aa 100644 --- a/test/files/neg/reify_metalevel_breach_-1_refers_to_1.scala +++ b/test/files/neg/reify_metalevel_breach_-1_refers_to_1.scala @@ -11,6 +11,6 @@ object Test extends App { }; val toolbox = cm.mkToolBox() - val evaluated = toolbox.runExpr(code.tree) + val evaluated = toolbox.eval(code.tree) println("evaluated = " + evaluated) }
\ No newline at end of file diff --git a/test/files/neg/reify_nested_inner_refers_to_local.scala b/test/files/neg/reify_nested_inner_refers_to_local.scala index fcbc1f7865..75ed1bf330 100644 --- a/test/files/neg/reify_nested_inner_refers_to_local.scala +++ b/test/files/neg/reify_nested_inner_refers_to_local.scala @@ -10,6 +10,6 @@ object Test extends App { }; val toolbox = cm.mkToolBox() - val evaluated = toolbox.runExpr(code.tree) + val evaluated = toolbox.eval(code.tree) println("evaluated = " + evaluated) }
\ No newline at end of file diff --git a/test/files/neg/t2296a.check b/test/files/neg/t2296a.check new file mode 100644 index 0000000000..863b861046 --- /dev/null +++ b/test/files/neg/t2296a.check @@ -0,0 +1,5 @@ +S.scala:6: error: Implementation restriction: trait S accesses protected method foo inside a concrete trait method. +Add an accessor in a class extending class J as a workaround. + foo() + ^ +one error found diff --git a/test/files/run/t2296a/J.java b/test/files/neg/t2296a/J.java index 78ff3e9804..78ff3e9804 100644 --- a/test/files/run/t2296a/J.java +++ b/test/files/neg/t2296a/J.java diff --git a/test/files/run/t2296a/S.scala b/test/files/neg/t2296a/S.scala index 532d038a42..532d038a42 100644 --- a/test/files/run/t2296a/S.scala +++ b/test/files/neg/t2296a/S.scala diff --git a/test/files/neg/t2296b.check b/test/files/neg/t2296b.check new file mode 100644 index 0000000000..07cc54d573 --- /dev/null +++ b/test/files/neg/t2296b.check @@ -0,0 +1,5 @@ +S_2.scala:6: error: Implementation restriction: trait S accesses protected method foo inside a concrete trait method. +Add an accessor in a class extending class J_1 as a workaround. + foo() + ^ +one error found diff --git a/test/files/run/t2296b/J_1.java b/test/files/neg/t2296b/J_1.java index 4c91d47073..4c91d47073 100644 --- a/test/files/run/t2296b/J_1.java +++ b/test/files/neg/t2296b/J_1.java diff --git a/test/files/run/t2296b/S_2.scala b/test/files/neg/t2296b/S_2.scala index 6cdb0cfaba..6cdb0cfaba 100644 --- a/test/files/run/t2296b/S_2.scala +++ b/test/files/neg/t2296b/S_2.scala diff --git a/test/files/neg/t6040.check b/test/files/neg/t6040.check index f44a81c471..f6757f97e3 100644 --- a/test/files/neg/t6040.check +++ b/test/files/neg/t6040.check @@ -1,6 +1,6 @@ error: extension of type scala.Dynamic needs to be enabled by making the implicit value language.dynamics visible. -This can be achieved by adding the import clause 'import language.dynamics' +This can be achieved by adding the import clause 'import scala.language.dynamics' or by setting the compiler option -language:dynamics. See the Scala docs for value scala.language.dynamics for a discussion why the feature needs to be explicitly enabled. diff --git a/test/files/neg/t6162-inheritance.check b/test/files/neg/t6162-inheritance.check new file mode 100644 index 0000000000..a7d3cc3238 --- /dev/null +++ b/test/files/neg/t6162-inheritance.check @@ -0,0 +1,10 @@ +t6162-inheritance.scala:6: error: inheritance from class Foo in package t6126 is deprecated: `Foo` will be made final in a future version. +class SubFoo extends Foo + ^ +t6162-inheritance.scala:11: error: inheritance from trait T in package t6126 is deprecated +object SubT extends T + ^ +t6162-inheritance.scala:17: error: inheritance from trait S in package t6126 is deprecated + new S { + ^ +three errors found diff --git a/test/files/neg/t6162-inheritance.flags b/test/files/neg/t6162-inheritance.flags new file mode 100644 index 0000000000..65faf53579 --- /dev/null +++ b/test/files/neg/t6162-inheritance.flags @@ -0,0 +1 @@ +-Xfatal-warnings -deprecation
\ No newline at end of file diff --git a/test/files/neg/t6162-inheritance.scala b/test/files/neg/t6162-inheritance.scala new file mode 100644 index 0000000000..7b47b9285a --- /dev/null +++ b/test/files/neg/t6162-inheritance.scala @@ -0,0 +1,19 @@ +package scala.t6126 + +@deprecatedInheritance("`Foo` will be made final in a future version.", "2.10.0") +class Foo + +class SubFoo extends Foo + +@deprecatedInheritance() +trait T + +object SubT extends T + +@deprecatedInheritance() +trait S + +object O { + new S { + } +} diff --git a/test/files/neg/t6162-overriding.check b/test/files/neg/t6162-overriding.check new file mode 100644 index 0000000000..e774888d36 --- /dev/null +++ b/test/files/neg/t6162-overriding.check @@ -0,0 +1,7 @@ +t6162-overriding.scala:14: error: overriding method bar in class Bar is deprecated: `bar` will be made private in a future version. + override def bar = 43 + ^ +t6162-overriding.scala:15: error: overriding method baz in class Bar is deprecated + override def baz = 43 + ^ +two errors found diff --git a/test/files/neg/t6162-overriding.flags b/test/files/neg/t6162-overriding.flags new file mode 100644 index 0000000000..65faf53579 --- /dev/null +++ b/test/files/neg/t6162-overriding.flags @@ -0,0 +1 @@ +-Xfatal-warnings -deprecation
\ No newline at end of file diff --git a/test/files/neg/t6162-overriding.scala b/test/files/neg/t6162-overriding.scala new file mode 100644 index 0000000000..4cab0c2dee --- /dev/null +++ b/test/files/neg/t6162-overriding.scala @@ -0,0 +1,17 @@ +package scala.t6162 + +class Bar { + @deprecatedOverriding("`bar` will be made private in a future version.", "2.10.0") + def bar = 42 + + @deprecatedOverriding() + def baz = 42 + + def baz(a: Any) = 0 +} + +class SubBar extends Bar { + override def bar = 43 + override def baz = 43 + override def baz(a: Any) = 43 // okay +} diff --git a/test/files/neg/t6276.check b/test/files/neg/t6276.check new file mode 100644 index 0000000000..0b3dfa5531 --- /dev/null +++ b/test/files/neg/t6276.check @@ -0,0 +1,19 @@ +t6276.scala:4: error: method a in class C does nothing other than call itself recursively + def a: Any = a // warn + ^ +t6276.scala:5: error: value b in class C does nothing other than call itself recursively + val b: Any = b // warn + ^ +t6276.scala:7: error: method c in class C does nothing other than call itself recursively + def c: Any = this.c // warn + ^ +t6276.scala:8: error: method d in class C does nothing other than call itself recursively + def d: Any = C.this.d // warn + ^ +t6276.scala:13: error: method a does nothing other than call itself recursively + def a: Any = a // warn + ^ +t6276.scala:22: error: method a does nothing other than call itself recursively + def a = a // warn + ^ +6 errors found diff --git a/test/files/neg/t6276.flags b/test/files/neg/t6276.flags new file mode 100644 index 0000000000..85d8eb2ba2 --- /dev/null +++ b/test/files/neg/t6276.flags @@ -0,0 +1 @@ +-Xfatal-warnings diff --git a/test/files/neg/t6276.scala b/test/files/neg/t6276.scala new file mode 100644 index 0000000000..bd0a473f71 --- /dev/null +++ b/test/files/neg/t6276.scala @@ -0,0 +1,44 @@ +object Test { + def foo(a: Int, b: Int, c: Int) { + class C { + def a: Any = a // warn + val b: Any = b // warn + + def c: Any = this.c // warn + def d: Any = C.this.d // warn + } + + def method { + // method local + def a: Any = a // warn + } + + trait T { + def a: Any + } + + new T { + // inherited return type + def a = a // warn + } + + // no warnings below + new { + def a: Any = {println(""); a} + val b: Any = {println(""); b} + def c(i: Int): Any = c(i - 0) + } + + class D { + def other: D = null + def foo: Any = other.foo + } + + class E { + def foo: Any = 0 + class D extends E { + override def foo: Any = E.this.foo + } + } + } +} diff --git a/test/files/neg/t6323a.check b/test/files/neg/t6323a.check new file mode 100644 index 0000000000..694c79ca5f --- /dev/null +++ b/test/files/neg/t6323a.check @@ -0,0 +1,9 @@ +t6323a.scala:11: `package`.this.materializeTypeTag[Test](scala.reflect.runtime.`package`.universe) is not a valid implicit value for reflect.runtime.universe.TypeTag[Test] because:
+failed to typecheck the materialized tag:
+cannot create a TypeTag referring to local class Test.Test
+ val value = u.typeOf[Test]
+ ^
+t6323a.scala:11: error: No TypeTag available for Test
+ val value = u.typeOf[Test]
+ ^
+one error found
diff --git a/test/files/neg/t6323a.flags b/test/files/neg/t6323a.flags new file mode 100644 index 0000000000..4c6cdb71e2 --- /dev/null +++ b/test/files/neg/t6323a.flags @@ -0,0 +1 @@ +-Xlog-implicits
\ No newline at end of file diff --git a/test/files/neg/t6323a.scala b/test/files/neg/t6323a.scala new file mode 100644 index 0000000000..a203167f3c --- /dev/null +++ b/test/files/neg/t6323a.scala @@ -0,0 +1,21 @@ +import scala.reflect.runtime.universe._ +import scala.reflect.runtime.{currentMirror => m} +import scala.reflect.runtime.{universe => u} + +object Test extends App { + locally { + try { + case class Test(a:String,b:List[Int]) + + val lookAtMe = m.reflect(Test("a",List(5))) + val value = u.typeOf[Test] + val members = value.members + val member = value.members.filter(_.name.encoded == "a") + val aAccessor = lookAtMe.reflectMethod(member.head.asMethod) + val thisShouldBeA = aAccessor.apply() + println(thisShouldBeA) + } catch { + case ScalaReflectionException(msg) => println(msg) + } + } +}
\ No newline at end of file diff --git a/test/files/neg/t6335.check b/test/files/neg/t6335.check new file mode 100644 index 0000000000..1727a05eb2 --- /dev/null +++ b/test/files/neg/t6335.check @@ -0,0 +1,9 @@ +t6335.scala:6: error: method Z is defined twice + conflicting symbols both originated in file 't6335.scala' + implicit class Z[A](val i: A) { def zz = i } + ^ +t6335.scala:3: error: method X is defined twice + conflicting symbols both originated in file 't6335.scala' + implicit class X(val x: Int) { def xx = x } + ^ +two errors found diff --git a/test/files/neg/t6335.scala b/test/files/neg/t6335.scala new file mode 100644 index 0000000000..5c41e81ef5 --- /dev/null +++ b/test/files/neg/t6335.scala @@ -0,0 +1,7 @@ +object ImplicitClass { + def X(i: Int) {} + implicit class X(val x: Int) { def xx = x } + + def Z[A](i: A) {} + implicit class Z[A](val i: A) { def zz = i } +}
\ No newline at end of file diff --git a/test/files/neg/t6340.check b/test/files/neg/t6340.check new file mode 100644 index 0000000000..f18b8c3f4b --- /dev/null +++ b/test/files/neg/t6340.check @@ -0,0 +1,10 @@ +t6340.scala:11: error: value D is not a member of object Foo + import Foo.{ A, B, C, D, E, X, Y, Z } + ^ +t6340.scala:16: error: not found: type D + val d = new D + ^ +t6340.scala:17: error: not found: type W + val w = new W + ^ +three errors found diff --git a/test/files/neg/t6340.scala b/test/files/neg/t6340.scala new file mode 100644 index 0000000000..8934d5c15d --- /dev/null +++ b/test/files/neg/t6340.scala @@ -0,0 +1,21 @@ +object Foo { + class A + class B + class C + class X + class Y + class Z +} + +object Test { + import Foo.{ A, B, C, D, E, X, Y, Z } + + val a = new A + val b = new B + val c = new C + val d = new D + val w = new W + val x = new X + val y = new Y + val z = new Z +} diff --git a/test/files/neg/t6359.check b/test/files/neg/t6359.check new file mode 100644 index 0000000000..2aa1ac5035 --- /dev/null +++ b/test/files/neg/t6359.check @@ -0,0 +1,7 @@ +t6359.scala:3: error: value class may not have nested module definitions + object X + ^ +t6359.scala:4: error: value class may not have nested class definitions + class Y + ^ +two errors found diff --git a/test/files/neg/t6359.scala b/test/files/neg/t6359.scala new file mode 100644 index 0000000000..96550fd906 --- /dev/null +++ b/test/files/neg/t6359.scala @@ -0,0 +1,8 @@ +class M(val t: Int) extends AnyVal { + def lazyString = { + object X + class Y + + () => {X; new Y} + } +} diff --git a/test/files/neg/wrong-args-for-none.check b/test/files/neg/wrong-args-for-none.check new file mode 100644 index 0000000000..d3b2d572ab --- /dev/null +++ b/test/files/neg/wrong-args-for-none.check @@ -0,0 +1,4 @@ +wrong-args-for-none.scala:5: error: wrong number of arguments for pattern Test.Foo(x: Int,y: Int) + def f(x: Any) = x match { case Bar(Foo(5)) => } + ^ +one error found diff --git a/test/files/neg/wrong-args-for-none.scala b/test/files/neg/wrong-args-for-none.scala new file mode 100644 index 0000000000..1caa4782a3 --- /dev/null +++ b/test/files/neg/wrong-args-for-none.scala @@ -0,0 +1,6 @@ +object Test { + case class Foo(x: Int, y: Int) + case class Bar(x: AnyRef) + + def f(x: Any) = x match { case Bar(Foo(5)) => } +} diff --git a/test/files/pos/t4579.scala b/test/files/pos/t4579.scala index 2404b19da1..8951ec011f 100644 --- a/test/files/pos/t4579.scala +++ b/test/files/pos/t4579.scala @@ -12,11 +12,11 @@ class LispTokenizer(s: String) extends Iterator[String] { while (i < s.length() && s.charAt(i) <= ' ') i += 1 i < s.length() } - def next: String = + def next: String = if (hasNext) { val start = i if (isDelimiter(s charAt i)) i += 1 - else + else do i = i + 1 while (!isDelimiter(s charAt i)) s.substring(start, i) @@ -235,7 +235,7 @@ object LispCaseClasses extends Lisp { def string2lisp(s: String): Data = { val it = new LispTokenizer(s); - def parseExpr(token: String): Data = { + def parse(token: String): Data = { if (token == "(") parseList else if (token == ")") sys.error("unbalanced parentheses") else if ('0' <= token.charAt(0) && token.charAt(0) <= '9') @@ -246,9 +246,9 @@ object LispCaseClasses extends Lisp { } def parseList: Data = { val token = it.next; - if (token == ")") NIL() else CONS(parseExpr(token), parseList) + if (token == ")") NIL() else CONS(parse(token), parseList) } - parseExpr(it.next) + parse(it.next) } def lisp2string(d: Data): String = d.toString(); @@ -426,7 +426,7 @@ object LispAny extends Lisp { def string2lisp(s: String): Data = { val it = new LispTokenizer(s); - def parseExpr(token: String): Data = { + def parse(token: String): Data = { if (token == "(") parseList else if (token == ")") sys.error("unbalanced parentheses") //else if (Character.isDigit(token.charAt(0))) @@ -438,9 +438,9 @@ object LispAny extends Lisp { } def parseList: List[Data] = { val token = it.next; - if (token == ")") Nil else parseExpr(token) :: parseList + if (token == ")") Nil else parse(token) :: parseList } - parseExpr(it.next) + parse(it.next) } } diff --git a/test/files/pos/t6047.scala b/test/files/pos/t6047.scala index 80d5e9668b..bc5f856bd2 100644 --- a/test/files/pos/t6047.scala +++ b/test/files/pos/t6047.scala @@ -4,17 +4,17 @@ import java.io.InputStream object Macros { def unpack[A](input: InputStream): A = macro unpack_impl[A] - def unpack_impl[A: c.AbsTypeTag](c: Context)(input: c.Expr[InputStream]): c.Expr[A] = { + def unpack_impl[A: c.WeakTypeTag](c: Context)(input: c.Expr[InputStream]): c.Expr[A] = { import c.universe._ def unpackcode(tpe: c.Type): c.Expr[_] = { - if (tpe <:< implicitly[c.AbsTypeTag[Traversable[_]]].tpe) { + if (tpe <:< implicitly[c.WeakTypeTag[Traversable[_]]].tpe) { } ??? } - unpackcode(implicitly[c.AbsTypeTag[A]].tpe) + unpackcode(implicitly[c.WeakTypeTag[A]].tpe) ??? } }
\ No newline at end of file diff --git a/test/files/pos/t6245/Base.java b/test/files/pos/t6245/Base.java new file mode 100644 index 0000000000..651ea08bf2 --- /dev/null +++ b/test/files/pos/t6245/Base.java @@ -0,0 +1,5 @@ +package t1; + +public class Base { + protected Vis inner; +} diff --git a/test/files/pos/t6245/Foo.scala b/test/files/pos/t6245/Foo.scala new file mode 100644 index 0000000000..f5f997fbff --- /dev/null +++ b/test/files/pos/t6245/Foo.scala @@ -0,0 +1,9 @@ +import t1.Vis + +abstract class Foo extends t1.Base { + trait Nested { + def crash() { + inner + } + } +} diff --git a/test/files/pos/t6245/Vis.java b/test/files/pos/t6245/Vis.java new file mode 100644 index 0000000000..4267f4e40b --- /dev/null +++ b/test/files/pos/t6245/Vis.java @@ -0,0 +1,3 @@ +package t1; + +public class Vis { } diff --git a/test/files/pos/t6259.scala b/test/files/pos/t6259.scala new file mode 100644 index 0000000000..43361c417e --- /dev/null +++ b/test/files/pos/t6259.scala @@ -0,0 +1,47 @@ +package t6259 + +import scala.reflect.runtime.universe._ + +class A[X](implicit val tt: TypeTag[X]) {} +object B extends A[String] + +object C { + object D extends A[String] +} + +trait E { + object F extends A[String] +} + +class G { + object H extends A[String] +} + +object Test { + val x = { + object InVal extends A[String] + 5 + } + +} + +// Note: Both of these fail right now. + +trait NeedsEarly { + val x: AnyRef +} + +object Early extends { + // Drops to this.getClass and is not ok... + val x = { object EarlyOk extends A[String]; EarlyOk } +} with NeedsEarly + + +class DoubleTrouble[X](x: AnyRef)(implicit override val tt: TypeTag[X]) extends A[X] + +object DoubleOk extends DoubleTrouble[String]({ + // Drops to this.getClass and is an issue + object InnerTrouble extends A[String]; + InnerTrouble +}) + diff --git a/test/files/pos/t6278-synth-def.scala b/test/files/pos/t6278-synth-def.scala new file mode 100644 index 0000000000..b8b660fbe3 --- /dev/null +++ b/test/files/pos/t6278-synth-def.scala @@ -0,0 +1,30 @@ + +package t6278 + +import language.implicitConversions + +object test { + def ok() { + class Foo(val i: Int) { + def foo[A](body: =>A): A = body + } + implicit def toFoo(i: Int): Foo = new Foo(i) + + val k = 1 + k foo println("k?") + val j = 2 + } + def nope() { + implicit class Foo(val i: Int) { + def foo[A](body: =>A): A = body + } + + val k = 1 + k foo println("k?") + //lazy + val j = 2 + } + def main(args: Array[String]) { + ok(); nope() + } +} diff --git a/test/files/pos/t6335.scala b/test/files/pos/t6335.scala new file mode 100644 index 0000000000..50e34092d1 --- /dev/null +++ b/test/files/pos/t6335.scala @@ -0,0 +1,25 @@ +object E extends Z { + def X = 3 + implicit class X(val i: Int) { + def xx = i + } + + def Y(a: Any) = 0 + object Y + implicit class Y(val i: String) { def yy = i } + + implicit class Z(val i: Boolean) { def zz = i } +} + +trait Z { + def Z = 0 +} + +object Test { + import E._ + 0.xx + + "".yy + + true.zz +} diff --git a/test/files/pos/t6367.scala b/test/files/pos/t6367.scala new file mode 100644 index 0000000000..1214be7418 --- /dev/null +++ b/test/files/pos/t6367.scala @@ -0,0 +1,34 @@ +package play.api.libs.json.util + +trait FunctionalCanBuild[M[_]]{ + def apply[A,B](ma:M[A], mb:M[B]):M[A ~ B] +} + +trait Variant[M[_]] + +trait Functor[M[_]] extends Variant[M]{ + def fmap[A,B](m:M[A], f: A => B): M[B] +} + +case class ~[A,B](_1:A,_2:B) + +class FunctionalBuilder[M[_]](canBuild:FunctionalCanBuild[M]){ + class CanBuild20[A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20]( + m1:M[A1 ~ A2 ~ A3 ~ A4 ~ A5 ~ A6 ~ A7 ~ A8 ~ A9 ~ A10 ~ A11 ~ A12 ~ A13 ~ A14 ~ A15 ~ A16 ~ A17 ~ A18 ~ A19], + m2:M[A20] + ) { + + def ~[A21](m3:M[A21]) = new CanBuild21(canBuild(m1,m2),m3) + + def apply[B](f: (A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20) => B)(implicit fu:Functor[M]): M[B] = + fu.fmap[A1 ~ A2 ~ A3 ~ A4 ~ A5 ~ A6 ~ A7 ~ A8 ~ A9 ~ A10 ~ A11 ~ A12 ~ A13 ~ A14 ~ A15 ~ A16 ~ A17 ~ A18 ~ A19 ~ A20, B]( + canBuild(m1, m2), + { case a1 ~ a2 ~ a3 ~ a4 ~ a5 ~ a6 ~ a7 ~ a8 ~ a9 ~ a10 ~ a11 ~ a12 ~ a13 ~ a14 ~ a15 ~ a16 ~ a17 ~ a18 ~ a19 ~ a20 => + f(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20) } + ) + } + + class CanBuild21[A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21](m1:M[A1 ~ A2 ~ A3 ~ A4 ~ A5 ~ A6 ~ A7 ~ A8 ~ A9 ~ A10 ~ A11 ~ A12 ~ A13 ~ A14 ~ A15 ~ A16 ~ A17 ~ A18 ~ A19 ~ A20], m2:M[A21]){ + } + +} diff --git a/test/files/pos/z1720.scala b/test/files/pos/z1720.scala new file mode 100644 index 0000000000..7394d428c1 --- /dev/null +++ b/test/files/pos/z1720.scala @@ -0,0 +1,16 @@ +package test + +class Thing { + def info: Info[this.type] = InfoRepository.getInfo(this) + def info2: Info[this.type] = { + def self: this.type = this + InfoRepository.getInfo(self) + } +} + +trait Info[T] +case class InfoImpl[T](thing: T) extends Info[T] + +object InfoRepository { + def getInfo(t: Thing): Info[t.type] = InfoImpl(t) +} diff --git a/test/files/run/abstypetags_core.scala b/test/files/run/abstypetags_core.scala index 226de94055..2692fec035 100644 --- a/test/files/run/abstypetags_core.scala +++ b/test/files/run/abstypetags_core.scala @@ -1,34 +1,34 @@ import scala.reflect.runtime.universe._ object Test extends App { - println(implicitly[AbsTypeTag[Byte]] eq AbsTypeTag.Byte) - println(implicitly[AbsTypeTag[Byte]]) - println(implicitly[AbsTypeTag[Short]] eq AbsTypeTag.Short) - println(implicitly[AbsTypeTag[Short]]) - println(implicitly[AbsTypeTag[Char]] eq AbsTypeTag.Char) - println(implicitly[AbsTypeTag[Char]]) - println(implicitly[AbsTypeTag[Int]] eq AbsTypeTag.Int) - println(implicitly[AbsTypeTag[Int]]) - println(implicitly[AbsTypeTag[Long]] eq AbsTypeTag.Long) - println(implicitly[AbsTypeTag[Long]]) - println(implicitly[AbsTypeTag[Float]] eq AbsTypeTag.Float) - println(implicitly[AbsTypeTag[Float]]) - println(implicitly[AbsTypeTag[Double]] eq AbsTypeTag.Double) - println(implicitly[AbsTypeTag[Double]]) - println(implicitly[AbsTypeTag[Boolean]] eq AbsTypeTag.Boolean) - println(implicitly[AbsTypeTag[Boolean]]) - println(implicitly[AbsTypeTag[Unit]] eq AbsTypeTag.Unit) - println(implicitly[AbsTypeTag[Unit]]) - println(implicitly[AbsTypeTag[Any]] eq AbsTypeTag.Any) - println(implicitly[AbsTypeTag[Any]]) - println(implicitly[AbsTypeTag[AnyVal]] eq AbsTypeTag.AnyVal) - println(implicitly[AbsTypeTag[AnyVal]]) - println(implicitly[AbsTypeTag[AnyRef]] eq AbsTypeTag.AnyRef) - println(implicitly[AbsTypeTag[AnyRef]]) - println(implicitly[AbsTypeTag[Object]] eq AbsTypeTag.Object) - println(implicitly[AbsTypeTag[Object]]) - println(implicitly[AbsTypeTag[Null]] eq AbsTypeTag.Null) - println(implicitly[AbsTypeTag[Null]]) - println(implicitly[AbsTypeTag[Nothing]] eq AbsTypeTag.Nothing) - println(implicitly[AbsTypeTag[Nothing]]) + println(implicitly[WeakTypeTag[Byte]] eq WeakTypeTag.Byte) + println(implicitly[WeakTypeTag[Byte]]) + println(implicitly[WeakTypeTag[Short]] eq WeakTypeTag.Short) + println(implicitly[WeakTypeTag[Short]]) + println(implicitly[WeakTypeTag[Char]] eq WeakTypeTag.Char) + println(implicitly[WeakTypeTag[Char]]) + println(implicitly[WeakTypeTag[Int]] eq WeakTypeTag.Int) + println(implicitly[WeakTypeTag[Int]]) + println(implicitly[WeakTypeTag[Long]] eq WeakTypeTag.Long) + println(implicitly[WeakTypeTag[Long]]) + println(implicitly[WeakTypeTag[Float]] eq WeakTypeTag.Float) + println(implicitly[WeakTypeTag[Float]]) + println(implicitly[WeakTypeTag[Double]] eq WeakTypeTag.Double) + println(implicitly[WeakTypeTag[Double]]) + println(implicitly[WeakTypeTag[Boolean]] eq WeakTypeTag.Boolean) + println(implicitly[WeakTypeTag[Boolean]]) + println(implicitly[WeakTypeTag[Unit]] eq WeakTypeTag.Unit) + println(implicitly[WeakTypeTag[Unit]]) + println(implicitly[WeakTypeTag[Any]] eq WeakTypeTag.Any) + println(implicitly[WeakTypeTag[Any]]) + println(implicitly[WeakTypeTag[AnyVal]] eq WeakTypeTag.AnyVal) + println(implicitly[WeakTypeTag[AnyVal]]) + println(implicitly[WeakTypeTag[AnyRef]] eq WeakTypeTag.AnyRef) + println(implicitly[WeakTypeTag[AnyRef]]) + println(implicitly[WeakTypeTag[Object]] eq WeakTypeTag.Object) + println(implicitly[WeakTypeTag[Object]]) + println(implicitly[WeakTypeTag[Null]] eq WeakTypeTag.Null) + println(implicitly[WeakTypeTag[Null]]) + println(implicitly[WeakTypeTag[Nothing]] eq WeakTypeTag.Nothing) + println(implicitly[WeakTypeTag[Nothing]]) }
\ No newline at end of file diff --git a/test/files/run/abstypetags_serialize.scala b/test/files/run/abstypetags_serialize.scala index 5b9142f6d5..38a7aba325 100644 --- a/test/files/run/abstypetags_serialize.scala +++ b/test/files/run/abstypetags_serialize.scala @@ -3,7 +3,7 @@ import scala.reflect.runtime.universe._ import scala.reflect.runtime.{currentMirror => cm} object Test extends App { - def test(tag: AbsTypeTag[_]) = + def test(tag: WeakTypeTag[_]) = try { val fout = new ByteArrayOutputStream() val out = new ObjectOutputStream(fout) @@ -13,7 +13,7 @@ object Test extends App { val fin = new ByteArrayInputStream(fout.toByteArray) val in = new ObjectInputStream(fin) - val retag = in.readObject().asInstanceOf[scala.reflect.basis.AbsTypeTag[_]].in(cm) + val retag = in.readObject().asInstanceOf[scala.reflect.basis.WeakTypeTag[_]].in(cm) in.close() fin.close() @@ -24,8 +24,8 @@ object Test extends App { } def qwe[T, U[_]] = { - test(implicitly[AbsTypeTag[T]]) - test(implicitly[AbsTypeTag[U[String]]]) + test(implicitly[WeakTypeTag[T]]) + test(implicitly[WeakTypeTag[U[String]]]) } qwe diff --git a/test/files/run/compiler-asSeenFrom.check b/test/files/run/compiler-asSeenFrom.check index 96e257d303..47d40b0331 100644 --- a/test/files/run/compiler-asSeenFrom.check +++ b/test/files/run/compiler-asSeenFrom.check @@ -269,8 +269,8 @@ value jZ { // after parser value jZ { // after explicitouter protected val $outer: D.this.type - val ll$D$J$$$outer(): D.this.type - val ll$C$I$$$outer(): C.this.type + val $outer(): D.this.type + val $outer(): C.this.type def thisI(): I.this.type def thisC(): C.this.type def t2(): T2 @@ -279,9 +279,9 @@ value jZ { // after explicitouter value jZ { // after erasure protected val $outer: ll.D - val ll$D$J$$$outer(): ll.D + val $outer(): ll.D protected val $outer: ll.C - val ll$C$I$$$outer(): ll.C + val $outer(): ll.C def thisI(): ll.C#I def thisC(): ll.C def t2(): Object @@ -290,9 +290,9 @@ value jZ { // after erasure value jZ { // after flatten protected val $outer: ll.D - val ll$D$J$$$outer(): ll.D + val $outer(): ll.D protected val $outer: ll.C - val ll$C$I$$$outer(): ll.C + val $outer(): ll.C def thisI(): ll.C#C$I def thisC(): ll.C def t2(): Object diff --git a/test/files/run/empty-array.check b/test/files/run/empty-array.check new file mode 100644 index 0000000000..bb0b1cf658 --- /dev/null +++ b/test/files/run/empty-array.check @@ -0,0 +1,3 @@ +0 +0 +0 diff --git a/test/files/run/empty-array.scala b/test/files/run/empty-array.scala new file mode 100644 index 0000000000..e56c86df5c --- /dev/null +++ b/test/files/run/empty-array.scala @@ -0,0 +1,8 @@ +object Test { + def main(args: Array[String]): Unit = { + println(Byte.emptyArray.length) + println(Double.emptyArray.length) + println(Boolean.emptyArray.length) + // okay okay okay + } +} diff --git a/test/files/run/existentials3-new.check b/test/files/run/existentials3-new.check index a036d92a24..2550f4dae0 100644 --- a/test/files/run/existentials3-new.check +++ b/test/files/run/existentials3-new.check @@ -1,24 +1,24 @@ -Bar.type, t=TypeRef, s= <: scala.runtime.AbstractFunction0[Bar] with Serializable{case def unapply(x$0: Bar): Boolean} with Singleton
-Bar, t=TypeRef, s= <: Test.ToS with Product with Serializable{def copy(): Bar}
+Bar.type, t=TypeRef, s=type Bar.type
+Bar, t=TypeRef, s=type Bar
Test.ToS, t=RefinedType, s=f3
Test.ToS, t=RefinedType, s=f4
Test.ToS, t=RefinedType, s=f5
() => Test.ToS, t=TypeRef, s=class Function0
() => Test.ToS, t=TypeRef, s=class Function0
-$anon, t=TypeRef, s= <: B with Test.ToS
-$anon, t=TypeRef, s= <: B with A with Test.ToS
+$anon, t=TypeRef, s=type $anon
+$anon, t=TypeRef, s=type $anon
List[java.lang.Object{type T1}#T1], t=TypeRef, s=class List
List[Seq[Int]], t=TypeRef, s=class List
List[Seq[U forSome { type U <: Int }]], t=TypeRef, s=class List
-Bar.type, t=TypeRef, s= <: scala.runtime.AbstractFunction0[Bar] with Serializable{case def unapply(x$0: Bar): Boolean} with Singleton
-Bar, t=TypeRef, s= <: Test.ToS with Product with Serializable{def copy(): Bar}
+Bar.type, t=TypeRef, s=type Bar.type
+Bar, t=TypeRef, s=type Bar
Test.ToS, t=RefinedType, s=g3
Test.ToS, t=RefinedType, s=g4
Test.ToS, t=RefinedType, s=g5
() => Test.ToS, t=TypeRef, s=class Function0
() => Test.ToS, t=TypeRef, s=class Function0
-$anon, t=TypeRef, s= <: B with Test.ToS
-$anon, t=TypeRef, s= <: B with A with Test.ToS
+$anon, t=TypeRef, s=type $anon
+$anon, t=TypeRef, s=type $anon
List[java.lang.Object{type T1}#T1], t=TypeRef, s=class List
List[Seq[Int]], t=TypeRef, s=class List
List[Seq[U forSome { type U <: Int }]], t=TypeRef, s=class List
diff --git a/test/files/run/existentials3-new.scala b/test/files/run/existentials3-new.scala index 16735eab4f..110c8eff7a 100644 --- a/test/files/run/existentials3-new.scala +++ b/test/files/run/existentials3-new.scala @@ -38,31 +38,31 @@ object Test { println("%s, t=%s, s=%s".format(t, t.asInstanceOf[Product].productPrefix, s)) } def m[T: TypeTag](x: T) = printTpe(typeOf[T]) - def m2[T: AbsTypeTag](x: T) = printTpe(implicitly[AbsTypeTag[T]].tpe) + def m2[T: WeakTypeTag](x: T) = printTpe(implicitly[WeakTypeTag[T]].tpe) // tags do work for f10/g10 def main(args: Array[String]): Unit = { - m(f1) - m(f2) + m2(f1) + m2(f2) m(f3) m(f4) m(f5) m(f6) m(f7) - m(f8) - m(f9) + m2(f8) + m2(f9) m2(f10) m(f11) m(f12) - m(g1) - m(g2) + m2(g1) + m2(g2) m(g3) m(g4) m(g5) m(g6) m(g7) - m(g8) - m(g9) + m2(g8) + m2(g9) m2(g10) m(g11) m(g12) diff --git a/test/files/run/getClassTest-valueClass.check b/test/files/run/getClassTest-valueClass.check new file mode 100644 index 0000000000..7608d92b4e --- /dev/null +++ b/test/files/run/getClassTest-valueClass.check @@ -0,0 +1,2 @@ +int +class V diff --git a/test/files/run/getClassTest-valueClass.scala b/test/files/run/getClassTest-valueClass.scala new file mode 100644 index 0000000000..05a116dfff --- /dev/null +++ b/test/files/run/getClassTest-valueClass.scala @@ -0,0 +1,10 @@ +class V(val x: Int) extends AnyVal + +object Test { + def main(args: Array[String]) = { + val v = new V(2) + val s: Any = 2 + println(2.getClass) + println(v.getClass) + } +} diff --git a/test/files/run/interop_manifests_are_abstypetags.scala b/test/files/run/interop_manifests_are_abstypetags.scala index 1cba2fdb4b..f2c2723106 100644 --- a/test/files/run/interop_manifests_are_abstypetags.scala +++ b/test/files/run/interop_manifests_are_abstypetags.scala @@ -1,11 +1,11 @@ import scala.reflect.runtime.universe._ object Test extends App { - def manifestIsAbsTypeTag[T: Manifest] = { - println(implicitly[AbsTypeTag[T]].tpe) + def manifestIsWeakTypeTag[T: Manifest] = { + println(implicitly[WeakTypeTag[T]].tpe) } - manifestIsAbsTypeTag[Int] - manifestIsAbsTypeTag[String] - manifestIsAbsTypeTag[Array[Int]] + manifestIsWeakTypeTag[Int] + manifestIsWeakTypeTag[String] + manifestIsWeakTypeTag[Array[Int]] }
\ No newline at end of file diff --git a/test/files/run/macro-abort-fresh/Test_2.scala b/test/files/run/macro-abort-fresh/Test_2.scala index c6caa2b585..15c498efb0 100644 --- a/test/files/run/macro-abort-fresh/Test_2.scala +++ b/test/files/run/macro-abort-fresh/Test_2.scala @@ -3,6 +3,6 @@ object Test extends App { import scala.reflect.runtime.{currentMirror => cm} import scala.tools.reflect.ToolBox val tree = Select(Ident("Macros"), newTermName("foo")) - try cm.mkToolBox().runExpr(tree) + try cm.mkToolBox().eval(tree) catch { case ex: Throwable => println(ex.getMessage) } }
\ No newline at end of file diff --git a/test/files/run/macro-def-infer-return-type-b/Test_2.scala b/test/files/run/macro-def-infer-return-type-b/Test_2.scala index 0f84859545..ef2920a432 100644 --- a/test/files/run/macro-def-infer-return-type-b/Test_2.scala +++ b/test/files/run/macro-def-infer-return-type-b/Test_2.scala @@ -3,6 +3,6 @@ object Test extends App { import scala.reflect.runtime.{currentMirror => cm} import scala.tools.reflect.ToolBox val tree = Apply(Select(Ident("Macros"), newTermName("foo")), List(Literal(Constant(42)))) - try cm.mkToolBox().runExpr(tree) + try cm.mkToolBox().eval(tree) catch { case ex: Throwable => println(ex.getMessage) } } diff --git a/test/files/run/macro-def-path-dependent-d1/Impls_Macros_1.scala b/test/files/run/macro-def-path-dependent-d1/Impls_Macros_1.scala index 2daf6fc3fb..69d9708b2a 100644 --- a/test/files/run/macro-def-path-dependent-d1/Impls_Macros_1.scala +++ b/test/files/run/macro-def-path-dependent-d1/Impls_Macros_1.scala @@ -5,5 +5,5 @@ import scala.reflect.api.Universe object Test { def materializeTypeTag[T](u: Universe)(e: T) = macro materializeTypeTag_impl[T] - def materializeTypeTag_impl[T: c.AbsTypeTag](c: Context)(u: c.Expr[Universe])(e: c.Expr[T]): c.Expr[u.value.TypeTag[T]] = ??? + def materializeTypeTag_impl[T: c.WeakTypeTag](c: Context)(u: c.Expr[Universe])(e: c.Expr[T]): c.Expr[u.value.TypeTag[T]] = ??? }
\ No newline at end of file diff --git a/test/files/run/macro-def-path-dependent-d2/Impls_1.scala b/test/files/run/macro-def-path-dependent-d2/Impls_1.scala index 1cda64e43e..7fa9c3579e 100644 --- a/test/files/run/macro-def-path-dependent-d2/Impls_1.scala +++ b/test/files/run/macro-def-path-dependent-d2/Impls_1.scala @@ -3,5 +3,5 @@ import scala.reflect.macros.Context import scala.reflect.api.Universe object Impls { - def materializeTypeTag_impl[T: c.AbsTypeTag](c: Context)(u: c.Expr[Universe])(e: c.Expr[T]): c.Expr[u.value.TypeTag[T]] = ??? + def materializeTypeTag_impl[T: c.WeakTypeTag](c: Context)(u: c.Expr[Universe])(e: c.Expr[T]): c.Expr[u.value.TypeTag[T]] = ??? }
\ No newline at end of file diff --git a/test/files/run/macro-expand-implicit-argument/Macros_1.scala b/test/files/run/macro-expand-implicit-argument/Macros_1.scala index 7629c5a9e2..86c4198870 100644 --- a/test/files/run/macro-expand-implicit-argument/Macros_1.scala +++ b/test/files/run/macro-expand-implicit-argument/Macros_1.scala @@ -35,7 +35,7 @@ object Macros { * arr * } */ - def arrayMacro[A:c.AbsTypeTag](c:Context)(as:c.Expr[A]*)(ct: c.Expr[ClassTag[A]]): c.Expr[Array[A]] = { + def arrayMacro[A:c.WeakTypeTag](c:Context)(as:c.Expr[A]*)(ct: c.Expr[ClassTag[A]]): c.Expr[Array[A]] = { import c.mirror._ import c.universe._ def const(x:Int) = Literal(Constant(x)) @@ -44,7 +44,7 @@ object Macros { val arr = newTermName("arr") val create = Apply(Select(ct.tree, "newArray"), List(const(n))) - val arrtpe = TypeTree(implicitly[c.AbsTypeTag[Array[A]]].tpe) + val arrtpe = TypeTree(implicitly[c.WeakTypeTag[Array[A]]].tpe) val valdef = ValDef(Modifiers(), arr, arrtpe, create) val updates = (0 until n).map { diff --git a/test/files/run/macro-expand-nullary-generic/Impls_1.scala b/test/files/run/macro-expand-nullary-generic/Impls_1.scala index fbbc23a824..1180c83a40 100644 --- a/test/files/run/macro-expand-nullary-generic/Impls_1.scala +++ b/test/files/run/macro-expand-nullary-generic/Impls_1.scala @@ -2,14 +2,14 @@ import scala.reflect.runtime.universe._ import scala.reflect.macros.{Context => Ctx} object Impls { - def impl[T: c.AbsTypeTag](c: Ctx) = { + def impl[T: c.WeakTypeTag](c: Ctx) = { import c.universe._ - val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works " + implicitly[c.AbsTypeTag[T]])))) + val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works " + implicitly[c.WeakTypeTag[T]])))) c.Expr[Unit](body) } - def fooNullary[T: c.AbsTypeTag](c: Ctx) = impl[T](c) - def fooEmpty[T: c.AbsTypeTag](c: Ctx)() = impl[T](c) - def barNullary[T: c.AbsTypeTag](c: Ctx)(x: c.Expr[Int]) = impl[T](c) - def barEmpty[T: c.AbsTypeTag](c: Ctx)(x: c.Expr[Int])() = impl[T](c) + def fooNullary[T: c.WeakTypeTag](c: Ctx) = impl[T](c) + def fooEmpty[T: c.WeakTypeTag](c: Ctx)() = impl[T](c) + def barNullary[T: c.WeakTypeTag](c: Ctx)(x: c.Expr[Int]) = impl[T](c) + def barEmpty[T: c.WeakTypeTag](c: Ctx)(x: c.Expr[Int])() = impl[T](c) }
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-explicit/Impls_1.scala b/test/files/run/macro-expand-tparams-explicit/Impls_1.scala index 0a879687e8..72b420d92f 100644 --- a/test/files/run/macro-expand-tparams-explicit/Impls_1.scala +++ b/test/files/run/macro-expand-tparams-explicit/Impls_1.scala @@ -2,9 +2,9 @@ import scala.reflect.runtime.universe._ import scala.reflect.macros.{Context => Ctx} object Impls { - def foo[U: c.AbsTypeTag](c: Ctx) = { + def foo[U: c.WeakTypeTag](c: Ctx) = { import c.universe._ - val U = implicitly[c.AbsTypeTag[U]] + val U = implicitly[c.WeakTypeTag[U]] val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(U.toString)))) c.Expr[Unit](body) } diff --git a/test/files/run/macro-expand-tparams-implicit.check b/test/files/run/macro-expand-tparams-implicit.check index 1c1a785706..37226ec68d 100644 --- a/test/files/run/macro-expand-tparams-implicit.check +++ b/test/files/run/macro-expand-tparams-implicit.check @@ -1,2 +1,2 @@ TypeTag[Int]
-AbsTypeTag[String]
+WeakTypeTag[String]
diff --git a/test/files/run/macro-expand-tparams-implicit/Impls_1.scala b/test/files/run/macro-expand-tparams-implicit/Impls_1.scala index f6cb63b9c9..33770516df 100644 --- a/test/files/run/macro-expand-tparams-implicit/Impls_1.scala +++ b/test/files/run/macro-expand-tparams-implicit/Impls_1.scala @@ -2,9 +2,9 @@ import scala.reflect.runtime.universe._ import scala.reflect.macros.{Context => Ctx} object Impls { - def foo[U: c.AbsTypeTag](c: Ctx)(x: c.Expr[U]) = { + def foo[U: c.WeakTypeTag](c: Ctx)(x: c.Expr[U]) = { import c.universe._ - val U = implicitly[c.AbsTypeTag[U]] + val U = implicitly[c.WeakTypeTag[U]] val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(U.toString)))) c.Expr[Unit](body) } diff --git a/test/files/run/macro-expand-tparams-prefix-a.check b/test/files/run/macro-expand-tparams-prefix-a.check index 6a7f9c5f52..7ef9fa7330 100644 --- a/test/files/run/macro-expand-tparams-prefix-a.check +++ b/test/files/run/macro-expand-tparams-prefix-a.check @@ -1,4 +1,4 @@ TypeTag[Int]
TypeTag[Int]
-AbsTypeTag[String]
+WeakTypeTag[String]
TypeTag[Boolean]
diff --git a/test/files/run/macro-expand-tparams-prefix-a/Impls_1.scala b/test/files/run/macro-expand-tparams-prefix-a/Impls_1.scala index f6cb63b9c9..33770516df 100644 --- a/test/files/run/macro-expand-tparams-prefix-a/Impls_1.scala +++ b/test/files/run/macro-expand-tparams-prefix-a/Impls_1.scala @@ -2,9 +2,9 @@ import scala.reflect.runtime.universe._ import scala.reflect.macros.{Context => Ctx} object Impls { - def foo[U: c.AbsTypeTag](c: Ctx)(x: c.Expr[U]) = { + def foo[U: c.WeakTypeTag](c: Ctx)(x: c.Expr[U]) = { import c.universe._ - val U = implicitly[c.AbsTypeTag[U]] + val U = implicitly[c.WeakTypeTag[U]] val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(U.toString)))) c.Expr[Unit](body) } diff --git a/test/files/run/macro-expand-tparams-prefix-b.check b/test/files/run/macro-expand-tparams-prefix-b.check index daae32bd0a..f4a2a8e80d 100644 --- a/test/files/run/macro-expand-tparams-prefix-b.check +++ b/test/files/run/macro-expand-tparams-prefix-b.check @@ -1,2 +1,2 @@ TypeTag[Boolean] TypeTag[Int]
-TypeTag[Boolean] AbsTypeTag[String]
+TypeTag[Boolean] WeakTypeTag[String]
diff --git a/test/files/run/macro-expand-tparams-prefix-b/Impls_1.scala b/test/files/run/macro-expand-tparams-prefix-b/Impls_1.scala index 7e0fa26569..9378e67712 100644 --- a/test/files/run/macro-expand-tparams-prefix-b/Impls_1.scala +++ b/test/files/run/macro-expand-tparams-prefix-b/Impls_1.scala @@ -2,10 +2,10 @@ import scala.reflect.runtime.universe._ import scala.reflect.macros.{Context => Ctx} object Impls { - def foo[T: c.AbsTypeTag, U: c.AbsTypeTag](c: Ctx)(x: c.Expr[U]) = { + def foo[T: c.WeakTypeTag, U: c.WeakTypeTag](c: Ctx)(x: c.Expr[U]) = { import c.universe._ - val T = implicitly[c.AbsTypeTag[T]] - val U = implicitly[c.AbsTypeTag[U]] + val T = implicitly[c.WeakTypeTag[T]] + val U = implicitly[c.WeakTypeTag[U]] val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(T.toString + " " + U.toString)))) c.Expr[Unit](body) } diff --git a/test/files/run/macro-expand-tparams-prefix-c1.check b/test/files/run/macro-expand-tparams-prefix-c1.check index 5356b3e6d1..473668ac58 100644 --- a/test/files/run/macro-expand-tparams-prefix-c1.check +++ b/test/files/run/macro-expand-tparams-prefix-c1.check @@ -1,3 +1,3 @@ TypeTag[Int]
-AbsTypeTag[String]
+WeakTypeTag[String]
TypeTag[Boolean]
diff --git a/test/files/run/macro-expand-tparams-prefix-c1/Impls_1.scala b/test/files/run/macro-expand-tparams-prefix-c1/Impls_1.scala index ca515be627..afdd7d4f7a 100644 --- a/test/files/run/macro-expand-tparams-prefix-c1/Impls_1.scala +++ b/test/files/run/macro-expand-tparams-prefix-c1/Impls_1.scala @@ -2,11 +2,11 @@ import scala.reflect.runtime.universe._ import scala.reflect.macros.{Context => Ctx} object Impls { - def foo[T, U: c.AbsTypeTag, V](c: Ctx)(implicit T: c.AbsTypeTag[T], V: c.AbsTypeTag[V]): c.Expr[Unit] = { + def foo[T, U: c.WeakTypeTag, V](c: Ctx)(implicit T: c.WeakTypeTag[T], V: c.WeakTypeTag[V]): c.Expr[Unit] = { import c.universe._ c.Expr(Block(List( Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(T.toString)))), - Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(implicitly[c.AbsTypeTag[U]].toString)))), + Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(implicitly[c.WeakTypeTag[U]].toString)))), Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(V.toString))))), Literal(Constant(())))) } diff --git a/test/files/run/macro-expand-tparams-prefix-c2.check b/test/files/run/macro-expand-tparams-prefix-c2.check index 5356b3e6d1..473668ac58 100644 --- a/test/files/run/macro-expand-tparams-prefix-c2.check +++ b/test/files/run/macro-expand-tparams-prefix-c2.check @@ -1,3 +1,3 @@ TypeTag[Int]
-AbsTypeTag[String]
+WeakTypeTag[String]
TypeTag[Boolean]
diff --git a/test/files/run/macro-expand-tparams-prefix-c2/Impls_Macros_1.scala b/test/files/run/macro-expand-tparams-prefix-c2/Impls_Macros_1.scala index 5a554590d8..3c2838208a 100644 --- a/test/files/run/macro-expand-tparams-prefix-c2/Impls_Macros_1.scala +++ b/test/files/run/macro-expand-tparams-prefix-c2/Impls_Macros_1.scala @@ -2,11 +2,11 @@ import scala.reflect.runtime.universe._ import scala.reflect.macros.{Context => Ctx} object Impls { - def foo[T, U: c.AbsTypeTag, V](c: Ctx)(implicit T: c.AbsTypeTag[T], V: c.AbsTypeTag[V]): c.Expr[Unit] = { + def foo[T, U: c.WeakTypeTag, V](c: Ctx)(implicit T: c.WeakTypeTag[T], V: c.WeakTypeTag[V]): c.Expr[Unit] = { import c.universe._ c.Expr(Block(List( Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(T.toString)))), - Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(implicitly[c.AbsTypeTag[U]].toString)))), + Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(implicitly[c.WeakTypeTag[U]].toString)))), Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(V.toString))))), Literal(Constant(())))) } diff --git a/test/files/run/macro-expand-tparams-prefix-d1.check b/test/files/run/macro-expand-tparams-prefix-d1.check index 319edfbed0..2331e2549e 100644 --- a/test/files/run/macro-expand-tparams-prefix-d1.check +++ b/test/files/run/macro-expand-tparams-prefix-d1.check @@ -1,3 +1,3 @@ -AbsTypeTag[T]
-AbsTypeTag[U]
+WeakTypeTag[T]
+WeakTypeTag[U]
TypeTag[Boolean]
diff --git a/test/files/run/macro-expand-tparams-prefix-d1/Impls_1.scala b/test/files/run/macro-expand-tparams-prefix-d1/Impls_1.scala index ca515be627..afdd7d4f7a 100644 --- a/test/files/run/macro-expand-tparams-prefix-d1/Impls_1.scala +++ b/test/files/run/macro-expand-tparams-prefix-d1/Impls_1.scala @@ -2,11 +2,11 @@ import scala.reflect.runtime.universe._ import scala.reflect.macros.{Context => Ctx} object Impls { - def foo[T, U: c.AbsTypeTag, V](c: Ctx)(implicit T: c.AbsTypeTag[T], V: c.AbsTypeTag[V]): c.Expr[Unit] = { + def foo[T, U: c.WeakTypeTag, V](c: Ctx)(implicit T: c.WeakTypeTag[T], V: c.WeakTypeTag[V]): c.Expr[Unit] = { import c.universe._ c.Expr(Block(List( Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(T.toString)))), - Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(implicitly[c.AbsTypeTag[U]].toString)))), + Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(implicitly[c.WeakTypeTag[U]].toString)))), Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(V.toString))))), Literal(Constant(())))) } diff --git a/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-bad/Macros_Test_2.scala b/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-bad/Macros_Test_2.scala index c0319fcd6c..16d2c1e6ac 100644 --- a/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-bad/Macros_Test_2.scala +++ b/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-bad/Macros_Test_2.scala @@ -7,6 +7,6 @@ object Test extends App { import scala.reflect.runtime.{currentMirror => cm} import scala.tools.reflect.ToolBox val tree = Apply(Select(Ident("Macros"), newTermName("foo")), List(Typed(Apply(Ident(definitions.ListModule), List(Literal(Constant(1)), Literal(Constant(2)))), Ident(tpnme.WILDCARD_STAR)))) - try cm.mkToolBox().runExpr(tree) + try cm.mkToolBox().eval(tree) catch { case ex: Throwable => println(ex.getMessage) } }
\ No newline at end of file diff --git a/test/files/run/macro-impl-default-params/Impls_Macros_1.scala b/test/files/run/macro-impl-default-params/Impls_Macros_1.scala index 06c58d96ab..db77b1923a 100644 --- a/test/files/run/macro-impl-default-params/Impls_Macros_1.scala +++ b/test/files/run/macro-impl-default-params/Impls_Macros_1.scala @@ -2,10 +2,10 @@ import scala.reflect.runtime.universe._ import scala.reflect.macros.{Context => Ctx} object Impls { - def foo_targs[T, U: c.AbsTypeTag](c: Ctx = null)(x: c.Expr[Int] = null) = { + def foo_targs[T, U: c.WeakTypeTag](c: Ctx = null)(x: c.Expr[Int] = null) = { import c.{prefix => prefix} import c.universe._ - val U = implicitly[c.AbsTypeTag[U]] + val U = implicitly[c.WeakTypeTag[U]] val body = Block( Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("invoking foo_targs...")))), Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("type of prefix is: " + prefix.staticType)))), diff --git a/test/files/run/macro-invalidret-doesnt-conform-to-def-rettype/Test_2.scala b/test/files/run/macro-invalidret-doesnt-conform-to-def-rettype/Test_2.scala index c6caa2b585..15c498efb0 100644 --- a/test/files/run/macro-invalidret-doesnt-conform-to-def-rettype/Test_2.scala +++ b/test/files/run/macro-invalidret-doesnt-conform-to-def-rettype/Test_2.scala @@ -3,6 +3,6 @@ object Test extends App { import scala.reflect.runtime.{currentMirror => cm} import scala.tools.reflect.ToolBox val tree = Select(Ident("Macros"), newTermName("foo")) - try cm.mkToolBox().runExpr(tree) + try cm.mkToolBox().eval(tree) catch { case ex: Throwable => println(ex.getMessage) } }
\ No newline at end of file diff --git a/test/files/run/macro-invalidret-nontypeable/Test_2.scala b/test/files/run/macro-invalidret-nontypeable/Test_2.scala index c6caa2b585..15c498efb0 100644 --- a/test/files/run/macro-invalidret-nontypeable/Test_2.scala +++ b/test/files/run/macro-invalidret-nontypeable/Test_2.scala @@ -3,6 +3,6 @@ object Test extends App { import scala.reflect.runtime.{currentMirror => cm} import scala.tools.reflect.ToolBox val tree = Select(Ident("Macros"), newTermName("foo")) - try cm.mkToolBox().runExpr(tree) + try cm.mkToolBox().eval(tree) catch { case ex: Throwable => println(ex.getMessage) } }
\ No newline at end of file diff --git a/test/files/run/macro-invalidusage-badret/Test_2.scala b/test/files/run/macro-invalidusage-badret/Test_2.scala index 8322e8a4e0..f3a76f3fff 100644 --- a/test/files/run/macro-invalidusage-badret/Test_2.scala +++ b/test/files/run/macro-invalidusage-badret/Test_2.scala @@ -3,6 +3,6 @@ object Test extends App { import scala.reflect.runtime.{currentMirror => cm} import scala.tools.reflect.ToolBox val tree = Typed(Apply(Select(Ident("Macros"), newTermName("foo")), List(Literal(Constant(42)))), Ident(newTypeName("String"))) - try cm.mkToolBox().runExpr(tree) + try cm.mkToolBox().eval(tree) catch { case ex: Throwable => println(ex.getMessage) } } diff --git a/test/files/run/macro-invalidusage-partialapplication-with-tparams/Impls_Macros_1.scala b/test/files/run/macro-invalidusage-partialapplication-with-tparams/Impls_Macros_1.scala index a54b7f4b08..4583a726cf 100644 --- a/test/files/run/macro-invalidusage-partialapplication-with-tparams/Impls_Macros_1.scala +++ b/test/files/run/macro-invalidusage-partialapplication-with-tparams/Impls_Macros_1.scala @@ -1,7 +1,7 @@ import scala.reflect.macros.{Context => Ctx} object Impls { - def foo[T: c.AbsTypeTag](c: Ctx)(x: c.Expr[T]) = { + def foo[T: c.WeakTypeTag](c: Ctx)(x: c.Expr[T]) = { import c.universe._ val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(x.tree.toString)))) c.Expr[Unit](body) diff --git a/test/files/run/macro-invalidusage-partialapplication-with-tparams/Test_2.scala b/test/files/run/macro-invalidusage-partialapplication-with-tparams/Test_2.scala index f51cc7e699..c91fd7d380 100644 --- a/test/files/run/macro-invalidusage-partialapplication-with-tparams/Test_2.scala +++ b/test/files/run/macro-invalidusage-partialapplication-with-tparams/Test_2.scala @@ -3,6 +3,6 @@ object Test extends App { import scala.reflect.runtime.{currentMirror => cm} import scala.tools.reflect.ToolBox val tree = Select(Ident("Macros"), newTermName("foo")) - try cm.mkToolBox().runExpr(tree) + try cm.mkToolBox().eval(tree) catch { case ex: Throwable => println(ex.getMessage) } } diff --git a/test/files/run/macro-invalidusage-partialapplication/Test_2.scala b/test/files/run/macro-invalidusage-partialapplication/Test_2.scala index 64020b2aa9..cbfee725e2 100644 --- a/test/files/run/macro-invalidusage-partialapplication/Test_2.scala +++ b/test/files/run/macro-invalidusage-partialapplication/Test_2.scala @@ -3,6 +3,6 @@ object Test extends App { import scala.reflect.runtime.{currentMirror => cm} import scala.tools.reflect.ToolBox val tree = Apply(Select(Ident("Macros"), newTermName("foo")), List(Literal(Constant(40)))) - try cm.mkToolBox().runExpr(tree) + try cm.mkToolBox().eval(tree) catch { case ex: Throwable => println(ex.getMessage) } } diff --git a/test/files/run/macro-reflective-ma-normal-mdmi/Test_2.scala b/test/files/run/macro-reflective-ma-normal-mdmi/Test_2.scala index 67666a632b..373c6a6fca 100644 --- a/test/files/run/macro-reflective-ma-normal-mdmi/Test_2.scala +++ b/test/files/run/macro-reflective-ma-normal-mdmi/Test_2.scala @@ -3,5 +3,5 @@ object Test extends App { import scala.reflect.runtime.{currentMirror => cm} import scala.tools.reflect.ToolBox val tree = Apply(Select(Ident("Macros"), newTermName("foo")), List(Literal(Constant(42)))) - println(cm.mkToolBox().runExpr(tree)) + println(cm.mkToolBox().eval(tree)) } diff --git a/test/files/run/macro-reflective-mamd-normal-mi/Macros_Test_2.scala b/test/files/run/macro-reflective-mamd-normal-mi/Macros_Test_2.scala index 7a2c0a6fa9..089f30f389 100644 --- a/test/files/run/macro-reflective-mamd-normal-mi/Macros_Test_2.scala +++ b/test/files/run/macro-reflective-mamd-normal-mi/Macros_Test_2.scala @@ -16,5 +16,5 @@ object Test extends App { val macroapp = Apply(Select(Ident("Macros"), newTermName("foo")), List(Literal(Constant(42)))) val tree = Block(macrodef, module, macroapp) val toolbox = cm.mkToolBox(options = "-language:experimental.macros") - println(toolbox.runExpr(tree)) + println(toolbox.eval(tree)) } diff --git a/test/files/run/macro-reify-abstypetag-notypeparams/Test.scala b/test/files/run/macro-reify-abstypetag-notypeparams/Test.scala index 34f742b9fb..73c2d05921 100644 --- a/test/files/run/macro-reify-abstypetag-notypeparams/Test.scala +++ b/test/files/run/macro-reify-abstypetag-notypeparams/Test.scala @@ -1,6 +1,6 @@ import scala.reflect.runtime.universe._ object Test extends App { - println(implicitly[AbsTypeTag[Int]]) - println(implicitly[AbsTypeTag[List[Int]]]) + println(implicitly[WeakTypeTag[Int]]) + println(implicitly[WeakTypeTag[List[Int]]]) }
\ No newline at end of file diff --git a/test/files/run/macro-reify-abstypetag-typeparams-notags.check b/test/files/run/macro-reify-abstypetag-typeparams-notags.check index be62b59a69..6aeec96079 100644 --- a/test/files/run/macro-reify-abstypetag-typeparams-notags.check +++ b/test/files/run/macro-reify-abstypetag-typeparams-notags.check @@ -1,2 +1,2 @@ -AbsTypeTag[T]
-AbsTypeTag[List[T]]
+WeakTypeTag[T]
+WeakTypeTag[List[T]]
diff --git a/test/files/run/macro-reify-abstypetag-typeparams-notags/Test.scala b/test/files/run/macro-reify-abstypetag-typeparams-notags/Test.scala index 0b42cc07b5..4ba2231d9a 100644 --- a/test/files/run/macro-reify-abstypetag-typeparams-notags/Test.scala +++ b/test/files/run/macro-reify-abstypetag-typeparams-notags/Test.scala @@ -2,8 +2,8 @@ import scala.reflect.runtime.universe._ object Test extends App { def fooNoTypeTag[T] = { - println(implicitly[AbsTypeTag[T]]) - println(implicitly[AbsTypeTag[List[T]]]) + println(implicitly[WeakTypeTag[T]]) + println(implicitly[WeakTypeTag[List[T]]]) } fooNoTypeTag[Int] }
\ No newline at end of file diff --git a/test/files/run/macro-reify-abstypetag-typeparams-tags.check b/test/files/run/macro-reify-abstypetag-typeparams-tags.check index d6ca5a85ef..6e2646c5e0 100644 --- a/test/files/run/macro-reify-abstypetag-typeparams-tags.check +++ b/test/files/run/macro-reify-abstypetag-typeparams-tags.check @@ -1,2 +1,2 @@ TypeTag[Int]
-AbsTypeTag[List[Int]]
+WeakTypeTag[List[Int]]
diff --git a/test/files/run/macro-reify-abstypetag-typeparams-tags/Test.scala b/test/files/run/macro-reify-abstypetag-typeparams-tags/Test.scala index 82a7b7971d..70ca615e1f 100644 --- a/test/files/run/macro-reify-abstypetag-typeparams-tags/Test.scala +++ b/test/files/run/macro-reify-abstypetag-typeparams-tags/Test.scala @@ -1,9 +1,9 @@ import scala.reflect.runtime.universe._ object Test extends App { - def fooTypeTag[T: AbsTypeTag] = { - println(implicitly[AbsTypeTag[T]]) - println(implicitly[AbsTypeTag[List[T]]]) + def fooTypeTag[T: WeakTypeTag] = { + println(implicitly[WeakTypeTag[T]]) + println(implicitly[WeakTypeTag[List[T]]]) } fooTypeTag[Int] }
\ No newline at end of file diff --git a/test/files/run/macro-reify-abstypetag-usetypetag.check b/test/files/run/macro-reify-abstypetag-usetypetag.check index d6ca5a85ef..6e2646c5e0 100644 --- a/test/files/run/macro-reify-abstypetag-usetypetag.check +++ b/test/files/run/macro-reify-abstypetag-usetypetag.check @@ -1,2 +1,2 @@ TypeTag[Int]
-AbsTypeTag[List[Int]]
+WeakTypeTag[List[Int]]
diff --git a/test/files/run/macro-reify-abstypetag-usetypetag/Test.scala b/test/files/run/macro-reify-abstypetag-usetypetag/Test.scala index 3c62725c42..ecae4110a8 100644 --- a/test/files/run/macro-reify-abstypetag-usetypetag/Test.scala +++ b/test/files/run/macro-reify-abstypetag-usetypetag/Test.scala @@ -2,8 +2,8 @@ import scala.reflect.runtime.universe._ object Test extends App { def fooTypeTag[T: TypeTag] = { - println(implicitly[AbsTypeTag[T]]) - println(implicitly[AbsTypeTag[List[T]]]) + println(implicitly[WeakTypeTag[T]]) + println(implicitly[WeakTypeTag[List[T]]]) } fooTypeTag[Int] }
\ No newline at end of file diff --git a/test/files/run/macro-reify-freevars/Macros_1.scala b/test/files/run/macro-reify-freevars/Macros_1.scala index 57fdc32437..20f80c06d1 100644 --- a/test/files/run/macro-reify-freevars/Macros_1.scala +++ b/test/files/run/macro-reify-freevars/Macros_1.scala @@ -1,7 +1,7 @@ package scala.collection.slick object QueryableMacros{ - def map[T:c.AbsTypeTag, S:c.AbsTypeTag] + def map[T:c.WeakTypeTag, S:c.WeakTypeTag] (c: scala.reflect.macros.Context) (projection: c.Expr[T => S]) : c.Expr[scala.collection.slick.Queryable[S]] = { diff --git a/test/files/run/macro-reify-freevars/Test_2.scala b/test/files/run/macro-reify-freevars/Test_2.scala index 603cf10d41..e24758cfb4 100644 --- a/test/files/run/macro-reify-freevars/Test_2.scala +++ b/test/files/run/macro-reify-freevars/Test_2.scala @@ -6,6 +6,6 @@ object Test extends App { val x = ValDef(NoMods, newTermName("x"), Ident("Int"), EmptyTree) val fn = Function(List(x), Apply(Select(Ident(newTermName("x")), newTermName("$plus")), List(Literal(Constant("5"))))) val tree = Apply(Select(q, newTermName("map")), List(fn)) - try cm.mkToolBox().runExpr(tree) + try cm.mkToolBox().eval(tree) catch { case ex: Throwable => println(ex.getMessage) } }
\ No newline at end of file diff --git a/test/files/run/macro-reify-nested-a/Impls_Macros_1.scala b/test/files/run/macro-reify-nested-a/Impls_Macros_1.scala index 04714970dd..ae2def2d3e 100644 --- a/test/files/run/macro-reify-nested-a/Impls_Macros_1.scala +++ b/test/files/run/macro-reify-nested-a/Impls_Macros_1.scala @@ -21,9 +21,9 @@ case class Utils[C <: Context]( c:C ) { } } object QueryableMacros{ - def _helper[C <: Context,S:c.AbsTypeTag]( c:C )( name:String, projection:c.Expr[_] ) = { + def _helper[C <: Context,S:c.WeakTypeTag]( c:C )( name:String, projection:c.Expr[_] ) = { import c.universe._ - val element_type = implicitly[c.AbsTypeTag[S]].tpe + val element_type = implicitly[c.WeakTypeTag[S]].tpe val foo = c.Expr[ru.Expr[Queryable[S]]]( c.reifyTree( c.runtimeUniverse, EmptyTree, c.typeCheck( Utils[c.type](c).removeDoubleReify( @@ -32,7 +32,7 @@ object QueryableMacros{ ))) c.universe.reify{ Queryable.factory[S]( foo.splice )} } - def map[T:c.AbsTypeTag, S:c.AbsTypeTag] + def map[T:c.WeakTypeTag, S:c.WeakTypeTag] (c: scala.reflect.macros.Context) (projection: c.Expr[T => S]): c.Expr[Queryable[S]] = _helper[c.type,S]( c )( "_map", projection ) } diff --git a/test/files/run/macro-reify-nested-b/Impls_Macros_1.scala b/test/files/run/macro-reify-nested-b/Impls_Macros_1.scala index 04714970dd..ae2def2d3e 100644 --- a/test/files/run/macro-reify-nested-b/Impls_Macros_1.scala +++ b/test/files/run/macro-reify-nested-b/Impls_Macros_1.scala @@ -21,9 +21,9 @@ case class Utils[C <: Context]( c:C ) { } } object QueryableMacros{ - def _helper[C <: Context,S:c.AbsTypeTag]( c:C )( name:String, projection:c.Expr[_] ) = { + def _helper[C <: Context,S:c.WeakTypeTag]( c:C )( name:String, projection:c.Expr[_] ) = { import c.universe._ - val element_type = implicitly[c.AbsTypeTag[S]].tpe + val element_type = implicitly[c.WeakTypeTag[S]].tpe val foo = c.Expr[ru.Expr[Queryable[S]]]( c.reifyTree( c.runtimeUniverse, EmptyTree, c.typeCheck( Utils[c.type](c).removeDoubleReify( @@ -32,7 +32,7 @@ object QueryableMacros{ ))) c.universe.reify{ Queryable.factory[S]( foo.splice )} } - def map[T:c.AbsTypeTag, S:c.AbsTypeTag] + def map[T:c.WeakTypeTag, S:c.WeakTypeTag] (c: scala.reflect.macros.Context) (projection: c.Expr[T => S]): c.Expr[Queryable[S]] = _helper[c.type,S]( c )( "_map", projection ) } diff --git a/test/files/run/macro-reify-splice-outside-reify/Impls_Macros_1.scala b/test/files/run/macro-reify-splice-outside-reify/Impls_Macros_1.scala index f3e1c9ae95..b23a5c70e1 100644 --- a/test/files/run/macro-reify-splice-outside-reify/Impls_Macros_1.scala +++ b/test/files/run/macro-reify-splice-outside-reify/Impls_Macros_1.scala @@ -15,7 +15,7 @@ object Impls { val importer = ru.mkImporter(c.universe).asInstanceOf[ru.Importer { val from: c.universe.type }] val tree = c.resetAllAttrs(x.tree.duplicate) val imported = importer.importTree(tree) - toolBox.runExpr(imported).asInstanceOf[T] + toolBox.eval(imported).asInstanceOf[T] } } diff --git a/test/files/run/macro-reify-splice-outside-reify/Test_2.scala b/test/files/run/macro-reify-splice-outside-reify/Test_2.scala index 5bca7db668..8f96ea199d 100644 --- a/test/files/run/macro-reify-splice-outside-reify/Test_2.scala +++ b/test/files/run/macro-reify-splice-outside-reify/Test_2.scala @@ -3,6 +3,6 @@ object Test extends App { import scala.reflect.runtime.{currentMirror => cm} import scala.tools.reflect.ToolBox val tree = Apply(Select(Ident("Macros"), newTermName("foo")), List(Literal(Constant(42)))) - try println(cm.mkToolBox().runExpr(tree)) + try println(cm.mkToolBox().eval(tree)) catch { case ex: Throwable => println(ex.getMessage) } } diff --git a/test/files/run/macro-reify-tagful-a/Macros_1.scala b/test/files/run/macro-reify-tagful-a/Macros_1.scala index 0eac74236f..f2512dcfaf 100644 --- a/test/files/run/macro-reify-tagful-a/Macros_1.scala +++ b/test/files/run/macro-reify-tagful-a/Macros_1.scala @@ -5,7 +5,7 @@ object Macros { def foo[T](s: T) = macro Impls.foo[T] object Impls { - def foo[T: c.AbsTypeTag](c: Ctx)(s: c.Expr[T]) = c.universe.reify { + def foo[T: c.WeakTypeTag](c: Ctx)(s: c.Expr[T]) = c.universe.reify { List(s.splice) } } diff --git a/test/files/run/macro-reify-tagless-a.check b/test/files/run/macro-reify-tagless-a.check index d69f641280..c2385ba008 100644 --- a/test/files/run/macro-reify-tagless-a.check +++ b/test/files/run/macro-reify-tagless-a.check @@ -1,3 +1,3 @@ reflective compilation has failed:
-Macro expansion contains free type variable T defined by foo in Impls_Macros_1.scala:7:13. Have you forgotten to use c.AbsTypeTag annotation for this type parameter? If you have troubles tracking free type variables, consider using -Xlog-free-types
+Macro expansion contains free type variable T defined by foo in Impls_Macros_1.scala:7:13. Have you forgotten to use c.WeakTypeTag annotation for this type parameter? If you have troubles tracking free type variables, consider using -Xlog-free-types
diff --git a/test/files/run/macro-reify-tagless-a/Test_2.scala b/test/files/run/macro-reify-tagless-a/Test_2.scala index 7029e59ea1..1bb3945ece 100644 --- a/test/files/run/macro-reify-tagless-a/Test_2.scala +++ b/test/files/run/macro-reify-tagless-a/Test_2.scala @@ -9,6 +9,6 @@ object Test extends App { val rhs = Apply(Select(Ident("Macros"), newTermName("foo")), List(Literal(Constant("hello world")))) val list = ValDef(NoMods, newTermName("list"), tpt, rhs) val tree = Block(list, Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Ident(list.name)))) - try cm.mkToolBox().runExpr(tree) + try cm.mkToolBox().eval(tree) catch { case ex: Throwable => println(ex.getMessage) } } diff --git a/test/files/run/macro-typecheck-macrosdisabled/Impls_Macros_1.scala b/test/files/run/macro-typecheck-macrosdisabled/Impls_Macros_1.scala index b2f6f7d50e..f693ad78cc 100644 --- a/test/files/run/macro-typecheck-macrosdisabled/Impls_Macros_1.scala +++ b/test/files/run/macro-typecheck-macrosdisabled/Impls_Macros_1.scala @@ -18,7 +18,8 @@ object Macros { val rupkg = c.mirror.staticModule("scala.reflect.runtime.package") val rusym = build.selectTerm(rupkg, "universe") val NullaryMethodType(rutpe) = rusym.typeSignature - val ru = build.newFreeTerm("ru", rutpe, scala.reflect.runtime.universe) + val ru = build.newFreeTerm("ru", scala.reflect.runtime.universe) + build.setTypeSignature(ru, rutpe) val tree2 = Apply(Select(Ident(ru), newTermName("reify")), List(Literal(Constant(2)))) val ttree2 = c.typeCheck(tree2, withMacrosDisabled = true) diff --git a/test/files/run/macro-typecheck-macrosdisabled2/Impls_Macros_1.scala b/test/files/run/macro-typecheck-macrosdisabled2/Impls_Macros_1.scala index 948c047351..1dbf5a1a87 100644 --- a/test/files/run/macro-typecheck-macrosdisabled2/Impls_Macros_1.scala +++ b/test/files/run/macro-typecheck-macrosdisabled2/Impls_Macros_1.scala @@ -18,7 +18,8 @@ object Macros { val rupkg = c.mirror.staticModule("scala.reflect.runtime.package") val rusym = build.selectTerm(rupkg, "universe") val NullaryMethodType(rutpe) = rusym.typeSignature - val ru = build.newFreeTerm("ru", rutpe, scala.reflect.runtime.universe) + val ru = build.newFreeTerm("ru", scala.reflect.runtime.universe) + build.setTypeSignature(ru, rutpe) val tree2 = Apply(Select(Ident(ru), newTermName("reify")), List(Apply(Select(Ident(newTermName("scala")), newTermName("Array")), List(Literal(Constant(2)))))) val ttree2 = c.typeCheck(tree2, withMacrosDisabled = true) diff --git a/test/files/run/macro-undetparams-consfromsls/Impls_Macros_1.scala b/test/files/run/macro-undetparams-consfromsls/Impls_Macros_1.scala index 3d350a50fa..bcbd12817b 100644 --- a/test/files/run/macro-undetparams-consfromsls/Impls_Macros_1.scala +++ b/test/files/run/macro-undetparams-consfromsls/Impls_Macros_1.scala @@ -2,13 +2,13 @@ import scala.reflect.runtime.universe._ import scala.reflect.macros.Context object Macros { - def cons_impl[A: c.AbsTypeTag](c: Context)(x: c.Expr[A], xs: c.Expr[List[A]]): c.Expr[List[A]] = c.universe.reify { - println("A = " + c.literal(implicitly[c.AbsTypeTag[A]].toString).splice) + def cons_impl[A: c.WeakTypeTag](c: Context)(x: c.Expr[A], xs: c.Expr[List[A]]): c.Expr[List[A]] = c.universe.reify { + println("A = " + c.literal(implicitly[c.WeakTypeTag[A]].toString).splice) x.splice :: xs.splice } - def nil_impl[B: c.AbsTypeTag](c: Context): c.Expr[List[B]] = c.universe.reify { - println("B = " + c.literal(implicitly[c.AbsTypeTag[B]].toString).splice) + def nil_impl[B: c.WeakTypeTag](c: Context): c.Expr[List[B]] = c.universe.reify { + println("B = " + c.literal(implicitly[c.WeakTypeTag[B]].toString).splice) Nil } diff --git a/test/files/run/macro-undetparams-macroitself.check b/test/files/run/macro-undetparams-macroitself.check index 1c1a785706..37226ec68d 100644 --- a/test/files/run/macro-undetparams-macroitself.check +++ b/test/files/run/macro-undetparams-macroitself.check @@ -1,2 +1,2 @@ TypeTag[Int]
-AbsTypeTag[String]
+WeakTypeTag[String]
diff --git a/test/files/run/macro-undetparams-macroitself/Impls_Macros_1.scala b/test/files/run/macro-undetparams-macroitself/Impls_Macros_1.scala index 081894cf52..0244273b6f 100644 --- a/test/files/run/macro-undetparams-macroitself/Impls_Macros_1.scala +++ b/test/files/run/macro-undetparams-macroitself/Impls_Macros_1.scala @@ -2,7 +2,7 @@ import scala.reflect.runtime.universe._ import scala.reflect.macros.Context object Macros { - def impl[T: c.AbsTypeTag](c: Context)(foo: c.Expr[T]): c.Expr[Unit] = c.universe.reify { println(c.literal(implicitly[c.AbsTypeTag[T]].toString).splice) } + def impl[T: c.WeakTypeTag](c: Context)(foo: c.Expr[T]): c.Expr[Unit] = c.universe.reify { println(c.literal(implicitly[c.WeakTypeTag[T]].toString).splice) } def foo[T](foo: T) = macro impl[T] }
\ No newline at end of file diff --git a/test/files/run/pure-args-byname-noinline.check b/test/files/run/pure-args-byname-noinline.check new file mode 100644 index 0000000000..a39c61eb64 --- /dev/null +++ b/test/files/run/pure-args-byname-noinline.check @@ -0,0 +1,12 @@ +2 +2 +2 +2 +List(1) +List() + +1 +1 +1 +1 +1 diff --git a/test/files/run/pure-args-byname-noinline.scala b/test/files/run/pure-args-byname-noinline.scala new file mode 100644 index 0000000000..5c5c8a7eb6 --- /dev/null +++ b/test/files/run/pure-args-byname-noinline.scala @@ -0,0 +1,33 @@ +object Test { + //Were affected by SI-6306 + def f[A](a: =>A) = println(a.toString) + def f1[A <: AnyVal](a: =>A) = println(a.toString) + def f1a[A <: AnyVal](a: =>A) = println(a.##) + def f2[A <: AnyRef](a: =>A) = println(a.toString) + def f2a[A <: String](a: =>A) = println(a.toString) + //Works + def f3[A](a: =>Seq[A]) = println(a.toString) + + def foo() = println(2) + def client(f: () => Unit) = {f(); f()} + def attempt2() { + val bar: () => Unit = foo _ + //The code causing SI-6306 was supposed to optimize code like this: + client(() => bar ()) + //to: + client(bar) + } + def main(args: Array[String]) { + attempt2() + f3(Seq(1)) + f3(Seq()) + f("") + f((1).toString) + f((1).##) + f1((1).##) + f2((1).toString) + f2a((1).toString) + } +} + +// vim: set ts=8 sw=2 et: diff --git a/test/files/run/reflection-java-annotations.check b/test/files/run/reflection-java-annotations.check new file mode 100644 index 0000000000..84cfd03358 --- /dev/null +++ b/test/files/run/reflection-java-annotations.check @@ -0,0 +1,22 @@ +Type in expressions to have them evaluated.
+Type :help for more information.
+
+scala>
+
+scala> import scala.reflect.runtime.universe._
+import scala.reflect.runtime.universe._
+
+scala> val sym = typeOf[Foo].typeSymbol
+sym: reflect.runtime.universe.Symbol = class Foo
+
+scala> sym.typeSignature
+res0: reflect.runtime.universe.Type = java.lang.Object{def <init>(): Foo}
+
+scala> sym.getAnnotations foreach (_.javaArgs)
+
+scala> println(sym.getAnnotations)
+List(ComplexAnnotation(v1 = 1, v10 = "hello", v101 = [101, 101], v102 = [102, 102], v103 = ['g', 'g'], v104 = [104, 104], v105 = [105L, 105L], v106 = [106.0, 106.0], v107 = [107.0, 107.0], v108 = [false, true], v11 = classOf[Foo], v110 = ["hello", "world"], v111 = [classOf[SimpleAnnotation], classOf[ComplexAnnotation]], v113 = [SimpleAnnotation(v1 = 21, v10 = "world2", v11 = classOf[ComplexAnnotation], v2 = 22, v3 = '\027', v4 = 24, v5 = 25L, v6 = 26.0, v7 = 27.0, v8 = false)], v13 = SimpleAnnotation(v1 = 11, v10 = "world1", v11 = classOf[SimpleAnnotation], v2 = 12, v3 = '\r', v4 = 14, v5 = 15L, v6 = 16.0, v7 = 17.0, v8 = false), v2 = 2, v3 = '\03', v4 = 4, v5 = 5L, v6 = 6.0, v7 = 7.0, v8 = false))
+
+scala>
+
+scala>
diff --git a/test/files/run/reflection-java-annotations.jar.desired.sha1 b/test/files/run/reflection-java-annotations.jar.desired.sha1 new file mode 100644 index 0000000000..430e7626e6 --- /dev/null +++ b/test/files/run/reflection-java-annotations.jar.desired.sha1 @@ -0,0 +1 @@ +c35876a529c6be33bdda7b3f48ac8ae800d2f36a ?reflection-java-annotations.jar diff --git a/test/files/run/reflection-java-annotations.scala b/test/files/run/reflection-java-annotations.scala new file mode 100644 index 0000000000..4a4fe2572d --- /dev/null +++ b/test/files/run/reflection-java-annotations.scala @@ -0,0 +1,20 @@ +import scala.tools.partest._ +import scala.tools.nsc.Settings + +object Test extends ReplTest { + def code = """ + import scala.reflect.runtime.universe._ + val sym = typeOf[Foo].typeSymbol + sym.typeSignature + sym.getAnnotations foreach (_.javaArgs) + println(sym.getAnnotations) + """ + + override def transformSettings(settings: Settings): Settings = { + val thisFile = testPath.jfile.getAbsolutePath + val javaCompiledAnnotationsJar = (thisFile stripSuffix "scala") + "jar" + val classpath = List(sys.props("partest.lib"), sys.props("partest.reflect"), sys.props("partest.comp"), javaCompiledAnnotationsJar) mkString sys.props("path.separator") + settings.processArguments(List("-cp", classpath), true) + settings + } +}
\ No newline at end of file diff --git a/test/files/run/reify_ann1a.scala b/test/files/run/reify_ann1a.scala index 754baef6b7..88b4191195 100644 --- a/test/files/run/reify_ann1a.scala +++ b/test/files/run/reify_ann1a.scala @@ -25,5 +25,5 @@ object Test extends App { println(ttree.toString) // test 3: import and compile - toolbox.runExpr(tree) + toolbox.eval(tree) }
\ No newline at end of file diff --git a/test/files/run/reify_ann1b.scala b/test/files/run/reify_ann1b.scala index eb00b4cb10..a8fb876023 100644 --- a/test/files/run/reify_ann1b.scala +++ b/test/files/run/reify_ann1b.scala @@ -25,5 +25,5 @@ object Test extends App { println(ttree.toString) // test 3: import and compile - toolbox.runExpr(tree) + toolbox.eval(tree) }
\ No newline at end of file diff --git a/test/files/run/reify_ann2a.scala b/test/files/run/reify_ann2a.scala index 9f901d86bd..b7e5833584 100644 --- a/test/files/run/reify_ann2a.scala +++ b/test/files/run/reify_ann2a.scala @@ -25,5 +25,5 @@ object Test extends App { println(ttree.toString) // test 3: import and compile - toolbox.runExpr(tree) + toolbox.eval(tree) }
\ No newline at end of file diff --git a/test/files/run/reify_ann3.scala b/test/files/run/reify_ann3.scala index cbf1e10063..662d58aaf3 100644 --- a/test/files/run/reify_ann3.scala +++ b/test/files/run/reify_ann3.scala @@ -19,5 +19,5 @@ object Test extends App { println(ttree.toString) // test 3: import and compile - toolbox.runExpr(tree) + toolbox.eval(tree) }
\ No newline at end of file diff --git a/test/files/run/reify_ann4.scala b/test/files/run/reify_ann4.scala index 58c8c2c521..a85e5e3625 100644 --- a/test/files/run/reify_ann4.scala +++ b/test/files/run/reify_ann4.scala @@ -23,5 +23,5 @@ object Test extends App { println(ttree.toString) // test 3: import and compile - toolbox.runExpr(tree) + toolbox.eval(tree) }
\ No newline at end of file diff --git a/test/files/run/reify_ann5.scala b/test/files/run/reify_ann5.scala index 801db07960..877360180c 100644 --- a/test/files/run/reify_ann5.scala +++ b/test/files/run/reify_ann5.scala @@ -20,5 +20,5 @@ object Test extends App { println(ttree.toString) // test 3: import and compile - toolbox.runExpr(tree) + toolbox.eval(tree) }
\ No newline at end of file diff --git a/test/files/run/reify_classfileann_a.scala b/test/files/run/reify_classfileann_a.scala index 0abb7b8154..1d51688e78 100644 --- a/test/files/run/reify_classfileann_a.scala +++ b/test/files/run/reify_classfileann_a.scala @@ -18,5 +18,5 @@ object Test extends App { println(ttree.toString) // test 3: import and compile - toolbox.runExpr(tree) + toolbox.eval(tree) }
\ No newline at end of file diff --git a/test/files/run/reify_classfileann_b.scala b/test/files/run/reify_classfileann_b.scala index 5ceb652a8b..ef19e9240b 100644 --- a/test/files/run/reify_classfileann_b.scala +++ b/test/files/run/reify_classfileann_b.scala @@ -22,5 +22,5 @@ object Test extends App { println(ttree.toString) // test 3: import and compile - toolbox.runExpr(tree) + toolbox.eval(tree) }
\ No newline at end of file diff --git a/test/files/run/reify_closure1.scala b/test/files/run/reify_closure1.scala index ce68975acc..af24a4b1e4 100644 --- a/test/files/run/reify_closure1.scala +++ b/test/files/run/reify_closure1.scala @@ -10,7 +10,7 @@ object Test extends App { }} val toolbox = cm.mkToolBox() - val dyn = toolbox.runExpr(fun.tree) + val dyn = toolbox.eval(fun.tree) dyn.asInstanceOf[Int => Int] } diff --git a/test/files/run/reify_closure2a.scala b/test/files/run/reify_closure2a.scala index cb53e7ffa8..7a2cdb5e17 100644 --- a/test/files/run/reify_closure2a.scala +++ b/test/files/run/reify_closure2a.scala @@ -10,7 +10,7 @@ object Test extends App { }} val toolbox = cm.mkToolBox() - val dyn = toolbox.runExpr(fun.tree) + val dyn = toolbox.eval(fun.tree) dyn.asInstanceOf[Int => Int] } diff --git a/test/files/run/reify_closure3a.scala b/test/files/run/reify_closure3a.scala index cf8c161afa..cb17c89501 100644 --- a/test/files/run/reify_closure3a.scala +++ b/test/files/run/reify_closure3a.scala @@ -12,7 +12,7 @@ object Test extends App { }} val toolbox = cm.mkToolBox() - val dyn = toolbox.runExpr(fun.tree) + val dyn = toolbox.eval(fun.tree) dyn.asInstanceOf[Int => Int] } diff --git a/test/files/run/reify_closure4a.scala b/test/files/run/reify_closure4a.scala index 1521295f16..23436e0763 100644 --- a/test/files/run/reify_closure4a.scala +++ b/test/files/run/reify_closure4a.scala @@ -12,7 +12,7 @@ object Test extends App { }} val toolbox = cm.mkToolBox() - val dyn = toolbox.runExpr(fun.tree) + val dyn = toolbox.eval(fun.tree) dyn.asInstanceOf[Int => Int] } diff --git a/test/files/run/reify_closure5a.scala b/test/files/run/reify_closure5a.scala index 84c2c08727..6b5089a4e5 100644 --- a/test/files/run/reify_closure5a.scala +++ b/test/files/run/reify_closure5a.scala @@ -10,7 +10,7 @@ object Test extends App { }} val toolbox = cm.mkToolBox() - val dyn = toolbox.runExpr(fun.tree) + val dyn = toolbox.eval(fun.tree) dyn.asInstanceOf[Int => Int] } diff --git a/test/files/run/reify_closure6.scala b/test/files/run/reify_closure6.scala index d007e80899..cba035132d 100644 --- a/test/files/run/reify_closure6.scala +++ b/test/files/run/reify_closure6.scala @@ -17,7 +17,7 @@ object Test extends App { }} val toolbox = cm.mkToolBox() - val dyn = toolbox.runExpr(fun.tree) + val dyn = toolbox.eval(fun.tree) dyn.asInstanceOf[Int => Int] } diff --git a/test/files/run/reify_closure7.scala b/test/files/run/reify_closure7.scala index 3d4956a724..2a7ce25e88 100644 --- a/test/files/run/reify_closure7.scala +++ b/test/files/run/reify_closure7.scala @@ -19,7 +19,7 @@ object Test extends App { if (clo == null) { val toolbox = cm.mkToolBox() - val dyn = toolbox.runExpr(fun.tree) + val dyn = toolbox.eval(fun.tree) clo = dyn.asInstanceOf[Int => Int] } diff --git a/test/files/run/reify_closure8a.scala b/test/files/run/reify_closure8a.scala index 8db3d38241..f303a7511c 100644 --- a/test/files/run/reify_closure8a.scala +++ b/test/files/run/reify_closure8a.scala @@ -9,7 +9,7 @@ object Test extends App { } val toolbox = cm.mkToolBox() - val dyn = toolbox.runExpr(new Foo(10).fun.tree) + val dyn = toolbox.eval(new Foo(10).fun.tree) val foo = dyn.asInstanceOf[Int] println(foo) }
\ No newline at end of file diff --git a/test/files/run/reify_closure8b.scala b/test/files/run/reify_closure8b.scala index 9cdc0e997f..c693cb490e 100644 --- a/test/files/run/reify_closure8b.scala +++ b/test/files/run/reify_closure8b.scala @@ -11,7 +11,7 @@ object Test extends App { } try { - val dyn = cm.mkToolBox().runExpr(new Foo(10).fun.tree) + val dyn = cm.mkToolBox().eval(new Foo(10).fun.tree) val foo = dyn.asInstanceOf[Int] println(foo) } catch { diff --git a/test/files/run/reify_closures10.scala b/test/files/run/reify_closures10.scala index 2d9b833851..a2740c8362 100644 --- a/test/files/run/reify_closures10.scala +++ b/test/files/run/reify_closures10.scala @@ -9,5 +9,5 @@ object Test extends App { val code = reify{println(x + y); x + y} val toolbox = cm.mkToolBox() - println(toolbox.runExpr(code.tree)) + println(toolbox.eval(code.tree)) }
\ No newline at end of file diff --git a/test/files/run/reify_copypaste1.scala b/test/files/run/reify_copypaste1.scala index 7eaa4fa7b5..c597b7af19 100644 --- a/test/files/run/reify_copypaste1.scala +++ b/test/files/run/reify_copypaste1.scala @@ -11,9 +11,9 @@ object Test extends App { val toolBox = currentMirror.mkToolBox(options = "-Yreify-copypaste") val reify = Select(Select(Select(Select(Ident(ScalaPackage), newTermName("reflect")), newTermName("runtime")), newTermName("universe")), newTermName("reify")) val reifee = Block(List(ValDef(Modifiers(LAZY), newTermName("x"), TypeTree(), Apply(Ident(ListModule), List(Literal(Constant(1)), Literal(Constant(2)))))), Ident(newTermName("x"))) - toolBox.runExpr(Apply(reify, List(reifee))) - val Block(List(tpeCopypaste), exprCopypaste @ ModuleDef(_, _, Template(_, _, (_ :: stats) :+ expr))) = toolBox.parseExpr(output.toString()) + toolBox.eval(Apply(reify, List(reifee))) + val Block(List(tpeCopypaste), exprCopypaste @ ModuleDef(_, _, Template(_, _, (_ :: stats) :+ expr))) = toolBox.parse(output.toString()) output.reset() - toolBox.runExpr(Block(stats, expr)) + toolBox.eval(Block(stats, expr)) stdout.println(output.toString) }
\ No newline at end of file diff --git a/test/files/run/reify_getter.scala b/test/files/run/reify_getter.scala index 26767603a0..cb04ddffde 100644 --- a/test/files/run/reify_getter.scala +++ b/test/files/run/reify_getter.scala @@ -13,6 +13,6 @@ object Test extends App { } val toolbox = cm.mkToolBox() - val evaluated = toolbox.runExpr(code.tree) + val evaluated = toolbox.eval(code.tree) println("evaluated = " + evaluated) }
\ No newline at end of file diff --git a/test/files/run/reify_metalevel_breach_+0_refers_to_1.scala b/test/files/run/reify_metalevel_breach_+0_refers_to_1.scala index 8ea92c511b..76f935ecd2 100644 --- a/test/files/run/reify_metalevel_breach_+0_refers_to_1.scala +++ b/test/files/run/reify_metalevel_breach_+0_refers_to_1.scala @@ -13,6 +13,6 @@ object Test extends App { }; val toolbox = cm.mkToolBox() - val evaluated = toolbox.runExpr(code.tree) + val evaluated = toolbox.eval(code.tree) println("evaluated = " + evaluated) }
\ No newline at end of file diff --git a/test/files/run/reify_metalevel_breach_-1_refers_to_0_a.scala b/test/files/run/reify_metalevel_breach_-1_refers_to_0_a.scala index 7ff4f84de0..e7c5cb71c1 100644 --- a/test/files/run/reify_metalevel_breach_-1_refers_to_0_a.scala +++ b/test/files/run/reify_metalevel_breach_-1_refers_to_0_a.scala @@ -11,6 +11,6 @@ object Test extends App { val code = reify{outer.eval.eval} val toolbox = cm.mkToolBox() - val evaluated = toolbox.runExpr(code.tree) + val evaluated = toolbox.eval(code.tree) println("evaluated = " + evaluated) }
\ No newline at end of file diff --git a/test/files/run/reify_metalevel_breach_-1_refers_to_0_b.scala b/test/files/run/reify_metalevel_breach_-1_refers_to_0_b.scala index 7f1f9d8478..770fcccd15 100644 --- a/test/files/run/reify_metalevel_breach_-1_refers_to_0_b.scala +++ b/test/files/run/reify_metalevel_breach_-1_refers_to_0_b.scala @@ -16,6 +16,6 @@ object Test extends App { } val toolbox = cm.mkToolBox() - val evaluated = toolbox.runExpr(code.tree) + val evaluated = toolbox.eval(code.tree) println("evaluated = " + evaluated) }
\ No newline at end of file diff --git a/test/files/run/reify_metalevel_breach_-1_refers_to_1.scala b/test/files/run/reify_metalevel_breach_-1_refers_to_1.scala index 65e0931b6e..32e7e9003b 100644 --- a/test/files/run/reify_metalevel_breach_-1_refers_to_1.scala +++ b/test/files/run/reify_metalevel_breach_-1_refers_to_1.scala @@ -13,6 +13,6 @@ object Test extends App { }; val toolbox = cm.mkToolBox() - val evaluated = toolbox.runExpr(code.tree) + val evaluated = toolbox.eval(code.tree) println("evaluated = " + evaluated) }
\ No newline at end of file diff --git a/test/files/run/reify_nested_inner_refers_to_global.scala b/test/files/run/reify_nested_inner_refers_to_global.scala index f45c1daed9..877222f5bf 100644 --- a/test/files/run/reify_nested_inner_refers_to_global.scala +++ b/test/files/run/reify_nested_inner_refers_to_global.scala @@ -12,6 +12,6 @@ object Test extends App { } val toolbox = cm.mkToolBox() - val evaluated = toolbox.runExpr(code.tree) + val evaluated = toolbox.eval(code.tree) println("evaluated = " + evaluated) }
\ No newline at end of file diff --git a/test/files/run/reify_nested_inner_refers_to_local.scala b/test/files/run/reify_nested_inner_refers_to_local.scala index 4a3d8bb02b..703474e07e 100644 --- a/test/files/run/reify_nested_inner_refers_to_local.scala +++ b/test/files/run/reify_nested_inner_refers_to_local.scala @@ -12,6 +12,6 @@ object Test extends App { }; val toolbox = cm.mkToolBox() - val evaluated = toolbox.runExpr(code.tree) + val evaluated = toolbox.eval(code.tree) println("evaluated = " + evaluated) }
\ No newline at end of file diff --git a/test/files/run/reify_nested_outer_refers_to_global.scala b/test/files/run/reify_nested_outer_refers_to_global.scala index b628975e59..e40c569ce6 100644 --- a/test/files/run/reify_nested_outer_refers_to_global.scala +++ b/test/files/run/reify_nested_outer_refers_to_global.scala @@ -14,6 +14,6 @@ object Test extends App { } val toolbox = cm.mkToolBox() - val evaluated = toolbox.runExpr(code.tree) + val evaluated = toolbox.eval(code.tree) println("evaluated = " + evaluated) }
\ No newline at end of file diff --git a/test/files/run/reify_nested_outer_refers_to_local.scala b/test/files/run/reify_nested_outer_refers_to_local.scala index 80564fa9a2..12147c51da 100644 --- a/test/files/run/reify_nested_outer_refers_to_local.scala +++ b/test/files/run/reify_nested_outer_refers_to_local.scala @@ -14,6 +14,6 @@ object Test extends App { }; val toolbox = cm.mkToolBox() - val evaluated = toolbox.runExpr(code.tree) + val evaluated = toolbox.eval(code.tree) println("evaluated = " + evaluated) }
\ No newline at end of file diff --git a/test/files/run/reify_newimpl_26.check b/test/files/run/reify_newimpl_26.check index c006cb7ffb..5996f3b322 100644 --- a/test/files/run/reify_newimpl_26.check +++ b/test/files/run/reify_newimpl_26.check @@ -5,16 +5,16 @@ scala> scala> def foo[T]{
import scala.reflect.runtime.universe._
- val tt = implicitly[AbsTypeTag[List[T]]]
+ val tt = implicitly[WeakTypeTag[List[T]]]
println(tt)
}
<console>:9: free type: Ident(newTypeName("T")) defined by foo in <console>:7:16
- val tt = implicitly[AbsTypeTag[List[T]]]
+ val tt = implicitly[WeakTypeTag[List[T]]]
^
foo: [T]=> Unit
scala> foo[Int]
-AbsTypeTag[scala.List[T]]
+WeakTypeTag[scala.List[T]]
scala>
diff --git a/test/files/run/reify_newimpl_26.scala b/test/files/run/reify_newimpl_26.scala index a12d8a2970..af74d60e8b 100644 --- a/test/files/run/reify_newimpl_26.scala +++ b/test/files/run/reify_newimpl_26.scala @@ -5,7 +5,7 @@ object Test extends ReplTest { def code = """ def foo[T]{ import scala.reflect.runtime.universe._ - val tt = implicitly[AbsTypeTag[List[T]]] + val tt = implicitly[WeakTypeTag[List[T]]] println(tt) } foo[Int] diff --git a/test/files/run/reify_newimpl_45.scala b/test/files/run/reify_newimpl_45.scala index cbae0839b2..2a6c68d441 100644 --- a/test/files/run/reify_newimpl_45.scala +++ b/test/files/run/reify_newimpl_45.scala @@ -9,7 +9,7 @@ object Test extends App { println(code.tree.freeTypes) val T = code.tree.freeTypes(0) val tree = code.tree.substituteSymbols(List(T), List(definitions.StringClass)) - cm.mkToolBox().runExpr(tree) + cm.mkToolBox().eval(tree) } new C[String] diff --git a/test/files/run/reify_printf.scala b/test/files/run/reify_printf.scala index 07e99781e3..272856b962 100644 --- a/test/files/run/reify_printf.scala +++ b/test/files/run/reify_printf.scala @@ -14,7 +14,7 @@ object Test extends App { val toolbox = cm.mkToolBox() val tree = tree_printf(reify("hello %s").tree, reify("world").tree) - val evaluated = toolbox.runExpr(tree) + val evaluated = toolbox.eval(tree) assert(output.toString() == "hello world", output.toString() +" == hello world") /* diff --git a/test/files/run/reify_typerefs_1a.scala b/test/files/run/reify_typerefs_1a.scala index 53033e210c..2e961f171d 100644 --- a/test/files/run/reify_typerefs_1a.scala +++ b/test/files/run/reify_typerefs_1a.scala @@ -13,6 +13,6 @@ object Test extends App { }; val toolbox = cm.mkToolBox() - val evaluated = toolbox.runExpr(code.tree) + val evaluated = toolbox.eval(code.tree) println("evaluated = " + evaluated) }
\ No newline at end of file diff --git a/test/files/run/reify_typerefs_1b.scala b/test/files/run/reify_typerefs_1b.scala index 12604454ed..88bb864820 100644 --- a/test/files/run/reify_typerefs_1b.scala +++ b/test/files/run/reify_typerefs_1b.scala @@ -13,6 +13,6 @@ object Test extends App { }; val toolbox = cm.mkToolBox() - val evaluated = toolbox.runExpr(code.tree) + val evaluated = toolbox.eval(code.tree) println("evaluated = " + evaluated) }
\ No newline at end of file diff --git a/test/files/run/reify_typerefs_2a.scala b/test/files/run/reify_typerefs_2a.scala index ffc3dfc942..3a1db1d80f 100644 --- a/test/files/run/reify_typerefs_2a.scala +++ b/test/files/run/reify_typerefs_2a.scala @@ -15,6 +15,6 @@ object Test extends App { }; val toolbox = cm.mkToolBox() - val evaluated = toolbox.runExpr(code.tree) + val evaluated = toolbox.eval(code.tree) println("evaluated = " + evaluated) }
\ No newline at end of file diff --git a/test/files/run/reify_typerefs_2b.scala b/test/files/run/reify_typerefs_2b.scala index f5d1633d79..50082aa8d2 100644 --- a/test/files/run/reify_typerefs_2b.scala +++ b/test/files/run/reify_typerefs_2b.scala @@ -15,6 +15,6 @@ object Test extends App { }; val toolbox = cm.mkToolBox() - val evaluated = toolbox.runExpr(code.tree) + val evaluated = toolbox.eval(code.tree) println("evaluated = " + evaluated) }
\ No newline at end of file diff --git a/test/files/run/reify_typerefs_3a.scala b/test/files/run/reify_typerefs_3a.scala index 67b2c2d8aa..682d6f01ac 100644 --- a/test/files/run/reify_typerefs_3a.scala +++ b/test/files/run/reify_typerefs_3a.scala @@ -15,6 +15,6 @@ object Test extends App { }; val toolbox = cm.mkToolBox() - val evaluated = toolbox.runExpr(code.tree) + val evaluated = toolbox.eval(code.tree) println("evaluated = " + evaluated) }
\ No newline at end of file diff --git a/test/files/run/reify_typerefs_3b.scala b/test/files/run/reify_typerefs_3b.scala index 41a0a667e2..c85072f55f 100644 --- a/test/files/run/reify_typerefs_3b.scala +++ b/test/files/run/reify_typerefs_3b.scala @@ -15,6 +15,6 @@ object Test extends App { }; val toolbox = cm.mkToolBox() - val evaluated = toolbox.runExpr(code.tree) + val evaluated = toolbox.eval(code.tree) println("evaluated = " + evaluated) }
\ No newline at end of file diff --git a/test/files/run/t1195-new.scala b/test/files/run/t1195-new.scala index 4edfb5073f..0f62b140c9 100644 --- a/test/files/run/t1195-new.scala +++ b/test/files/run/t1195-new.scala @@ -9,7 +9,7 @@ object Test { val g1 = g() val h1 = h() - def m[T: TypeTag](x: T) = println(typeOf[T] + ", underlying = " + typeOf[T].typeSymbol.typeSignature) + def m[T: WeakTypeTag](x: T) = println(weakTypeOf[T] + ", underlying = " + weakTypeOf[T].typeSymbol.typeSignature) def main(args: Array[String]): Unit = { m(f) diff --git a/test/files/run/t2296a.check b/test/files/run/t2296a.check deleted file mode 100644 index f75aec9d81..0000000000 --- a/test/files/run/t2296a.check +++ /dev/null @@ -1,2 +0,0 @@ -J.foo() -J.foo() diff --git a/test/files/run/t2296b.check b/test/files/run/t2296b.check deleted file mode 100644 index f75aec9d81..0000000000 --- a/test/files/run/t2296b.check +++ /dev/null @@ -1,2 +0,0 @@ -J.foo() -J.foo() diff --git a/test/files/run/t4813.scala b/test/files/run/t4813.scala new file mode 100644 index 0000000000..6d48ca8758 --- /dev/null +++ b/test/files/run/t4813.scala @@ -0,0 +1,37 @@ +import collection.mutable._ +import reflect._ + + +object Test extends App { + def runTest[T, U](col: T)(clone: T => U)(mod: T => Unit)(implicit ct: ClassTag[T]): Unit = { + val cloned = clone(col) + assert(cloned == col, s"cloned should be equal to original. $cloned != $col") + mod(col) + assert(cloned != col, s"cloned should not modify when original does: $ct") + } + + // Seqs + runTest(ArrayBuffer(1,2,3))(_.clone) { buf => buf transform (_ + 1) } + runTest(ArraySeq(1,2,3))(_.clone) { buf => buf transform (_ + 1) } + runTest(Buffer(1,2,3))(_.clone) { buf => buf transform (_ + 1) } + runTest(DoubleLinkedList(1,2,3))(_.clone) { buf => buf transform (_ + 1) } + runTest(IndexedSeq(1,2,3))(_.clone) { buf => buf transform (_ + 1) } + runTest(LinearSeq(1,2,3))(_.clone) { buf => buf transform (_ + 1) } + runTest(LinkedList(1,2,3))(_.clone) { buf => buf transform (_ + 1) } + runTest(ListBuffer(1,2,3))(_.clone) { buf => buf transform (_ + 1) } + runTest(MutableList(1,2,3))(_.clone) { buf => buf transform (_ + 1) } + runTest(Queue(1,2,3))(_.clone) { buf => buf transform (_ + 1) } + runTest(Stack(1,2,3))(_.clone) { buf => buf transform (_ + 1) } + + // Sets + runTest(BitSet(1,2,3))(_.clone) { buf => buf add 4 } + runTest(HashSet(1,2,3))(_.clone) { buf => buf add 4 } + runTest(Set(1,2,3))(_.clone) { buf => buf add 4 } + runTest(SortedSet(1,2,3))(_.clone) { buf => buf add 4 } + runTest(TreeSet(1,2,3))(_.clone) { buf => buf add 4 } + + // Maps + runTest(HashMap(1->1,2->2,3->3))(_.clone) { buf => buf put (4,4) } + runTest(WeakHashMap(1->1,2->2,3->3))(_.clone) { buf => buf put (4,4) } +} + diff --git a/test/files/run/t5229_2.scala b/test/files/run/t5229_2.scala index 75d7204911..f059b09772 100644 --- a/test/files/run/t5229_2.scala +++ b/test/files/run/t5229_2.scala @@ -13,6 +13,6 @@ object Test extends App { }; val toolbox = cm.mkToolBox() - val evaluated = toolbox.runExpr(code.tree) + val evaluated = toolbox.eval(code.tree) println("evaluated = " + evaluated) }
\ No newline at end of file diff --git a/test/files/run/t5230.scala b/test/files/run/t5230.scala index 5cd67766b4..f6a7817c0b 100644 --- a/test/files/run/t5230.scala +++ b/test/files/run/t5230.scala @@ -13,6 +13,6 @@ object Test extends App { }; val toolbox = cm.mkToolBox() - val evaluated = toolbox.runExpr(code.tree) + val evaluated = toolbox.eval(code.tree) println("evaluated = " + evaluated) }
\ No newline at end of file diff --git a/test/files/run/t5266_1.scala b/test/files/run/t5266_1.scala index ee7ea6d335..7bf73ac988 100644 --- a/test/files/run/t5266_1.scala +++ b/test/files/run/t5266_1.scala @@ -10,6 +10,6 @@ object Test extends App { }; val toolbox = cm.mkToolBox() - val evaluated = toolbox.runExpr(code.tree) + val evaluated = toolbox.eval(code.tree) println("evaluated = " + evaluated) }
\ No newline at end of file diff --git a/test/files/run/t5266_2.scala b/test/files/run/t5266_2.scala index ca16f656ee..9b33910d00 100644 --- a/test/files/run/t5266_2.scala +++ b/test/files/run/t5266_2.scala @@ -11,6 +11,6 @@ object Test extends App { }; val toolbox = cm.mkToolBox() - val evaluated = toolbox.runExpr(code.tree) + val evaluated = toolbox.eval(code.tree) println("evaluated = " + evaluated) }
\ No newline at end of file diff --git a/test/files/run/t5334_1.scala b/test/files/run/t5334_1.scala index 2b6418990a..3aeb7e4437 100644 --- a/test/files/run/t5334_1.scala +++ b/test/files/run/t5334_1.scala @@ -11,5 +11,5 @@ object Test extends App { }; val toolbox = cm.mkToolBox() - println(toolbox.runExpr(code.tree)) + println(toolbox.eval(code.tree)) }
\ No newline at end of file diff --git a/test/files/run/t5334_2.scala b/test/files/run/t5334_2.scala index 815f78f951..64ee1e0acd 100644 --- a/test/files/run/t5334_2.scala +++ b/test/files/run/t5334_2.scala @@ -11,5 +11,5 @@ object Test extends App { }; val toolbox = cm.mkToolBox() - println(toolbox.runExpr(code.tree)) + println(toolbox.eval(code.tree)) }
\ No newline at end of file diff --git a/test/files/run/t6114.scala b/test/files/run/t6114.scala new file mode 100644 index 0000000000..cb880ece00 --- /dev/null +++ b/test/files/run/t6114.scala @@ -0,0 +1,61 @@ +object Test extends App { + def testList = { + val list = new java.util.ArrayList[Int] + list.add(1) + list.add(2) + list.add(3) + import scala.collection.JavaConverters._ + val next = list.asScala ++ List(4,5,6) + assert(next != list.asScala) + + val raw = list.asScala + val cloned = raw.clone + list.add(1) + assert(raw != cloned) + } + def testSet = { + val set = new java.util.HashSet[Int] + set.add(1) + set.add(2) + set.add(3) + import scala.collection.JavaConverters._ + val next = set.asScala ++ Set(4,5,6) + assert(next != set.asScala) + + val raw = set.asScala + val cloned = raw.clone + set.add(4) + assert(raw != cloned) + } + def testMap = { + val map = new java.util.HashMap[Int,Int] + map.put(1,1) + map.put(2,2) + map.put(3,3) + import scala.collection.JavaConverters._ + val next = map.asScala ++ Map(4->4,5->5,6->6) + assert(next != map.asScala) + + val raw = map.asScala + val cloned = raw.clone + map.put(4,4) + assert(raw != cloned) + } + + def testCollection = { + val list: java.util.Collection[Int] = new java.util.ArrayDeque[Int] + list.add(1) + list.add(2) + list.add(3) + import scala.collection.JavaConverters._ + val next = list.asScala ++ List(4,5,6) + assert(next != list.asScala) + + // Note: Clone is hidden at this level, so no overriden cloning. + } + + testList + testSet + testMap + testCollection +} diff --git a/test/files/run/t6199-toolbox.scala b/test/files/run/t6199-toolbox.scala index 14670f8e21..89015f5878 100644 --- a/test/files/run/t6199-toolbox.scala +++ b/test/files/run/t6199-toolbox.scala @@ -4,5 +4,5 @@ import scala.tools.reflect.ToolBox object Test extends App { val tb = cm.mkToolBox() - println(tb.runExpr(Literal(Constant(())))) + println(tb.eval(Literal(Constant(())))) }
\ No newline at end of file diff --git a/test/files/run/t6271.scala b/test/files/run/t6271.scala new file mode 100644 index 0000000000..8ebf7ad8b5 --- /dev/null +++ b/test/files/run/t6271.scala @@ -0,0 +1,32 @@ +object Test extends App { + def filterIssue = { + val viewed : Iterable[Iterable[Int]] = List(List(0).view).view + val filtered = viewed flatMap { x => List( x filter (_ > 0) ) } + filtered.iterator.toIterable.flatten + } + def takenIssue = { + val viewed : Iterable[Iterable[Int]] = List(List(0).view).view + val filtered = viewed flatMap { x => List( x take 0 ) } + filtered.iterator.toIterable.flatten + } + def droppedIssue = { + val viewed : Iterable[Iterable[Int]] = List(List(0).view).view + val filtered = viewed flatMap { x => List( x drop 1 ) } + filtered.iterator.toIterable.flatten + } + def flatMappedIssue = { + val viewed : Iterable[Iterable[Int]] = List(List(0).view).view + val filtered = viewed flatMap { x => List( x flatMap (_ => List()) ) } + filtered.iterator.toIterable.flatten + } + def slicedIssue = { + val viewed : Iterable[Iterable[Int]] = List(List(0).view).view + val filtered = viewed flatMap { x => List( x slice (2,3) ) } + filtered.iterator.toIterable.flatten + } + filterIssue + takenIssue + droppedIssue + flatMappedIssue + slicedIssue +} diff --git a/test/files/run/t6318_derived.check b/test/files/run/t6318_derived.check new file mode 100644 index 0000000000..ad43b6579b --- /dev/null +++ b/test/files/run/t6318_derived.check @@ -0,0 +1,3 @@ +Some(X)
+true
+Some(X)
diff --git a/test/files/run/t6318_derived.scala b/test/files/run/t6318_derived.scala new file mode 100644 index 0000000000..ccdc18daee --- /dev/null +++ b/test/files/run/t6318_derived.scala @@ -0,0 +1,15 @@ +import scala.reflect.{ClassTag, classTag} + +object Test extends App { + def test[T: ClassTag](x: T) { + println(classTag[T].runtimeClass.isAssignableFrom(x.getClass)) + println(classTag[T].unapply(x)) + } + + class X(val x: Int) extends AnyVal { override def toString = "X" } + val x = new X(1) + // the commented line crashes because of SI-6326 + //println(classTag[X].runtimeClass.isAssignableFrom(x.getClass)) + println(classTag[X].unapply(x)) + test(x) +}
\ No newline at end of file diff --git a/test/files/run/t6318_primitives.check b/test/files/run/t6318_primitives.check new file mode 100644 index 0000000000..bb474c3bdc --- /dev/null +++ b/test/files/run/t6318_primitives.check @@ -0,0 +1,36 @@ +true
+Some(1)
+false
+None
+true
+Some(1)
+false
+None
+true
+Some()
+false
+None
+true
+Some(1)
+false
+None
+true
+Some(1)
+false
+None
+true
+Some(1.0)
+false
+None
+true
+Some(1.0)
+false
+None
+true
+Some(true)
+false
+None
+true
+Some(())
+false
+None
diff --git a/test/files/run/t6318_primitives.scala b/test/files/run/t6318_primitives.scala new file mode 100644 index 0000000000..30f27120b3 --- /dev/null +++ b/test/files/run/t6318_primitives.scala @@ -0,0 +1,71 @@ +import scala.reflect.{ClassTag, classTag} + +object Test extends App { + def test[T: ClassTag](x: T) { + println(classTag[T].runtimeClass.isAssignableFrom(x.getClass)) + println(classTag[T].unapply(x)) + } + + { + val x = 1.toByte + println(ClassTag.Byte.runtimeClass.isAssignableFrom(x.getClass)) + println(ClassTag.Byte.unapply(x)) + test(x) + } + + { + val x = 1.toShort + println(ClassTag.Short.runtimeClass.isAssignableFrom(x.getClass)) + println(ClassTag.Short.unapply(x)) + test(x) + } + + { + val x = 1.toChar + println(ClassTag.Char.runtimeClass.isAssignableFrom(x.getClass)) + println(ClassTag.Char.unapply(x)) + test(x) + } + + { + val x = 1.toInt + println(ClassTag.Int.runtimeClass.isAssignableFrom(x.getClass)) + println(ClassTag.Int.unapply(x)) + test(x) + } + + { + val x = 1.toLong + println(ClassTag.Long.runtimeClass.isAssignableFrom(x.getClass)) + println(ClassTag.Long.unapply(x)) + test(x) + } + + { + val x = 1.toFloat + println(ClassTag.Float.runtimeClass.isAssignableFrom(x.getClass)) + println(ClassTag.Float.unapply(x)) + test(x) + } + + { + val x = 1.toDouble + println(ClassTag.Double.runtimeClass.isAssignableFrom(x.getClass)) + println(ClassTag.Double.unapply(x)) + test(x) + } + + { + val x = true + println(ClassTag.Boolean.runtimeClass.isAssignableFrom(x.getClass)) + println(ClassTag.Boolean.unapply(x)) + test(x) + } + + { + val x = () + println(ClassTag.Unit.runtimeClass.isAssignableFrom(x.getClass)) + println(ClassTag.Unit.unapply(x)) + test(x) + } +}
\ No newline at end of file diff --git a/test/files/run/t6323b.check b/test/files/run/t6323b.check new file mode 100644 index 0000000000..80b6176178 --- /dev/null +++ b/test/files/run/t6323b.check @@ -0,0 +1 @@ +cannot reflect value a, because it's a member of a weak type Test
diff --git a/test/files/run/t6323b.scala b/test/files/run/t6323b.scala new file mode 100644 index 0000000000..f530ac3ecc --- /dev/null +++ b/test/files/run/t6323b.scala @@ -0,0 +1,21 @@ +import scala.reflect.runtime.universe._ +import scala.reflect.runtime.{currentMirror => m} +import scala.reflect.runtime.{universe => u} + +object Test extends App { + locally { + try { + case class Test(a:String,b:List[Int]) + + val lookAtMe = m.reflect(Test("a",List(5))) + val value = u.weakTypeOf[Test] + val members = value.members + val member = value.members.filter(_.name.encoded == "a") + val aAccessor = lookAtMe.reflectMethod(member.head.asMethod) + val thisShouldBeA = aAccessor.apply() + println(thisShouldBeA) + } catch { + case ScalaReflectionException(msg) => println(msg) + } + } +}
\ No newline at end of file diff --git a/test/files/run/t6327.check b/test/files/run/t6327.check new file mode 100644 index 0000000000..f7bacac931 --- /dev/null +++ b/test/files/run/t6327.check @@ -0,0 +1,4 @@ +A +A +A +A diff --git a/test/files/run/t6327.scala b/test/files/run/t6327.scala new file mode 100644 index 0000000000..7683101f14 --- /dev/null +++ b/test/files/run/t6327.scala @@ -0,0 +1,22 @@ +import language._ + +object Test extends App { + + case class R[+T](s: String) { def x() = println(s) } + + // Implicits in contention; StringR is nested to avoid ambiguity + object R { implicit val StringR = R[String]("A") } + implicit val Default = R[Any]("B") + + class B() extends Dynamic { + def selectDynamic[T](f: String)(implicit r: R[T]): Unit = r.x() + } + + val b = new B() + + // These should all produce the same output, but they don't + b.selectDynamic[String]("baz") + b.baz[String] + val c = b.selectDynamic[String]("baz") + val d = b.baz[String] +} diff --git a/test/files/run/t6331.check b/test/files/run/t6331.check new file mode 100644 index 0000000000..9bf3f7823a --- /dev/null +++ b/test/files/run/t6331.check @@ -0,0 +1,23 @@ + () == () + true == true + true != false + false != true + 0.toByte == 0.toByte + 0.toByte != 1.toByte + 0.toShort == 0.toShort + 0.toShort != 1.toShort + 0 == 0 + 0 != 1 + 0L == 0L + 0L != 1L + 0.0f == 0.0f + 0.0f != -0.0f + -0.0f != 0.0f + NaNf == NaNf + 0.0d == 0.0d + 0.0d != -0.0d + -0.0d != 0.0d + NaNd == NaNd + 0 != 0.0d + 0 != 0L + 0.0d != 0.0f diff --git a/test/files/run/t6331.scala b/test/files/run/t6331.scala new file mode 100644 index 0000000000..4e43a7686e --- /dev/null +++ b/test/files/run/t6331.scala @@ -0,0 +1,71 @@ +import scala.tools.partest._ +import java.io._ +import scala.tools.nsc._ +import scala.tools.nsc.util.CommandLineParser +import scala.tools.nsc.{Global, Settings, CompilerCommand} +import scala.tools.nsc.reporters.ConsoleReporter + +// Test of Constant#equals, which must must account for floating point intricacies. +object Test extends DirectTest { + + override def code = "" + + override def show() { + val global = newCompiler() + import global._ + + def check(c1: Any, c2: Any): Unit = { + val const1 = Constant(c1) + val const2 = Constant(c2) + val equal = const1 == const2 + def show(a: Any) = "" + a + (a match { + case _: Byte => ".toByte" + case _: Short => ".toShort" + case _: Long => "L" + case _: Float => "f" + case _: Double => "d" + case _ => "" + }) + val op = if (equal) "==" else "!=" + println(f"${show(c1)}%12s $op ${show(c2)}") + + val hash1 = const1.hashCode + val hash2 = const2.hashCode + val hashesEqual = hash1 == hash2 + val hashBroken = equal && !hashesEqual + if (hashBroken) println(f"$hash1%12s != $hash2 // hash codes differ for equal objects!!") + } + + check((), ()) + + check(true, true) + check(true, false) + check(false, true) + + check(0.toByte, 0.toByte) + check(0.toByte, 1.toByte) + + check(0.toShort, 0.toShort) + check(0.toShort, 1.toShort) + + check(0, 0) + check(0, 1) + + check(0L, 0L) + check(0L, 1L) + + check(0f, 0f) + check(0f, -0f) + check(-0f, 0f) + check(Float.NaN, Float.NaN) + + check(0d, 0d) + check(0d, -0d) + check(-0d, 0d) + check(Double.NaN, Double.NaN) + + check(0, 0d) + check(0, 0L) + check(0d, 0f) + } +} diff --git a/test/files/run/t6331b.check b/test/files/run/t6331b.check new file mode 100644 index 0000000000..6ca09e3814 --- /dev/null +++ b/test/files/run/t6331b.check @@ -0,0 +1,30 @@ +trace> if (Test.this.t) + -0.0 +else + 0.0 +res: Double = -0.0 + +trace> if (Test.this.t) + 0.0 +else + -0.0 +res: Double = 0.0 + +trace> Test.this.intercept.apply[Any](if (scala.this.Predef.???) + -0.0 +else + 0.0) +res: Any = class scala.NotImplementedError + +trace> Test.this.intercept.apply[Any](if (scala.this.Predef.???) + 0.0 +else + 0.0) +res: Any = class scala.NotImplementedError + +trace> Test.this.intercept.apply[Any](if (scala.this.Predef.???) + () +else + ()) +res: Any = class scala.NotImplementedError + diff --git a/test/files/run/t6331b.scala b/test/files/run/t6331b.scala new file mode 100644 index 0000000000..f966abea51 --- /dev/null +++ b/test/files/run/t6331b.scala @@ -0,0 +1,20 @@ +import scala.tools.partest._ +import java.io._ +import scala.tools.nsc._ +import scala.tools.nsc.util.CommandLineParser +import scala.tools.nsc.{Global, Settings, CompilerCommand} +import scala.tools.nsc.reporters.ConsoleReporter + +import scala.tools.partest.trace +import scala.util.control.Exception._ + + +object Test extends App { + def intercept = allCatch.withApply(_.getClass) + val t: Boolean = true + trace(if (t) -0d else 0d) + trace(if (t) 0d else -0d) + trace(intercept(if (???) -0d else 0d)) + trace(intercept(if (???) 0d else 0d)) + trace(intercept(if (???) () else ())) +} diff --git a/test/files/run/t6333.scala b/test/files/run/t6333.scala new file mode 100644 index 0000000000..266d95ce69 --- /dev/null +++ b/test/files/run/t6333.scala @@ -0,0 +1,29 @@ +object Test extends App { + import util.Try + + val a = "apple" + def fail: String = throw new Exception("Fail!") + def argh: Try[String] = throw new Exception("Argh!") + + // No throw tests + def tryMethods(expr: => String): Unit = { + Try(expr) orElse argh + Try(expr).transform(_ => argh, _ => argh) + Try(expr).recoverWith { case e if (a == fail) => Try(a) } + Try(expr).recoverWith { case _ => argh } + Try(expr).getOrElse(a) + // TODO - Fail getOrElse? + Try(expr) orElse argh + Try(expr) orElse Try(a) + Try(expr) map (_ => fail) + Try(expr) map (_ => a) + Try(expr) flatMap (_ => argh) + Try(expr) flatMap (_ => Try(a)) + Try(expr) filter (_ => throw new Exception("O NOES")) + Try(expr) filter (_ => true) + Try(expr) recover { case _ => fail } + Try(expr).failed + } + tryMethods(a) + tryMethods(fail) +} diff --git a/test/files/run/toolbox_console_reporter.scala b/test/files/run/toolbox_console_reporter.scala index c5b788550e..a57dea38a8 100644 --- a/test/files/run/toolbox_console_reporter.scala +++ b/test/files/run/toolbox_console_reporter.scala @@ -5,7 +5,7 @@ object Test extends App { // todo. and isn't affected by Console.setOut employed by partest to intercept output //val toolbox = mkToolBox(frontEnd = mkConsoleFrontEnd(), options = "-deprecation") - //toolbox.runExpr(reify{ + //toolbox.eval(reify{ // object Utils { // @deprecated("test", "2.10.0") // def foo { println("hello") } diff --git a/test/files/run/toolbox_default_reporter_is_silent.scala b/test/files/run/toolbox_default_reporter_is_silent.scala index 5f3269b6fa..4bd7a646b0 100644 --- a/test/files/run/toolbox_default_reporter_is_silent.scala +++ b/test/files/run/toolbox_default_reporter_is_silent.scala @@ -5,7 +5,7 @@ import scala.tools.reflect.ToolBox object Test extends App { val toolbox = cm.mkToolBox() - toolbox.runExpr(reify{ + toolbox.eval(reify{ object Utils { @deprecated("test", "2.10.0") def foo { println("hello") } diff --git a/test/files/run/toolbox_silent_reporter.scala b/test/files/run/toolbox_silent_reporter.scala index 915734e6ad..15f559d605 100644 --- a/test/files/run/toolbox_silent_reporter.scala +++ b/test/files/run/toolbox_silent_reporter.scala @@ -5,7 +5,7 @@ import scala.tools.reflect.ToolBox object Test extends App { val toolbox = cm.mkToolBox(options = "-deprecation") - toolbox.runExpr(reify{ + toolbox.eval(reify{ object Utils { @deprecated("test", "2.10.0") def foo { println("hello") } diff --git a/test/files/run/toolbox_typecheck_macrosdisabled.check b/test/files/run/toolbox_typecheck_macrosdisabled.check index 9cf101c69d..4d253f31fc 100644 --- a/test/files/run/toolbox_typecheck_macrosdisabled.check +++ b/test/files/run/toolbox_typecheck_macrosdisabled.check @@ -1,32 +1,41 @@ -{
- val $u: ru.type = ru;
- val $m: $u.Mirror = ru.rootMirror;
- $u.Expr.apply[Int(2)]($m, {
- final class $treecreator1 extends TreeCreator {
- def <init>(): $treecreator1 = {
- $treecreator1.super.<init>();
- ()
- };
- def apply[U <: scala.reflect.base.Universe with Singleton]($m$untyped: scala.reflect.base.MirrorOf[U]): U#Tree = {
- val $u: U = $m$untyped.universe;
- val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror];
- $u.Literal.apply($u.Constant.apply(2))
- }
- };
- new $treecreator1()
- })($u.TypeTag.apply[Int(2)]($m, {
- final class $typecreator2 extends TypeCreator {
- def <init>(): $typecreator2 = {
- $typecreator2.super.<init>();
- ()
- };
- def apply[U <: scala.reflect.base.Universe with Singleton]($m$untyped: scala.reflect.base.MirrorOf[U]): U#Type = {
- val $u: U = $m$untyped.universe;
- val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror];
- $u.ConstantType.apply($u.Constant.apply(2))
- }
- };
- new $typecreator2()
- }))
-}
-ru.reify[Int](2)
+{ + val $u: ru.type = ru; + val $m: $u.Mirror = ru.runtimeMirror({ + final class $anon extends scala.AnyRef { + def <init>(): anonymous class $anon = { + $anon.super.<init>(); + () + }; + () + }; + new $anon() +}.getClass().getClassLoader()); + $u.Expr.apply[Int(2)]($m, { + final class $treecreator1 extends TreeCreator { + def <init>(): $treecreator1 = { + $treecreator1.super.<init>(); + () + }; + def apply[U <: scala.reflect.base.Universe with Singleton]($m$untyped: scala.reflect.base.MirrorOf[U]): U#Tree = { + val $u: U = $m$untyped.universe; + val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror]; + $u.Literal.apply($u.Constant.apply(2)) + } + }; + new $treecreator1() + })($u.TypeTag.apply[Int(2)]($m, { + final class $typecreator2 extends TypeCreator { + def <init>(): $typecreator2 = { + $typecreator2.super.<init>(); + () + }; + def apply[U <: scala.reflect.base.Universe with Singleton]($m$untyped: scala.reflect.base.MirrorOf[U]): U#Type = { + val $u: U = $m$untyped.universe; + val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror]; + $u.ConstantType.apply($u.Constant.apply(2)) + } + }; + new $typecreator2() + })) +} +ru.reify[Int](2) diff --git a/test/files/run/toolbox_typecheck_macrosdisabled.scala b/test/files/run/toolbox_typecheck_macrosdisabled.scala index bcbd637e02..51eb63f294 100644 --- a/test/files/run/toolbox_typecheck_macrosdisabled.scala +++ b/test/files/run/toolbox_typecheck_macrosdisabled.scala @@ -3,12 +3,17 @@ import scala.reflect.runtime.{universe => ru} import scala.reflect.runtime.{currentMirror => cm} import scala.tools.reflect.ToolBox +// Note: If you're looking at this test and you don't know why, you may +// have accidentally changed the way type tags reify. If so, validate +// that your changes are accurate and update the check file. + object Test extends App { val toolbox = cm.mkToolBox() val rupkg = cm.staticModule("scala.reflect.runtime.package") val rusym = build.selectTerm(rupkg, "universe") val NullaryMethodType(rutpe) = rusym.typeSignature - val ru = build.newFreeTerm("ru", rutpe, scala.reflect.runtime.universe) + val ru = build.newFreeTerm("ru", scala.reflect.runtime.universe) + build.setTypeSignature(ru, rutpe) val tree1 = Apply(Select(Ident(ru), newTermName("reify")), List(Literal(Constant(2)))) val ttree1 = toolbox.typeCheck(tree1, withMacrosDisabled = false) @@ -17,4 +22,4 @@ object Test extends App { val tree2 = Apply(Select(Ident(ru), newTermName("reify")), List(Literal(Constant(2)))) val ttree2 = toolbox.typeCheck(tree2, withMacrosDisabled = true) println(ttree2) -}
\ No newline at end of file +} diff --git a/test/files/run/toolbox_typecheck_macrosdisabled2.check b/test/files/run/toolbox_typecheck_macrosdisabled2.check index d344e33180..149c3def12 100644 --- a/test/files/run/toolbox_typecheck_macrosdisabled2.check +++ b/test/files/run/toolbox_typecheck_macrosdisabled2.check @@ -1,32 +1,41 @@ -{
- val $u: ru.type = ru;
- val $m: $u.Mirror = ru.rootMirror;
- $u.Expr.apply[Array[Int]]($m, {
- final class $treecreator1 extends TreeCreator {
- def <init>(): $treecreator1 = {
- $treecreator1.super.<init>();
- ()
- };
- def apply[U <: scala.reflect.base.Universe with Singleton]($m$untyped: scala.reflect.base.MirrorOf[U]): U#Tree = {
- val $u: U = $m$untyped.universe;
- val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror];
- $u.Apply.apply($u.Select.apply($u.Select.apply($u.build.Ident($m.staticPackage("scala")), $u.newTermName("Array")), $u.newTermName("apply")), scala.collection.immutable.List.apply[$u.Literal]($u.Literal.apply($u.Constant.apply(2))))
- }
- };
- new $treecreator1()
- })($u.TypeTag.apply[Array[Int]]($m, {
- final class $typecreator2 extends TypeCreator {
- def <init>(): $typecreator2 = {
- $typecreator2.super.<init>();
- ()
- };
- def apply[U <: scala.reflect.base.Universe with Singleton]($m$untyped: scala.reflect.base.MirrorOf[U]): U#Type = {
- val $u: U = $m$untyped.universe;
- val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror];
- $u.TypeRef.apply($u.ThisType.apply($m.staticPackage("scala").asModule.moduleClass), $m.staticClass("scala.Array"), scala.collection.immutable.List.apply[$u.Type]($m.staticClass("scala.Int").asType.toTypeConstructor))
- }
- };
- new $typecreator2()
- }))
-}
-ru.reify[Array[Int]](scala.Array.apply(2))
+{ + val $u: ru.type = ru; + val $m: $u.Mirror = ru.runtimeMirror({ + final class $anon extends scala.AnyRef { + def <init>(): anonymous class $anon = { + $anon.super.<init>(); + () + }; + () + }; + new $anon() +}.getClass().getClassLoader()); + $u.Expr.apply[Array[Int]]($m, { + final class $treecreator1 extends TreeCreator { + def <init>(): $treecreator1 = { + $treecreator1.super.<init>(); + () + }; + def apply[U <: scala.reflect.base.Universe with Singleton]($m$untyped: scala.reflect.base.MirrorOf[U]): U#Tree = { + val $u: U = $m$untyped.universe; + val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror]; + $u.Apply.apply($u.Select.apply($u.Select.apply($u.build.Ident($m.staticPackage("scala")), $u.newTermName("Array")), $u.newTermName("apply")), scala.collection.immutable.List.apply[$u.Literal]($u.Literal.apply($u.Constant.apply(2)))) + } + }; + new $treecreator1() + })($u.TypeTag.apply[Array[Int]]($m, { + final class $typecreator2 extends TypeCreator { + def <init>(): $typecreator2 = { + $typecreator2.super.<init>(); + () + }; + def apply[U <: scala.reflect.base.Universe with Singleton]($m$untyped: scala.reflect.base.MirrorOf[U]): U#Type = { + val $u: U = $m$untyped.universe; + val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror]; + $u.TypeRef.apply($u.ThisType.apply($m.staticPackage("scala").asModule.moduleClass), $m.staticClass("scala.Array"), scala.collection.immutable.List.apply[$u.Type]($m.staticClass("scala.Int").asType.toTypeConstructor)) + } + }; + new $typecreator2() + })) +} +ru.reify[Array[Int]](scala.Array.apply(2)) diff --git a/test/files/run/toolbox_typecheck_macrosdisabled2.scala b/test/files/run/toolbox_typecheck_macrosdisabled2.scala index 51493ffc1c..74fd09d9fd 100644 --- a/test/files/run/toolbox_typecheck_macrosdisabled2.scala +++ b/test/files/run/toolbox_typecheck_macrosdisabled2.scala @@ -3,12 +3,17 @@ import scala.reflect.runtime.{universe => ru} import scala.reflect.runtime.{currentMirror => cm} import scala.tools.reflect.ToolBox +// Note: If you're looking at this test and you don't know why, you may +// have accidentally changed the way type tags reify. If so, validate +// that your changes are accurate and update the check file. + object Test extends App { val toolbox = cm.mkToolBox() val rupkg = cm.staticModule("scala.reflect.runtime.package") val rusym = build.selectTerm(rupkg, "universe") val NullaryMethodType(rutpe) = rusym.typeSignature - val ru = build.newFreeTerm("ru", rutpe, scala.reflect.runtime.universe) + val ru = build.newFreeTerm("ru", scala.reflect.runtime.universe) + build.setTypeSignature(ru, rutpe) val tree1 = Apply(Select(Ident(ru), newTermName("reify")), List(Apply(Select(Ident(newTermName("scala")), newTermName("Array")), List(Literal(Constant(2)))))) val ttree1 = toolbox.typeCheck(tree1, withMacrosDisabled = false) diff --git a/test/files/pos/t2868.cmds b/test/flaky/pos/t2868.cmds index ed8124a9e0..ed8124a9e0 100644 --- a/test/files/pos/t2868.cmds +++ b/test/flaky/pos/t2868.cmds diff --git a/test/files/pos/t2868/Jann.java b/test/flaky/pos/t2868/Jann.java index f5b68de7b0..f5b68de7b0 100644 --- a/test/files/pos/t2868/Jann.java +++ b/test/flaky/pos/t2868/Jann.java diff --git a/test/files/pos/t2868/Nest.java b/test/flaky/pos/t2868/Nest.java index 53652291ad..53652291ad 100644 --- a/test/files/pos/t2868/Nest.java +++ b/test/flaky/pos/t2868/Nest.java diff --git a/test/files/pos/t2868/pick_1.scala b/test/flaky/pos/t2868/pick_1.scala index a211687432..a211687432 100644 --- a/test/files/pos/t2868/pick_1.scala +++ b/test/flaky/pos/t2868/pick_1.scala diff --git a/test/files/pos/t2868/t2868_src_2.scala b/test/flaky/pos/t2868/t2868_src_2.scala index f11ef0fae2..f11ef0fae2 100644 --- a/test/files/pos/t2868/t2868_src_2.scala +++ b/test/flaky/pos/t2868/t2868_src_2.scala diff --git a/test/pending/neg/reify_packed.scala b/test/pending/neg/reify_packed.scala index 2004e031d5..7bdaa41915 100644 --- a/test/pending/neg/reify_packed.scala +++ b/test/pending/neg/reify_packed.scala @@ -11,5 +11,5 @@ object Test extends App { }; val toolbox = cm.mkToolBox() - println(toolbox.runExpr(code.tree)) + println(toolbox.eval(code.tree)) }
\ No newline at end of file diff --git a/test/pending/pos/t3943/Outer_1.java b/test/pending/pos/t3943/Outer_1.java new file mode 100644 index 0000000000..56c8cc7f85 --- /dev/null +++ b/test/pending/pos/t3943/Outer_1.java @@ -0,0 +1,14 @@ +public class Outer_1<E> { + abstract class Inner { + abstract public void foo(E e); + } +} + +class Child extends Outer_1<String> { + // the implicit prefix for Inner is Outer<E> instead of Outer<String> + public Inner getInner() { + return new Inner() { + public void foo(String e) { System.out.println("meh "+e); } + }; + } +} diff --git a/test/pending/pos/t3943/test_2.scala b/test/pending/pos/t3943/test_2.scala new file mode 100644 index 0000000000..a19db8b226 --- /dev/null +++ b/test/pending/pos/t3943/test_2.scala @@ -0,0 +1,8 @@ +object Test extends App { + val x: Child = new Child + x.getInner.foo("meh") +// ^ +// error: type mismatch; +// found : java.lang.String("meh") +// required: E +} diff --git a/test/pending/run/macro-expand-implicit-macro-defeats-type-inference/Impls_1.scala b/test/pending/run/macro-expand-implicit-macro-defeats-type-inference/Impls_1.scala index 26d4a45fee..15bcb581c8 100644 --- a/test/pending/run/macro-expand-implicit-macro-defeats-type-inference/Impls_1.scala +++ b/test/pending/run/macro-expand-implicit-macro-defeats-type-inference/Impls_1.scala @@ -1,7 +1,7 @@ import scala.reflect.macros.Context object Impls { - def foo[T: c.AbsTypeTag](c: Context): c.Expr[List[T]] = c.universe.reify { + def foo[T: c.WeakTypeTag](c: Context): c.Expr[List[T]] = c.universe.reify { println("openImplicits are: " + c.literal(c.openImplicits.toString).splice) println("enclosingImplicits are: " + c.literal(c.enclosingImplicits.toString).splice) println("typetag is: " + c.literal(c.tag[T].toString).splice) diff --git a/test/pending/run/macro-expand-tparams-prefix-e1/Impls_1.scala b/test/pending/run/macro-expand-tparams-prefix-e1/Impls_1.scala index d6ebb907e5..26de70cc12 100644 --- a/test/pending/run/macro-expand-tparams-prefix-e1/Impls_1.scala +++ b/test/pending/run/macro-expand-tparams-prefix-e1/Impls_1.scala @@ -1,11 +1,11 @@ import scala.reflect.macros.{Context => Ctx} object Impls { - def foo[T, U: c.AbsTypeTag, V](c: Ctx)(implicit T: c.AbsTypeTag[T], V: c.AbsTypeTag[V]): c.Expr[Unit] = { + def foo[T, U: c.WeakTypeTag, V](c: Ctx)(implicit T: c.WeakTypeTag[T], V: c.WeakTypeTag[V]): c.Expr[Unit] = { import c.universe._ Block(List( Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(T.toString)))), - Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(implicitly[c.AbsTypeTag[U]].toString)))), + Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(implicitly[c.WeakTypeTag[U]].toString)))), Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(V.toString))))), Literal(Constant(()))) } diff --git a/test/pending/run/macro-expand-tparams-prefix-f1/Impls_1.scala b/test/pending/run/macro-expand-tparams-prefix-f1/Impls_1.scala index d6ebb907e5..26de70cc12 100644 --- a/test/pending/run/macro-expand-tparams-prefix-f1/Impls_1.scala +++ b/test/pending/run/macro-expand-tparams-prefix-f1/Impls_1.scala @@ -1,11 +1,11 @@ import scala.reflect.macros.{Context => Ctx} object Impls { - def foo[T, U: c.AbsTypeTag, V](c: Ctx)(implicit T: c.AbsTypeTag[T], V: c.AbsTypeTag[V]): c.Expr[Unit] = { + def foo[T, U: c.WeakTypeTag, V](c: Ctx)(implicit T: c.WeakTypeTag[T], V: c.WeakTypeTag[V]): c.Expr[Unit] = { import c.universe._ Block(List( Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(T.toString)))), - Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(implicitly[c.AbsTypeTag[U]].toString)))), + Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(implicitly[c.WeakTypeTag[U]].toString)))), Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(V.toString))))), Literal(Constant(()))) } diff --git a/test/pending/run/macro-reify-array/Macros_1.scala b/test/pending/run/macro-reify-array/Macros_1.scala index 99006c548a..f970be5caa 100644 --- a/test/pending/run/macro-reify-array/Macros_1.scala +++ b/test/pending/run/macro-reify-array/Macros_1.scala @@ -4,7 +4,7 @@ object Macros { def foo[T](s: String) = macro Impls.foo[T] object Impls { - def foo[T: c.AbsTypeTag](c: Ctx)(s: c.Expr[T]) = c.universe.reify { + def foo[T: c.WeakTypeTag](c: Ctx)(s: c.Expr[T]) = c.universe.reify { Array(s.splice) } } diff --git a/test/pending/run/macro-reify-tagful-b/Macros_1.scala b/test/pending/run/macro-reify-tagful-b/Macros_1.scala index a14187e8a7..59dbe7157b 100644 --- a/test/pending/run/macro-reify-tagful-b/Macros_1.scala +++ b/test/pending/run/macro-reify-tagful-b/Macros_1.scala @@ -4,7 +4,7 @@ object Macros { def foo[T](s: T) = macro Impls.foo[List[T]] object Impls { - def foo[T: c.AbsTypeTag](c: Ctx)(s: c.Expr[T]) = c.universe.reify { + def foo[T: c.WeakTypeTag](c: Ctx)(s: c.Expr[T]) = c.universe.reify { List(s.splice) } } diff --git a/test/pending/run/macro-reify-tagless-b/Test_2.scala b/test/pending/run/macro-reify-tagless-b/Test_2.scala index 4649963d05..ebd35ffe47 100644 --- a/test/pending/run/macro-reify-tagless-b/Test_2.scala +++ b/test/pending/run/macro-reify-tagless-b/Test_2.scala @@ -9,5 +9,5 @@ object Test extends App { val rhs = Apply(Select(Ident("Macros"), newTermName("foo")), List(Literal(Constant("hello world")))) val list = ValDef(NoMods, newTermName("list"), tpt, rhs) val tree = Block(list, Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Ident(list.name)))) - println(cm.mkToolBox().runExpr(tree)) + println(cm.mkToolBox().eval(tree)) } diff --git a/test/pending/run/reify_closure2b.scala b/test/pending/run/reify_closure2b.scala index 565bb03b2f..0f126c8c91 100644 --- a/test/pending/run/reify_closure2b.scala +++ b/test/pending/run/reify_closure2b.scala @@ -12,7 +12,7 @@ object Test extends App { } val toolbox = cm.mkToolBox() - val dyn = toolbox.runExpr(new Foo(y).fun.tree) + val dyn = toolbox.eval(new Foo(y).fun.tree) dyn.asInstanceOf[Int => Int] } diff --git a/test/pending/run/reify_closure3b.scala b/test/pending/run/reify_closure3b.scala index 0d806b148b..54ac52ba0b 100644 --- a/test/pending/run/reify_closure3b.scala +++ b/test/pending/run/reify_closure3b.scala @@ -14,7 +14,7 @@ object Test extends App { } val toolbox = cm.mkToolBox() - val dyn = toolbox.runExpr(new Foo(y).fun.tree) + val dyn = toolbox.eval(new Foo(y).fun.tree) dyn.asInstanceOf[Int => Int] } diff --git a/test/pending/run/reify_closure4b.scala b/test/pending/run/reify_closure4b.scala index 1a349de072..34f707e092 100644 --- a/test/pending/run/reify_closure4b.scala +++ b/test/pending/run/reify_closure4b.scala @@ -14,7 +14,7 @@ object Test extends App { } val toolbox = cm.mkToolBox() - val dyn = toolbox.runExpr(new Foo(y).fun.tree) + val dyn = toolbox.eval(new Foo(y).fun.tree) dyn.asInstanceOf[Int => Int] } diff --git a/test/pending/run/reify_closure5b.scala b/test/pending/run/reify_closure5b.scala index 3e5e1bd328..0e506bf7b5 100644 --- a/test/pending/run/reify_closure5b.scala +++ b/test/pending/run/reify_closure5b.scala @@ -12,7 +12,7 @@ object Test extends App { } val toolbox = cm.mkToolBox() - val dyn = toolbox.runExpr(new Foo(ys).fun.tree) + val dyn = toolbox.eval(new Foo(ys).fun.tree) dyn.asInstanceOf[Int => Int] } diff --git a/test/pending/run/reify_closure9a.scala b/test/pending/run/reify_closure9a.scala index dddfa3f6c2..f39ff1e2f3 100644 --- a/test/pending/run/reify_closure9a.scala +++ b/test/pending/run/reify_closure9a.scala @@ -10,7 +10,7 @@ object Test extends App { } val toolbox = cm.mkToolBox() - val dyn = toolbox.runExpr(new Foo(y).fun.tree) + val dyn = toolbox.eval(new Foo(y).fun.tree) dyn.asInstanceOf[Int] } diff --git a/test/pending/run/reify_closure9b.scala b/test/pending/run/reify_closure9b.scala index df9db9b806..a6920b4e02 100644 --- a/test/pending/run/reify_closure9b.scala +++ b/test/pending/run/reify_closure9b.scala @@ -10,7 +10,7 @@ object Test extends App { } val toolbox = cm.mkToolBox() - val dyn = toolbox.runExpr(new Foo(y).fun.tree) + val dyn = toolbox.eval(new Foo(y).fun.tree) dyn.asInstanceOf[Int] } diff --git a/test/pending/run/reify_closures11.scala b/test/pending/run/reify_closures11.scala index 4c21033cbc..9156208b40 100644 --- a/test/pending/run/reify_closures11.scala +++ b/test/pending/run/reify_closures11.scala @@ -10,7 +10,7 @@ object Test extends App { } val toolbox = cm.mkToolBox() - val dyn = toolbox.runExpr(fun().tree) + val dyn = toolbox.eval(fun().tree) val foo = dyn.asInstanceOf[Int] println(foo) }
\ No newline at end of file diff --git a/test/pending/run/reify_newimpl_09c.scala b/test/pending/run/reify_newimpl_09c.scala index e2f4a4923a..6bde36328e 100644 --- a/test/pending/run/reify_newimpl_09c.scala +++ b/test/pending/run/reify_newimpl_09c.scala @@ -14,7 +14,7 @@ object Test extends App { val code = foo[Int] println(code.tree.freeTypes) val W = code.tree.freeTypes(2) - cm.mkToolBox().runExpr(code.tree, Map(W -> definitions.IntTpe)) + cm.mkToolBox().eval(code.tree, Map(W -> definitions.IntTpe)) println(code.eval) } }
\ No newline at end of file diff --git a/test/pending/run/reify_newimpl_46.scala b/test/pending/run/reify_newimpl_46.scala index 239c53953b..d063be0486 100644 --- a/test/pending/run/reify_newimpl_46.scala +++ b/test/pending/run/reify_newimpl_46.scala @@ -8,7 +8,7 @@ object Test extends App { val code = reify{val x: T[String] = null; println("ima worx"); x}.tree println(code.freeTypes) val T = code.freeTypes(0) - cm.mkToolBox().runExpr(code, Map(T -> definitions.ListClass.asType)) + cm.mkToolBox().eval(code, Map(T -> definitions.ListClass.asType)) } new C[List] diff --git a/test/pending/run/reify_newimpl_53.scala b/test/pending/run/reify_newimpl_53.scala index a73a0b94cb..54fa4bec1d 100644 --- a/test/pending/run/reify_newimpl_53.scala +++ b/test/pending/run/reify_newimpl_53.scala @@ -11,7 +11,7 @@ object Test extends App { }.tree println(code.freeTypes) val T = code.freeTypes(0) - cm.mkToolBox().runExpr(code, Map(T -> definitions.StringClass.asType)) + cm.mkToolBox().eval(code, Map(T -> definitions.StringClass.asType)) } new C[String] |