diff options
Diffstat (limited to 'test/files')
66 files changed, 446 insertions, 23 deletions
diff --git a/test/files/neg/macro-divergence-controlled.check b/test/files/neg/macro-divergence-controlled.check new file mode 100644 index 0000000000..4876f7cf96 --- /dev/null +++ b/test/files/neg/macro-divergence-controlled.check @@ -0,0 +1,4 @@ +Test_2.scala:2: error: could not find implicit value for parameter e: Complex[Foo] + println(implicitly[Complex[Foo]]) + ^ +one error found diff --git a/test/files/neg/macro-divergence-controlled/Impls_Macros_1.scala b/test/files/neg/macro-divergence-controlled/Impls_Macros_1.scala new file mode 100644 index 0000000000..cdea3104a1 --- /dev/null +++ b/test/files/neg/macro-divergence-controlled/Impls_Macros_1.scala @@ -0,0 +1,23 @@ +import scala.reflect.macros.Context +import language.experimental.macros + +trait Complex[T] + +class Foo(val foo: Foo) + +object Complex { + def impl[T: c.WeakTypeTag](c: Context): c.Expr[Complex[T]] = { + import c.universe._ + val tpe = weakTypeOf[T] + for (f <- tpe.declarations.collect{case f: TermSymbol if f.isParamAccessor && !f.isMethod => f}) { + val trecur = appliedType(typeOf[Complex[_]], List(f.typeSignature)) + if (c.openImplicits.tail.exists(ic => ic._1 =:= trecur)) c.abort(c.enclosingPosition, "diverging implicit expansion. reported by a macro!") + val recur = c.inferImplicitValue(trecur, silent = true) + if (recur == EmptyTree) c.abort(c.enclosingPosition, s"couldn't synthesize $trecur") + } + c.literalNull + } + + implicit object ComplexString extends Complex[String] + implicit def genComplex[T]: Complex[T] = macro impl[T] +} diff --git a/test/files/neg/macro-divergence-controlled/Test_2.scala b/test/files/neg/macro-divergence-controlled/Test_2.scala new file mode 100644 index 0000000000..dcc4593335 --- /dev/null +++ b/test/files/neg/macro-divergence-controlled/Test_2.scala @@ -0,0 +1,3 @@ +object Test extends App { + println(implicitly[Complex[Foo]]) +}
\ No newline at end of file diff --git a/test/files/neg/stringinterpolation_macro-neg.check b/test/files/neg/stringinterpolation_macro-neg.check index 8986b899a3..457f497f2f 100644 --- a/test/files/neg/stringinterpolation_macro-neg.check +++ b/test/files/neg/stringinterpolation_macro-neg.check @@ -66,5 +66,5 @@ Note that implicit conversions are not applicable because they are ambiguous: ^ stringinterpolation_macro-neg.scala:30: error: illegal conversion character f"$s%i" - ^ + ^ 15 errors found diff --git a/test/files/neg/t5353.check b/test/files/neg/t5353.check deleted file mode 100644 index 75e2435600..0000000000 --- a/test/files/neg/t5353.check +++ /dev/null @@ -1,4 +0,0 @@ -t5353.scala:2: error: this type parameter must be specified - def f(x: Boolean) = if (x) Array("abc") else Array() - ^ -one error found diff --git a/test/files/neg/t5353.scala b/test/files/neg/t5353.scala deleted file mode 100644 index 1ee869aac1..0000000000 --- a/test/files/neg/t5353.scala +++ /dev/null @@ -1,3 +0,0 @@ -class A { - def f(x: Boolean) = if (x) Array("abc") else Array() -} diff --git a/test/files/neg/t5510.check b/test/files/neg/t5510.check index 04220e79bb..322a2f5e25 100644 --- a/test/files/neg/t5510.check +++ b/test/files/neg/t5510.check @@ -1,15 +1,15 @@ t5510.scala:2: error: unclosed string literal val s1 = s"xxx - ^ + ^ t5510.scala:3: error: unclosed string literal val s2 = s"xxx $x ^ t5510.scala:4: error: unclosed string literal val s3 = s"xxx $$ - ^ + ^ t5510.scala:5: error: unclosed string literal val s4 = ""s" - ^ + ^ t5510.scala:6: error: unclosed multi-line string literal val s5 = ""s""" $s1 $s2 s" ^ diff --git a/test/files/neg/t5856.check b/test/files/neg/t5856.check index ac49d4b9ac..08a61bdc07 100644 --- a/test/files/neg/t5856.check +++ b/test/files/neg/t5856.check @@ -1,6 +1,6 @@ t5856.scala:10: error: invalid string interpolation: `$$', `$'ident or `$'BlockExpr expected val s9 = s"$" - ^ + ^ t5856.scala:10: error: unclosed string literal val s9 = s"$" ^ diff --git a/test/files/neg/t696.check b/test/files/neg/t696a.check index ac26a864a5..490fc1a571 100644 --- a/test/files/neg/t696.check +++ b/test/files/neg/t696a.check @@ -1,4 +1,4 @@ -t696.scala:4: error: diverging implicit expansion for type TypeUtil0.Type[Any] +t696a.scala:4: error: diverging implicit expansion for type TypeUtil0.Type[Any] starting with method WithType in object TypeUtil0 as[Any](null); ^ diff --git a/test/files/neg/t696a.flags b/test/files/neg/t696a.flags new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/files/neg/t696a.flags diff --git a/test/files/neg/t696.scala b/test/files/neg/t696a.scala index a06a32141a..a06a32141a 100644 --- a/test/files/neg/t696.scala +++ b/test/files/neg/t696a.scala diff --git a/test/files/neg/t696b.check b/test/files/neg/t696b.check new file mode 100644 index 0000000000..fcdb5440d8 --- /dev/null +++ b/test/files/neg/t696b.check @@ -0,0 +1,9 @@ +t696b.scala:5: error: diverging implicit expansion for type TypeUtil0.Type[Any] +starting with method WithType in object TypeUtil0 + as[Any](null) + ^ +t696b.scala:6: error: diverging implicit expansion for type TypeUtil0.Type[X] +starting with method WithType in object TypeUtil0 + def foo[X]() = as[X](null) + ^ +two errors found diff --git a/test/files/neg/t696b.flags b/test/files/neg/t696b.flags new file mode 100644 index 0000000000..d564f2b1f8 --- /dev/null +++ b/test/files/neg/t696b.flags @@ -0,0 +1 @@ +-Xdivergence211
\ No newline at end of file diff --git a/test/files/neg/t696b.scala b/test/files/neg/t696b.scala new file mode 100644 index 0000000000..ca76f7ef6c --- /dev/null +++ b/test/files/neg/t696b.scala @@ -0,0 +1,7 @@ +object TypeUtil0 { + trait Type[+T] + implicit def WithType[S,T](implicit tpeS : Type[S], tpeT : Type[T]) : Type[S with T] = null + def as[T](x : Any)(implicit tpe : Type[T]) = null + as[Any](null) + def foo[X]() = as[X](null) +} diff --git a/test/files/neg/t7166.check b/test/files/neg/t7166.check new file mode 100644 index 0000000000..c87198cb27 --- /dev/null +++ b/test/files/neg/t7166.check @@ -0,0 +1,4 @@ +Test_2.scala:2: error: silent = true does work! + println(implicitly[Complex[Foo]]) + ^ +one error found diff --git a/test/files/neg/t7166/Impls_Macros_1.scala b/test/files/neg/t7166/Impls_Macros_1.scala new file mode 100644 index 0000000000..62a15657c3 --- /dev/null +++ b/test/files/neg/t7166/Impls_Macros_1.scala @@ -0,0 +1,26 @@ +import scala.reflect.macros.Context +import language.experimental.macros + +trait Complex[T] + +class Foo + +object Complex { + def impl[T: c.WeakTypeTag](c: Context): c.Expr[Complex[T]] = { + import c.universe._ + def shout(msg: String) = { + val cannotShutMeUp = c.asInstanceOf[scala.reflect.macros.runtime.Context].universe.currentRun.currentUnit.error _ + cannotShutMeUp(c.enclosingPosition.asInstanceOf[scala.reflect.internal.util.Position], msg) + } + try { + val complexOfT = appliedType(typeOf[Complex[_]], List(weakTypeOf[T])) + val infiniteRecursion = c.inferImplicitValue(complexOfT, silent = true) + shout("silent = true does work!") + } catch { + case ex: Exception => shout(ex.toString) + } + c.literalNull + } + + implicit def genComplex[T]: Complex[T] = macro impl[T] +} diff --git a/test/files/neg/t7166/Test_2.scala b/test/files/neg/t7166/Test_2.scala new file mode 100644 index 0000000000..dcc4593335 --- /dev/null +++ b/test/files/neg/t7166/Test_2.scala @@ -0,0 +1,3 @@ +object Test extends App { + println(implicitly[Complex[Foo]]) +}
\ No newline at end of file diff --git a/test/files/neg/t7325.check b/test/files/neg/t7325.check new file mode 100644 index 0000000000..709ab6db3e --- /dev/null +++ b/test/files/neg/t7325.check @@ -0,0 +1,19 @@ +t7325.scala:2: error: percent signs not directly following splicees must be escaped + println(f"%") + ^ +t7325.scala:4: error: percent signs not directly following splicees must be escaped + println(f"%%%") + ^ +t7325.scala:6: error: percent signs not directly following splicees must be escaped + println(f"%%%%%") + ^ +t7325.scala:16: error: wrong conversion string + println(f"${0}%") + ^ +t7325.scala:19: error: percent signs not directly following splicees must be escaped + println(f"${0}%%%d") + ^ +t7325.scala:21: error: percent signs not directly following splicees must be escaped + println(f"${0}%%%%%d") + ^ +6 errors found diff --git a/test/files/neg/t7325.scala b/test/files/neg/t7325.scala new file mode 100644 index 0000000000..adfd8dd47a --- /dev/null +++ b/test/files/neg/t7325.scala @@ -0,0 +1,25 @@ +object Test extends App { + println(f"%") + println(f"%%") + println(f"%%%") + println(f"%%%%") + println(f"%%%%%") + println(f"%%%%%%") + + println(f"%%n") + println(f"%%%n") + println(f"%%%%n") + println(f"%%%%%n") + println(f"%%%%%%n") + println(f"%%%%%%%n") + + println(f"${0}%") + println(f"${0}%d") + println(f"${0}%%d") + println(f"${0}%%%d") + println(f"${0}%%%%d") + println(f"${0}%%%%%d") + + println(f"${0}%n") + println(f"${0}%d%n") +}
\ No newline at end of file diff --git a/test/files/neg/t7441.check b/test/files/neg/t7441.check new file mode 100644 index 0000000000..f259457197 --- /dev/null +++ b/test/files/neg/t7441.check @@ -0,0 +1,6 @@ +t7441.scala:4: error: type mismatch; + found : Int(1) + required: List[Any] + def test = apply(1) + ^ +one error found diff --git a/test/files/neg/t7441.scala b/test/files/neg/t7441.scala new file mode 100644 index 0000000000..dad7421e3f --- /dev/null +++ b/test/files/neg/t7441.scala @@ -0,0 +1,7 @@ +object Test { + object Bar { + def apply(xs: List[Any]): Int = 0 + def test = apply(1) + } + implicit def foo = 1 +} diff --git a/test/files/neg/t5692a.check b/test/files/pos/t5692a.check index 7fbfb5dba7..7fbfb5dba7 100644 --- a/test/files/neg/t5692a.check +++ b/test/files/pos/t5692a.check diff --git a/test/files/neg/t5692a.flags b/test/files/pos/t5692a.flags index cd66464f2f..cd66464f2f 100644 --- a/test/files/neg/t5692a.flags +++ b/test/files/pos/t5692a.flags diff --git a/test/files/neg/t5692a/Macros_1.scala b/test/files/pos/t5692a/Macros_1.scala index 06b5a3de36..06b5a3de36 100644 --- a/test/files/neg/t5692a/Macros_1.scala +++ b/test/files/pos/t5692a/Macros_1.scala diff --git a/test/files/neg/t5692a/Test_2.scala b/test/files/pos/t5692a/Test_2.scala index 08d510cc6f..08d510cc6f 100644 --- a/test/files/neg/t5692a/Test_2.scala +++ b/test/files/pos/t5692a/Test_2.scala diff --git a/test/files/neg/t5692b.check b/test/files/pos/t5692b.check index 16796826b4..16796826b4 100644 --- a/test/files/neg/t5692b.check +++ b/test/files/pos/t5692b.check diff --git a/test/files/neg/t5692b.flags b/test/files/pos/t5692b.flags index cd66464f2f..cd66464f2f 100644 --- a/test/files/neg/t5692b.flags +++ b/test/files/pos/t5692b.flags diff --git a/test/files/neg/t5692b/Macros_1.scala b/test/files/pos/t5692b/Macros_1.scala index b28d19f903..b28d19f903 100644 --- a/test/files/neg/t5692b/Macros_1.scala +++ b/test/files/pos/t5692b/Macros_1.scala diff --git a/test/files/neg/t5692b/Test_2.scala b/test/files/pos/t5692b/Test_2.scala index 08d510cc6f..08d510cc6f 100644 --- a/test/files/neg/t5692b/Test_2.scala +++ b/test/files/pos/t5692b/Test_2.scala diff --git a/test/files/pos/t5692c.check b/test/files/pos/t5692c.check new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/files/pos/t5692c.check diff --git a/test/files/pos/t5692c.scala b/test/files/pos/t5692c.scala new file mode 100644 index 0000000000..fa5f0b2dcd --- /dev/null +++ b/test/files/pos/t5692c.scala @@ -0,0 +1,4 @@ +class C { + def foo[T: scala.reflect.ClassTag](xs: T*): Array[T] = ??? + foo() +}
\ No newline at end of file diff --git a/test/files/pos/t7426.scala b/test/files/pos/t7426.scala new file mode 100644 index 0000000000..8e42ad1812 --- /dev/null +++ b/test/files/pos/t7426.scala @@ -0,0 +1,3 @@ +class foo(x: Any) extends annotation.StaticAnnotation + +@foo(new AnyRef { }) trait A diff --git a/test/files/run/interpolation.scala b/test/files/run/interpolation.scala index f443bd5feb..14d9819348 100644 --- a/test/files/run/interpolation.scala +++ b/test/files/run/interpolation.scala @@ -13,7 +13,7 @@ object Test extends App { println(s"Best price: $f") println(f"Best price: $f%.2f") println(s"$f% discount included") - println(f"$f%3.2f% discount included") + println(f"$f%3.2f%% discount included") } test1(1) diff --git a/test/files/run/interpolationMultiline1.scala b/test/files/run/interpolationMultiline1.scala index 437aed44b0..db634e7775 100644 --- a/test/files/run/interpolationMultiline1.scala +++ b/test/files/run/interpolationMultiline1.scala @@ -13,7 +13,7 @@ object Test extends App { println(s"""Best price: $f""") println(f"""Best price: $f%.2f""") println(s"""$f% discount included""") - println(f"""$f%3.2f% discount included""") + println(f"""$f%3.2f%% discount included""") } test1(1) diff --git a/test/files/run/macro-divergence-spurious.check b/test/files/run/macro-divergence-spurious.check new file mode 100644 index 0000000000..19765bd501 --- /dev/null +++ b/test/files/run/macro-divergence-spurious.check @@ -0,0 +1 @@ +null diff --git a/test/files/run/macro-divergence-spurious/Impls_Macros_1.scala b/test/files/run/macro-divergence-spurious/Impls_Macros_1.scala new file mode 100644 index 0000000000..bc4a9fded7 --- /dev/null +++ b/test/files/run/macro-divergence-spurious/Impls_Macros_1.scala @@ -0,0 +1,23 @@ +import scala.reflect.macros.Context +import language.experimental.macros + +trait Complex[T] + +class Foo(val bar: Bar) +class Bar(val s: String) + +object Complex { + def impl[T: c.WeakTypeTag](c: Context): c.Expr[Complex[T]] = { + import c.universe._ + val tpe = weakTypeOf[T] + for (f <- tpe.declarations.collect{case f: TermSymbol if f.isParamAccessor && !f.isMethod => f}) { + val trecur = appliedType(typeOf[Complex[_]], List(f.typeSignature)) + val recur = c.inferImplicitValue(trecur, silent = true) + if (recur == EmptyTree) c.abort(c.enclosingPosition, s"couldn't synthesize $trecur") + } + c.literalNull + } + + implicit object ComplexString extends Complex[String] + implicit def genComplex[T]: Complex[T] = macro impl[T] +} diff --git a/test/files/run/macro-divergence-spurious/Test_2.scala b/test/files/run/macro-divergence-spurious/Test_2.scala new file mode 100644 index 0000000000..dcc4593335 --- /dev/null +++ b/test/files/run/macro-divergence-spurious/Test_2.scala @@ -0,0 +1,3 @@ +object Test extends App { + println(implicitly[Complex[Foo]]) +}
\ No newline at end of file diff --git a/test/files/run/macro-system-properties.check b/test/files/run/macro-system-properties.check new file mode 100644 index 0000000000..dce976df02 --- /dev/null +++ b/test/files/run/macro-system-properties.check @@ -0,0 +1,26 @@ +Type in expressions to have them evaluated. +Type :help for more information. + +scala> + +scala> import language.experimental._, reflect.macros.Context +import language.experimental._ +import reflect.macros.Context + +scala> object GrabContext { + def lastContext = Option(System.getProperties.get("lastContext").asInstanceOf[reflect.macros.runtime.Context]) + // System.properties lets you stash true globals (unlike statics which are classloader scoped) + def impl(c: Context)() = { System.getProperties.put("lastContext", c); c.literalUnit } + def grab() = macro impl + } +defined module GrabContext + +scala> object Test { class C(implicit a: Any) { GrabContext.grab } } +defined module Test + +scala> object Test { class C(implicit a: Any) { GrabContext.grab } } +defined module Test + +scala> + +scala> diff --git a/test/files/run/macro-system-properties.scala b/test/files/run/macro-system-properties.scala new file mode 100644 index 0000000000..e182defc81 --- /dev/null +++ b/test/files/run/macro-system-properties.scala @@ -0,0 +1,16 @@ +import scala.tools.nsc._ +import scala.tools.partest.ReplTest + +object Test extends ReplTest { + def code = """ + import language.experimental._, reflect.macros.Context + object GrabContext { + def lastContext = Option(System.getProperties.get("lastContext").asInstanceOf[reflect.macros.runtime.Context]) + // System.properties lets you stash true globals (unlike statics which are classloader scoped) + def impl(c: Context)() = { System.getProperties.put("lastContext", c); c.literalUnit } + def grab() = macro impl + } + object Test { class C(implicit a: Any) { GrabContext.grab } } + object Test { class C(implicit a: Any) { GrabContext.grab } } + """ +} diff --git a/test/files/run/t5527.check b/test/files/run/t5527.check index 1518168c51..36bee9bb55 100644 --- a/test/files/run/t5527.check +++ b/test/files/run/t5527.check @@ -1,4 +1,4 @@ -[[syntax trees at end of parser]] // newSource1 +[[syntax trees at end of parser]] // newSource1.scala package <empty> { object UselessComments extends scala.AnyRef { def <init>() = { diff --git a/test/files/run/t5603.check b/test/files/run/t5603.check index 5127d3c1c7..3f19a0a4b1 100644 --- a/test/files/run/t5603.check +++ b/test/files/run/t5603.check @@ -1,4 +1,4 @@ -[[syntax trees at end of parser]] // newSource1 +[[syntax trees at end of parser]] // newSource1.scala [0:241]package [0:0]<empty> { [0:82]abstract trait Greeting extends [15:82][83]scala.AnyRef { [15]def $init$() = [15]{ diff --git a/test/files/run/t5923a.check b/test/files/run/t5923a.check new file mode 100644 index 0000000000..7165b734ac --- /dev/null +++ b/test/files/run/t5923a.check @@ -0,0 +1,3 @@ +C(Int) +C(String) +C(Nothing) diff --git a/test/files/run/t5923a/Macros_1.scala b/test/files/run/t5923a/Macros_1.scala new file mode 100644 index 0000000000..6d21362c4d --- /dev/null +++ b/test/files/run/t5923a/Macros_1.scala @@ -0,0 +1,14 @@ +import scala.reflect.macros.Context +import language.experimental.macros + +case class C[T](t: String) +object C { + implicit def foo[T]: C[T] = macro Macros.impl[T] +} + +object Macros { + def impl[T: c.WeakTypeTag](c: Context) = { + import c.universe._ + reify(C[T](c.literal(weakTypeOf[T].toString).splice)) + } +}
\ No newline at end of file diff --git a/test/files/run/t5923a/Test_2.scala b/test/files/run/t5923a/Test_2.scala new file mode 100644 index 0000000000..001ff9aea8 --- /dev/null +++ b/test/files/run/t5923a/Test_2.scala @@ -0,0 +1,5 @@ +object Test extends App { + println(implicitly[C[Int]]) + println(implicitly[C[String]]) + println(implicitly[C[Nothing]]) +}
\ No newline at end of file diff --git a/test/files/run/t5923b.check b/test/files/run/t5923b.check new file mode 100644 index 0000000000..d56076f84e --- /dev/null +++ b/test/files/run/t5923b.check @@ -0,0 +1,3 @@ +class [Ljava.lang.Object; +class [Ljava.lang.Object; +class [Ljava.lang.Object; diff --git a/test/files/run/t5923b/Test.scala b/test/files/run/t5923b/Test.scala new file mode 100644 index 0000000000..7c2627462a --- /dev/null +++ b/test/files/run/t5923b/Test.scala @@ -0,0 +1,7 @@ +object Test extends App { + import scala.collection.generic.CanBuildFrom + val cbf = implicitly[CanBuildFrom[Nothing, Nothing, Array[Nothing]]] + println(cbf().result.getClass) + println(new Array[Nothing](0).getClass) + println(Array[Nothing]().getClass) +}
\ No newline at end of file diff --git a/test/files/run/t6028.check b/test/files/run/t6028.check index 94013efd36..613d25b075 100644 --- a/test/files/run/t6028.check +++ b/test/files/run/t6028.check @@ -1,4 +1,4 @@ -[[syntax trees at end of lambdalift]] // newSource1 +[[syntax trees at end of lambdalift]] // newSource1.scala package <empty> { class T extends Object { <paramaccessor> val T$$classParam: Int = _; diff --git a/test/files/run/t6288.check b/test/files/run/t6288.check index e6467edc95..e940975e44 100644 --- a/test/files/run/t6288.check +++ b/test/files/run/t6288.check @@ -1,4 +1,4 @@ -[[syntax trees at end of patmat]] // newSource1 +[[syntax trees at end of patmat]] // newSource1.scala [7]package [7]<empty> { [7]object Case3 extends [13][106]scala.AnyRef { [13]def <init>(): [13]Case3.type = [13]{ diff --git a/test/files/run/t6440.check b/test/files/run/t6440.check index 69c253eab4..806279fb74 100644 --- a/test/files/run/t6440.check +++ b/test/files/run/t6440.check @@ -1,4 +1,4 @@ -pos: source-newSource1,line-9,offset=109 bad symbolic reference. A signature in U.class refers to term pack1 +pos: source-newSource1.scala,line-9,offset=109 bad symbolic reference. A signature in U.class refers to term pack1 in package <root> which is not available. It may be completely missing from the current classpath, or the version on the classpath might be incompatible with the version used when compiling U.class. ERROR diff --git a/test/files/run/t6555.check b/test/files/run/t6555.check index 04117b7c2f..a18a8e8023 100644 --- a/test/files/run/t6555.check +++ b/test/files/run/t6555.check @@ -1,4 +1,4 @@ -[[syntax trees at end of specialize]] // newSource1 +[[syntax trees at end of specialize]] // newSource1.scala package <empty> { class Foo extends Object { def <init>(): Foo = { diff --git a/test/files/run/t7047.check b/test/files/run/t7047.check new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/files/run/t7047.check diff --git a/test/files/run/t7047/Impls_Macros_1.scala b/test/files/run/t7047/Impls_Macros_1.scala new file mode 100644 index 0000000000..2992e3efe4 --- /dev/null +++ b/test/files/run/t7047/Impls_Macros_1.scala @@ -0,0 +1,19 @@ +import scala.reflect.macros.Context +import language.experimental.macros + +class Foo + +object Macros { + def impl(c: Context) = { + import c.universe._ + try { + c.inferImplicitValue(typeOf[Foo], silent = false) + c.abort(c.enclosingPosition, "silent=false is not working") + } catch { + case _: Exception => + } + c.literalNull + } + + def foo = macro impl +}
\ No newline at end of file diff --git a/test/files/run/t7047/Test_2.scala b/test/files/run/t7047/Test_2.scala new file mode 100644 index 0000000000..acfddae942 --- /dev/null +++ b/test/files/run/t7047/Test_2.scala @@ -0,0 +1,3 @@ +object Test extends App { + Macros.foo +}
\ No newline at end of file diff --git a/test/files/run/t7271.check b/test/files/run/t7271.check new file mode 100644 index 0000000000..dcd828a307 --- /dev/null +++ b/test/files/run/t7271.check @@ -0,0 +1,12 @@ +[[syntax trees at end of parser]] // newSource1.scala +[0:91]package [0:0]<empty> { + [0:91]class C extends [8:91][91]scala.AnyRef { + [8]def <init>() = [8]{ + [8][8][8]super.<init>(); + [8]() + }; + [16:44]def quote = [28:44]<28:44><28:44>[28]StringContext([30:34]"foo", [40:44]"baz").s([35:39]this); + [51:85]def tripleQuote = [69:85]<69:85><69:85>[69]StringContext([71:75]"foo", [81:85]"baz").s([76:80]this) + } +} + diff --git a/test/files/run/t7271.scala b/test/files/run/t7271.scala new file mode 100644 index 0000000000..6fccf14d20 --- /dev/null +++ b/test/files/run/t7271.scala @@ -0,0 +1,34 @@ +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 + +object Test extends DirectTest { + + override def extraSettings: String = "-usejavacp -Xprint:parser -Ystop-after:parser -d " + testOutput.path + + override def code = """ + class C { + def quote = s"foo${this}baz" + def tripleQuote = s"foo${this}baz" + } + """.trim + + override def show(): Unit = { + // redirect err to out, for logging + val prevErr = System.err + System.setErr(System.out) + compile() + System.setErr(prevErr) + } + + override def newCompiler(args: String*): Global = { + + val settings = new Settings() + settings.Xprintpos.value = true + val command = new CompilerCommand((CommandLineParser tokenize extraSettings) ++ args.toList, settings) + new Global(command.settings, new ConsoleReporter(settings)) with interactive.RangePositions + } +} diff --git a/test/files/run/t7291a.check b/test/files/run/t7291a.check new file mode 100644 index 0000000000..126faa15b4 --- /dev/null +++ b/test/files/run/t7291a.check @@ -0,0 +1 @@ +conjure diff --git a/test/files/run/t7291a.flags b/test/files/run/t7291a.flags new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/files/run/t7291a.flags diff --git a/test/files/run/t7291a.scala b/test/files/run/t7291a.scala new file mode 100644 index 0000000000..4b7c4a4184 --- /dev/null +++ b/test/files/run/t7291a.scala @@ -0,0 +1,19 @@ +trait Fooable[T] +object Fooable { + implicit def conjure[T]: Fooable[T] = { + println("conjure") + new Fooable[T]{} + } + +} + +object Test { + implicit def traversable[T, Coll[_] <: Traversable[_]](implicit +elem: Fooable[T]): Fooable[Coll[T]] = { + println("traversable") + new Fooable[Coll[T]]{} + } + def main(args: Array[String]) { + implicitly[Fooable[List[Any]]] + } +} diff --git a/test/files/run/t7291b.check b/test/files/run/t7291b.check new file mode 100644 index 0000000000..c07ba986a3 --- /dev/null +++ b/test/files/run/t7291b.check @@ -0,0 +1,2 @@ +conjure +traversable diff --git a/test/files/run/t7291b.flags b/test/files/run/t7291b.flags new file mode 100644 index 0000000000..d564f2b1f8 --- /dev/null +++ b/test/files/run/t7291b.flags @@ -0,0 +1 @@ +-Xdivergence211
\ No newline at end of file diff --git a/test/files/run/t7291b.scala b/test/files/run/t7291b.scala new file mode 100644 index 0000000000..30c4261a81 --- /dev/null +++ b/test/files/run/t7291b.scala @@ -0,0 +1,19 @@ +trait Fooable[T] +object Fooable { + implicit def conjure[T]: Fooable[T] = { + println("conjure") + new Fooable[T]{} + } + +} + +object Test { + implicit def traversable[T, Coll[_] <: Traversable[_]](implicit +elem: Fooable[T]): Fooable[Coll[T]] = { + println("traversable") + new Fooable[Coll[T]]{} + } + def main(args: Array[String]) { + implicitly[Fooable[List[Any]]] + } +} diff --git a/test/files/run/t7325.check b/test/files/run/t7325.check new file mode 100644 index 0000000000..3c7652f42c --- /dev/null +++ b/test/files/run/t7325.check @@ -0,0 +1,19 @@ +% +%% +%%% +%n +% + +%%n +%% + +%%%n +%%% + +0 +0%d +0%%d +0 + +0 + diff --git a/test/files/run/t7325.scala b/test/files/run/t7325.scala new file mode 100644 index 0000000000..26f6bc6ef7 --- /dev/null +++ b/test/files/run/t7325.scala @@ -0,0 +1,25 @@ +object Test extends App { + // println(f"%") + println(f"%%") + // println(f"%%%") + println(f"%%%%") + // println(f"%%%%%") + println(f"%%%%%%") + + println(f"%%n") + println(f"%%%n") + println(f"%%%%n") + println(f"%%%%%n") + println(f"%%%%%%n") + println(f"%%%%%%%n") + + // println(f"${0}%") + println(f"${0}%d") + println(f"${0}%%d") + // println(f"${0}%%%d") + println(f"${0}%%%%d") + // println(f"${0}%%%%%d") + + println(f"${0}%n") + println(f"${0}%d%n") +}
\ No newline at end of file diff --git a/test/files/run/t7398.scala b/test/files/run/t7398.scala new file mode 100644 index 0000000000..e4090f7db3 --- /dev/null +++ b/test/files/run/t7398.scala @@ -0,0 +1,31 @@ +import scala.tools.partest._ + +object Test extends CompilerTest { + import global._ + + def javaVersion = scala.util.Properties.javaVersion + def isJavaEight = javaVersion startsWith "1.8" + // This way we auto-pass on non-java8 since there's nothing to check + override lazy val units = { + val res: List[CompilationUnit] = if (isJavaEight) javaCompilationUnits(global)(defaultMethodSource) else Nil + val word = if (isJavaEight) "Attempting" else "Skipping" + log(s"$word java8-specific test under java version $javaVersion") + res + } + + private def defaultMethodSource = """ +public interface Iterator<E> { + boolean hasNext(); + E next(); + default void remove() { + throw new UnsupportedOperationException("remove"); + } + default void forEachRemaining(Consumer<? super E> action) { + throw new UnsupportedOperationException("forEachRemaining"); + } +} + """ + + // We're only checking we can parse it. + def check(source: String, unit: global.CompilationUnit): Unit = () +} diff --git a/test/files/run/typetags_without_scala_reflect_typetag_lookup.check b/test/files/run/typetags_without_scala_reflect_typetag_lookup.check index 8c558ced60..84e5435afe 100644 --- a/test/files/run/typetags_without_scala_reflect_typetag_lookup.check +++ b/test/files/run/typetags_without_scala_reflect_typetag_lookup.check @@ -1,2 +1,2 @@ -pos: source-newSource1,line-9,offset=466 could not find implicit value for evidence parameter of type reflect.runtime.package.universe.TypeTag[Int] ERROR +pos: source-newSource1.scala,line-9,offset=466 could not find implicit value for evidence parameter of type reflect.runtime.package.universe.TypeTag[Int] ERROR diff --git a/test/files/run/typetags_without_scala_reflect_typetag_manifest_interop.check b/test/files/run/typetags_without_scala_reflect_typetag_manifest_interop.check index acfecce628..8c9d07d836 100644 --- a/test/files/run/typetags_without_scala_reflect_typetag_manifest_interop.check +++ b/test/files/run/typetags_without_scala_reflect_typetag_manifest_interop.check @@ -1,2 +1,2 @@ -pos: source-newSource1,line-9,offset=479 No Manifest available for App.this.T. ERROR +pos: source-newSource1.scala,line-9,offset=479 No Manifest available for App.this.T. ERROR |