diff options
author | Lukas Rytz <lukas.rytz@gmail.com> | 2014-09-02 16:33:48 +0200 |
---|---|---|
committer | Lukas Rytz <lukas.rytz@gmail.com> | 2014-09-02 16:33:48 +0200 |
commit | f196ee2ee7807f007d2397a4d6168800900ae7fa (patch) | |
tree | 475de2822a89d25217acc0b7ff0fbc7f3d798519 /test | |
parent | 61dbf4ac711094db38a4b2dfb853d88499c2b1a5 (diff) | |
parent | 01f2d279e84fda300176e83ee94c17c08ad1dc3f (diff) | |
download | scala-f196ee2ee7807f007d2397a4d6168800900ae7fa.tar.gz scala-f196ee2ee7807f007d2397a4d6168800900ae7fa.tar.bz2 scala-f196ee2ee7807f007d2397a4d6168800900ae7fa.zip |
Merge commit '01f2d27' into merge/2.11-to-2.12-is-it-really-sept-2-already-where-was-summer
Diffstat (limited to 'test')
52 files changed, 375 insertions, 33 deletions
diff --git a/test/files/jvm/varargs.check b/test/files/jvm/varargs.check index 8379befe93..986f98896a 100644 --- a/test/files/jvm/varargs.check +++ b/test/files/jvm/varargs.check @@ -1,3 +1,4 @@ 7 10 -19
\ No newline at end of file +19 +a diff --git a/test/files/jvm/varargs/JavaClass.java b/test/files/jvm/varargs/JavaClass.java index 9851e1b78b..6928ee5adc 100644 --- a/test/files/jvm/varargs/JavaClass.java +++ b/test/files/jvm/varargs/JavaClass.java @@ -11,5 +11,6 @@ public class JavaClass { va.vi(1, 2, 3, 4); varargz(5, 1.0, 2.0, 3.0); va.vt(16, "", "", ""); + System.out.println(va.vt1(16, "a", "b", "c")); } }
\ No newline at end of file diff --git a/test/files/jvm/varargs/VaClass.scala b/test/files/jvm/varargs/VaClass.scala index 6343f9c6f6..e94e8a625a 100644 --- a/test/files/jvm/varargs/VaClass.scala +++ b/test/files/jvm/varargs/VaClass.scala @@ -9,5 +9,5 @@ class VaClass { @varargs def vs(a: Int, b: String*) = println(a + b.length) @varargs def vi(a: Int, b: Int*) = println(a + b.sum) @varargs def vt[T](a: Int, b: T*) = println(a + b.length) - + @varargs def vt1[T](a: Int, b: T*): T = b.head } diff --git a/test/files/neg/forgot-interpolator.check b/test/files/neg/forgot-interpolator.check index 8988458982..8e75350518 100644 --- a/test/files/neg/forgot-interpolator.check +++ b/test/files/neg/forgot-interpolator.check @@ -1,25 +1,25 @@ -forgot-interpolator.scala:4: warning: `$bippy` looks like an interpolated identifier! Did you forget the interpolator? +forgot-interpolator.scala:4: warning: possible missing interpolator: detected interpolated identifier `$bippy` def f = "Put the $bippy in the $bippy!" // warn 1 ^ -forgot-interpolator.scala:14: warning: That looks like an interpolated expression! Did you forget the interpolator? +forgot-interpolator.scala:14: warning: possible missing interpolator: detected an interpolated expression def f = """Put the ${println("bippy")} in the bippy!""" // warn 2 ^ -forgot-interpolator.scala:30: warning: `$beppo` looks like an interpolated identifier! Did you forget the interpolator? +forgot-interpolator.scala:30: warning: possible missing interpolator: detected interpolated identifier `$beppo` def f = "$beppo was a marx bros who saw dollars." // warn 3 ^ -forgot-interpolator.scala:34: warning: `$aleppo` looks like an interpolated identifier! Did you forget the interpolator? +forgot-interpolator.scala:34: warning: possible missing interpolator: detected interpolated identifier `$aleppo` def f = "$aleppo is a pepper and a city." // warn 4 ^ -forgot-interpolator.scala:47: warning: `$hippo` looks like an interpolated identifier! Did you forget the interpolator? +forgot-interpolator.scala:47: warning: possible missing interpolator: detected interpolated identifier `$hippo` def h = "$hippo takes an implicit" // warn 6 ^ -forgot-interpolator.scala:88: warning: `$groucho` looks like an interpolated identifier! Did you forget the interpolator? +forgot-interpolator.scala:88: warning: possible missing interpolator: detected interpolated identifier `$groucho` def f2 = "I salute $groucho" // warn 7 ^ -forgot-interpolator.scala:89: warning: `$dingo` looks like an interpolated identifier! Did you forget the interpolator? +forgot-interpolator.scala:89: warning: possible missing interpolator: detected interpolated identifier `$dingo` def f3 = "I even salute $dingo" // warn 8 ^ -forgot-interpolator.scala:90: warning: `$calico` looks like an interpolated identifier! Did you forget the interpolator? +forgot-interpolator.scala:90: warning: possible missing interpolator: detected interpolated identifier `$calico` def f4 = "I also salute $calico" // warn 9 ^ error: No warnings can be incurred under -Xfatal-warnings. diff --git a/test/files/neg/t4851.flags b/test/files/neg/t4851.flags index ca0d0a0ba3..044ce22c84 100644 --- a/test/files/neg/t4851.flags +++ b/test/files/neg/t4851.flags @@ -1 +1 @@ --Ywarn-adapted-args -Xfatal-warnings -deprecation +-Xlint:adapted-args -Xfatal-warnings -deprecation diff --git a/test/files/neg/t7848-interp-warn.check b/test/files/neg/t7848-interp-warn.check index b7df6d8ce2..4cf9d55ffd 100644 --- a/test/files/neg/t7848-interp-warn.check +++ b/test/files/neg/t7848-interp-warn.check @@ -1,10 +1,10 @@ -t7848-interp-warn.scala:8: warning: `$foo` looks like an interpolated identifier! Did you forget the interpolator? +t7848-interp-warn.scala:8: warning: possible missing interpolator: detected interpolated identifier `$foo` "An important $foo message!" ^ -t7848-interp-warn.scala:12: warning: That looks like an interpolated expression! Did you forget the interpolator? +t7848-interp-warn.scala:12: warning: possible missing interpolator: detected an interpolated expression "A doubly important ${foo * 2} message!" ^ -t7848-interp-warn.scala:16: warning: `$bar` looks like an interpolated identifier! Did you forget the interpolator? +t7848-interp-warn.scala:16: warning: possible missing interpolator: detected interpolated identifier `$bar` def j = s"Try using '${ "something like $bar" }' instead." // warn ^ error: No warnings can be incurred under -Xfatal-warnings. diff --git a/test/files/neg/t8035-no-adapted-args.check b/test/files/neg/t8035-no-adapted-args.check new file mode 100644 index 0000000000..43637b2c1f --- /dev/null +++ b/test/files/neg/t8035-no-adapted-args.check @@ -0,0 +1,21 @@ +t8035-no-adapted-args.scala:4: warning: No automatic adaptation here: use explicit parentheses. + signature: Test.f[T](x: T): Int + given arguments: 1, 2, 3 + after adaptation: Test.f((1, 2, 3): (Int, Int, Int)) + f(1, 2, 3) + ^ +t8035-no-adapted-args.scala:4: error: too many arguments for method f: (x: (Int, Int, Int))Int + f(1, 2, 3) + ^ +t8035-no-adapted-args.scala:5: warning: No automatic adaptation here: use explicit parentheses. + signature: Test.f[T](x: T): Int + given arguments: <none> + after adaptation: Test.f((): Unit) + f() + ^ +t8035-no-adapted-args.scala:5: error: not enough arguments for method f: (x: Unit)Int. +Unspecified value parameter x. + f() + ^ +two warnings found +two errors found diff --git a/test/files/neg/t8035-no-adapted-args.flags b/test/files/neg/t8035-no-adapted-args.flags new file mode 100644 index 0000000000..b3e8c505e2 --- /dev/null +++ b/test/files/neg/t8035-no-adapted-args.flags @@ -0,0 +1 @@ +-Yno-adapted-args
\ No newline at end of file diff --git a/test/files/neg/t8035-no-adapted-args.scala b/test/files/neg/t8035-no-adapted-args.scala new file mode 100644 index 0000000000..82690ebe94 --- /dev/null +++ b/test/files/neg/t8035-no-adapted-args.scala @@ -0,0 +1,6 @@ +object Test { + def f[T](x: T) = 0 + + f(1, 2, 3) + f() +} diff --git a/test/files/neg/t8525.check b/test/files/neg/t8525.check new file mode 100644 index 0000000000..5287e43b7a --- /dev/null +++ b/test/files/neg/t8525.check @@ -0,0 +1,15 @@ +t8525.scala:7: warning: Adapting argument list by creating a 2-tuple: this may not be what you want. + signature: X.f(p: (Int, Int)): Int + given arguments: 3, 4 + after adaptation: X.f((3, 4): (Int, Int)) + def g = f(3, 4) // adapted + ^ +t8525.scala:9: warning: private[this] value name in class X shadows mutable name inherited from class Named. Changes to name will not be visible within class X - you may want to give them distinct names. + override def toString = name // shadowing mutable var name + ^ +t8525.scala:8: warning: side-effecting nullary methods are discouraged: suggest defining as `def u()` instead + def u: Unit = () // unitarian universalist + ^ +error: No warnings can be incurred under -Xfatal-warnings. +three warnings found +one error found diff --git a/test/files/neg/t8525.flags b/test/files/neg/t8525.flags new file mode 100644 index 0000000000..53b2dfe7ec --- /dev/null +++ b/test/files/neg/t8525.flags @@ -0,0 +1 @@ +-Xfatal-warnings -Xlint:-missing-interpolator -Xlint diff --git a/test/files/neg/t8525.scala b/test/files/neg/t8525.scala new file mode 100644 index 0000000000..7bed04904f --- /dev/null +++ b/test/files/neg/t8525.scala @@ -0,0 +1,10 @@ + +class Named(var name: String) + +class X(name: String) extends Named(name) { + def x = "Hi, $name" // missing interp + def f(p: (Int, Int)): Int = p._1 * p._2 + def g = f(3, 4) // adapted + def u: Unit = () // unitarian universalist + override def toString = name // shadowing mutable var name +} diff --git a/test/files/neg/t8610-arg.check b/test/files/neg/t8610-arg.check new file mode 100644 index 0000000000..d6fe207119 --- /dev/null +++ b/test/files/neg/t8610-arg.check @@ -0,0 +1,6 @@ +t8610-arg.scala:8: warning: side-effecting nullary methods are discouraged: suggest defining as `def u()` instead + def u: Unit = () // unitarian universalist + ^ +error: No warnings can be incurred under -Xfatal-warnings. +one warning found +one error found diff --git a/test/files/neg/t8610-arg.flags b/test/files/neg/t8610-arg.flags new file mode 100644 index 0000000000..f331ba9383 --- /dev/null +++ b/test/files/neg/t8610-arg.flags @@ -0,0 +1 @@ +-Xfatal-warnings -Xlint nullary-unit diff --git a/test/files/neg/t8610-arg.scala b/test/files/neg/t8610-arg.scala new file mode 100644 index 0000000000..7bed04904f --- /dev/null +++ b/test/files/neg/t8610-arg.scala @@ -0,0 +1,10 @@ + +class Named(var name: String) + +class X(name: String) extends Named(name) { + def x = "Hi, $name" // missing interp + def f(p: (Int, Int)): Int = p._1 * p._2 + def g = f(3, 4) // adapted + def u: Unit = () // unitarian universalist + override def toString = name // shadowing mutable var name +} diff --git a/test/files/neg/t8610.check b/test/files/neg/t8610.check new file mode 100644 index 0000000000..334a947549 --- /dev/null +++ b/test/files/neg/t8610.check @@ -0,0 +1,18 @@ +t8610.scala:5: warning: possible missing interpolator: detected interpolated identifier `$name` + def x = "Hi, $name" // missing interp + ^ +t8610.scala:7: warning: Adapting argument list by creating a 2-tuple: this may not be what you want. + signature: X.f(p: (Int, Int)): Int + given arguments: 3, 4 + after adaptation: X.f((3, 4): (Int, Int)) + def g = f(3, 4) // adapted + ^ +t8610.scala:9: warning: private[this] value name in class X shadows mutable name inherited from class Named. Changes to name will not be visible within class X - you may want to give them distinct names. + override def toString = name // shadowing mutable var name + ^ +t8610.scala:8: warning: side-effecting nullary methods are discouraged: suggest defining as `def u()` instead + def u: Unit = () // unitarian universalist + ^ +error: No warnings can be incurred under -Xfatal-warnings. +four warnings found +one error found diff --git a/test/files/neg/t8610.flags b/test/files/neg/t8610.flags new file mode 100644 index 0000000000..954eaba352 --- /dev/null +++ b/test/files/neg/t8610.flags @@ -0,0 +1 @@ +-Xfatal-warnings -Xlint diff --git a/test/files/neg/t8610.scala b/test/files/neg/t8610.scala new file mode 100644 index 0000000000..7bed04904f --- /dev/null +++ b/test/files/neg/t8610.scala @@ -0,0 +1,10 @@ + +class Named(var name: String) + +class X(name: String) extends Named(name) { + def x = "Hi, $name" // missing interp + def f(p: (Int, Int)): Int = p._1 * p._2 + def g = f(3, 4) // adapted + def u: Unit = () // unitarian universalist + override def toString = name // shadowing mutable var name +} diff --git a/test/files/neg/t8736-c.check b/test/files/neg/t8736-c.check new file mode 100644 index 0000000000..06b2228543 --- /dev/null +++ b/test/files/neg/t8736-c.check @@ -0,0 +1,11 @@ +t8736-c.scala:4: warning: higher-kinded type should be enabled +by making the implicit value scala.language.higherKinds visible. +This can be achieved by adding the import clause 'import scala.language.higherKinds' +or by setting the compiler option -language:higherKinds. +See the Scala docs for value scala.language.higherKinds for a discussion +why the feature should be explicitly enabled. + def hk[M[_]] = ??? + ^ +error: No warnings can be incurred under -Xfatal-warnings. +one warning found +one error found diff --git a/test/files/neg/t8736-c.flags b/test/files/neg/t8736-c.flags new file mode 100644 index 0000000000..fde5313c96 --- /dev/null +++ b/test/files/neg/t8736-c.flags @@ -0,0 +1 @@ +-feature -language:-higherKinds,_ -Xfatal-warnings diff --git a/test/files/neg/t8736-c.scala b/test/files/neg/t8736-c.scala new file mode 100644 index 0000000000..8432775ae1 --- /dev/null +++ b/test/files/neg/t8736-c.scala @@ -0,0 +1,7 @@ +// scalac: -feature -language:-higherKinds,_ -Xfatal-warnings +// showing that wildcard doesn't supersede explicit disablement +class X { + def hk[M[_]] = ??? + + implicit def imp(x: X): Int = x.hashCode +} diff --git a/test/files/neg/warn-inferred-any.flags b/test/files/neg/warn-inferred-any.flags index a3127d392a..b580dfbbe3 100644 --- a/test/files/neg/warn-inferred-any.flags +++ b/test/files/neg/warn-inferred-any.flags @@ -1 +1 @@ --Xfatal-warnings -Ywarn-infer-any +-Xfatal-warnings -Xlint:infer-any diff --git a/test/files/pos/macro-attachments/Macros_1.scala b/test/files/pos/macro-attachments/Macros_1.scala new file mode 100644 index 0000000000..38d05d5b85 --- /dev/null +++ b/test/files/pos/macro-attachments/Macros_1.scala @@ -0,0 +1,19 @@ +import scala.language.experimental.macros +import scala.reflect.macros.whitebox.Context + +trait Base +class Att extends Base + +object Macros { + def impl(c: Context) = { + import c.universe._ + import c.internal._ + import decorators._ + val dummy = q"x" + dummy.updateAttachment(new Att) + if (dummy.attachments.get[Base].isEmpty) c.abort(c.enclosingPosition, "that's not good") + q"()" + } + + def foo: Any = macro impl +}
\ No newline at end of file diff --git a/test/files/pos/macro-attachments/Test_2.scala b/test/files/pos/macro-attachments/Test_2.scala new file mode 100644 index 0000000000..acfddae942 --- /dev/null +++ b/test/files/pos/macro-attachments/Test_2.scala @@ -0,0 +1,3 @@ +object Test extends App { + Macros.foo +}
\ No newline at end of file diff --git a/test/files/pos/t8736-b.flags b/test/files/pos/t8736-b.flags new file mode 100644 index 0000000000..1ad4eabe0f --- /dev/null +++ b/test/files/pos/t8736-b.flags @@ -0,0 +1 @@ +-feature -language:_ -Xfatal-warnings diff --git a/test/files/pos/t8736-b.scala b/test/files/pos/t8736-b.scala new file mode 100644 index 0000000000..903292d232 --- /dev/null +++ b/test/files/pos/t8736-b.scala @@ -0,0 +1,7 @@ +// scalac: -feature -language:_ -Xfatal-warnings +// showing that all are set +class X { + def hk[M[_]] = ??? + + implicit def imp(x: X): Int = x.hashCode +} diff --git a/test/files/pos/t8736.flags b/test/files/pos/t8736.flags new file mode 100644 index 0000000000..7fe42f7340 --- /dev/null +++ b/test/files/pos/t8736.flags @@ -0,0 +1 @@ +-feature -language:implicitConversions -language:higherKinds -language:-implicitConversions -Xfatal-warnings diff --git a/test/files/pos/t8736.scala b/test/files/pos/t8736.scala new file mode 100644 index 0000000000..46c0cdfd00 --- /dev/null +++ b/test/files/pos/t8736.scala @@ -0,0 +1,7 @@ +// scalac: -feature -language:implicitConversions -language:higherKinds -language:-implicitConversions -Xfatal-warnings +// showing that multiple settings are respected, and explicit enablement has precedence +class X { + def hk[M[_]] = ??? + + implicit def imp(x: X): Int = x.hashCode +} diff --git a/test/files/pos/t8743.scala b/test/files/pos/t8743.scala new file mode 100644 index 0000000000..03b0cd7044 --- /dev/null +++ b/test/files/pos/t8743.scala @@ -0,0 +1,15 @@ +import annotation.varargs + +object VarArgs { + @varargs + def foo[A](x: A, xs: String*): A = ??? + + @varargs + def bar[A](x: List[A], xs: String*): A = ??? + + @varargs + def baz[A](x: List[A], xs: String*): A = ??? + + @varargs + def boz[A](x: A, xs: String*): Nothing = ??? +} diff --git a/test/files/run/abstypetags_serialize.check b/test/files/run/abstypetags_serialize.check index bddc4523e6..1b5e2ebddf 100644 --- a/test/files/run/abstypetags_serialize.check +++ b/test/files/run/abstypetags_serialize.check @@ -1,2 +1,2 @@ -java.io.NotSerializableException: Test$$typecreator1$1 -java.io.NotSerializableException: Test$$typecreator2$1 +WeakTypeTag[T] +WeakTypeTag[U[String]] diff --git a/test/files/run/exprs_serialize.check b/test/files/run/exprs_serialize.check index 20ad6c110c..551823ccdc 100644 --- a/test/files/run/exprs_serialize.check +++ b/test/files/run/exprs_serialize.check @@ -1,2 +1,19 @@ -java.io.NotSerializableException: Test$$treecreator1$1 -java.io.NotSerializableException: Test$$treecreator2$1 +Expr[Int(2)](2) +Expr[java.lang.String]({ + def foo = "hello"; + foo.$plus("world!") +}) +Expr[Boolean]({ + def foo(x: Int) = { + class Local extends AnyRef { + def <init>() = { + super.<init>(); + () + }; + val f = 2 + }; + val obj = new Local(); + x.$percent(obj.f).$eq$eq(0) + }; + foo(5) +}) diff --git a/test/files/run/exprs_serialize.scala b/test/files/run/exprs_serialize.scala index c4310b0fe1..91027803b4 100644 --- a/test/files/run/exprs_serialize.scala +++ b/test/files/run/exprs_serialize.scala @@ -26,4 +26,14 @@ object Test extends App { test(reify(2)) test(reify{def foo = "hello"; foo + "world!"}) -}
\ No newline at end of file + test(reify { + def foo(x: Int) = { + class Local { + val f = 2 + } + val obj = new Local + x % obj.f == 0 + } + foo(5) + }) +} diff --git a/test/files/run/macro-rangepos-subpatterns.check b/test/files/run/macro-rangepos-subpatterns.check new file mode 100644 index 0000000000..760e15d019 --- /dev/null +++ b/test/files/run/macro-rangepos-subpatterns.check @@ -0,0 +1 @@ +The width of the subpattern is: 2 diff --git a/test/files/run/macro-rangepos-subpatterns.flags b/test/files/run/macro-rangepos-subpatterns.flags new file mode 100644 index 0000000000..fcf951d907 --- /dev/null +++ b/test/files/run/macro-rangepos-subpatterns.flags @@ -0,0 +1 @@ +-Yrangepos
\ No newline at end of file diff --git a/test/files/run/macro-rangepos-subpatterns/Macros_1.scala b/test/files/run/macro-rangepos-subpatterns/Macros_1.scala new file mode 100644 index 0000000000..0f30862347 --- /dev/null +++ b/test/files/run/macro-rangepos-subpatterns/Macros_1.scala @@ -0,0 +1,18 @@ +import scala.reflect.macros.whitebox.Context +import language.experimental.macros + +object Extractor { + def unapply(x: Any): Any = macro unapplyImpl + def unapplyImpl(c: Context)(x: c.Tree) = { + import c.universe._ + import internal._ + val pos = subpatterns(x).get.head.pos + q""" + new { + def isEmpty = false + def get = ${"The width of the subpattern is: " + (pos.end - pos.start + 1)} + def unapply(x: Any) = this + }.unapply($x) + """ + } +} diff --git a/test/files/run/macro-rangepos-subpatterns/Test_2.scala b/test/files/run/macro-rangepos-subpatterns/Test_2.scala new file mode 100644 index 0000000000..7b076e6632 --- /dev/null +++ b/test/files/run/macro-rangepos-subpatterns/Test_2.scala @@ -0,0 +1,5 @@ +object Test extends App { + 42 match { + case Extractor(a) => println(a) + } +} diff --git a/test/files/run/names-defaults.check b/test/files/run/names-defaults.check index 25999c488a..c358dc5849 100644 --- a/test/files/run/names-defaults.check +++ b/test/files/run/names-defaults.check @@ -124,3 +124,4 @@ List(1, 2) 3 3 (1,0), (1,2) +1 1 0 diff --git a/test/files/run/names-defaults.scala b/test/files/run/names-defaults.scala index 05cd4a540c..b7ed490cbc 100644 --- a/test/files/run/names-defaults.scala +++ b/test/files/run/names-defaults.scala @@ -401,6 +401,10 @@ object Test extends App { C4441a().copy() C4441b()().copy()() + // SI-8117 + def f8177(a: Int = 0, b: Int = 0, c: Int = 0) = s"$a $b $c" + println(f8177(a = 1, 1)) + // DEFINITIONS def test1(a: Int, b: String) = println(a +": "+ b) def test2(u: Int, v: Int)(k: String, l: Int) = println(l +": "+ k +", "+ (u + v)) diff --git a/test/files/run/reflection-attachments.check b/test/files/run/reflection-attachments.check new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/files/run/reflection-attachments.check diff --git a/test/files/run/stringinterpolation_macro-run.check b/test/files/run/stringinterpolation_macro-run.check index ead61e76ac..c7f46bac87 100644 --- a/test/files/run/stringinterpolation_macro-run.check +++ b/test/files/run/stringinterpolation_macro-run.check @@ -63,5 +63,9 @@ She is 4 feet tall. 05/26/12 05/26/12 % + mind +------ +matter + 7 7 9 7 9 9 diff --git a/test/files/run/stringinterpolation_macro-run.scala b/test/files/run/stringinterpolation_macro-run.scala index a6def98540..e18375d521 100644 --- a/test/files/run/stringinterpolation_macro-run.scala +++ b/test/files/run/stringinterpolation_macro-run.scala @@ -115,6 +115,7 @@ println(f"""${"1234"}%TD""") // literals and arg indexes println(f"%%") +println(f" mind%n------%nmatter%n") println(f"${7}%d %<d ${9}%d") println(f"${7}%d %2$$d ${9}%d") diff --git a/test/files/run/t8608-no-format.scala b/test/files/run/t8608-no-format.scala new file mode 100644 index 0000000000..71c369a7ea --- /dev/null +++ b/test/files/run/t8608-no-format.scala @@ -0,0 +1,15 @@ + +import scala.tools.partest.JavapTest + +object Test extends JavapTest { + def code = """ + |f"hello, world" + |:javap -prv - + """.stripMargin + + // no format + override def yah(res: Seq[String]) = { + // note: avoid the word "information" + res forall (!_.contains("StringOps.format")) + } +} diff --git a/test/files/run/t8610.check b/test/files/run/t8610.check new file mode 100644 index 0000000000..b3ab7a9cef --- /dev/null +++ b/test/files/run/t8610.check @@ -0,0 +1,7 @@ +t8610.scala:6: warning: Adapting argument list by creating a 2-tuple: this may not be what you want. + signature: X.f(p: (Int, Int)): Int + given arguments: 3, 4 + after adaptation: X.f((3, 4): (Int, Int)) + def g = f(3, 4) // adapted + ^ +Hi, $name diff --git a/test/files/run/t8610.flags b/test/files/run/t8610.flags new file mode 100644 index 0000000000..4195dec383 --- /dev/null +++ b/test/files/run/t8610.flags @@ -0,0 +1 @@ +-Xlint:adapted-args diff --git a/test/files/run/t8610.scala b/test/files/run/t8610.scala new file mode 100644 index 0000000000..dd9e8e861e --- /dev/null +++ b/test/files/run/t8610.scala @@ -0,0 +1,13 @@ + +// flags don't warn on u +case class X(name: String) { + def x = "Hi, $name" // missing interp + def f(p: (Int, Int)): Int = p._1 * p._2 + def g = f(3, 4) // adapted + def u: Unit = () // unitarian universalist +} + +object Test extends App { + // poignant demonstration + Console println X("Bob").x +} diff --git a/test/files/run/t8738.scala b/test/files/run/t8738.scala new file mode 100644 index 0000000000..6898301db7 --- /dev/null +++ b/test/files/run/t8738.scala @@ -0,0 +1,16 @@ +object Test { + def check(a: Range, b: Range) = (a == b) == (a.toList == b.toList) + def main(args: Array[String]) { + val lo = -2 to 2 + val hi = lo + val step = List(-6,-2,-1,1,2,6) + for (i <- lo; j <- hi; n <- step; k <- lo; l <- hi; m <- step) { + assert( + check(i until j by n, k until l by m) && + check(i until j by n, k to l by m) && + check(i to j by n, k until l by m) && + check(i to j by n, k to l by m) + ) + } + } +} diff --git a/test/files/run/typetags_serialize.check b/test/files/run/typetags_serialize.check index f79436ea5d..22928a2e94 100644 --- a/test/files/run/typetags_serialize.check +++ b/test/files/run/typetags_serialize.check @@ -1,2 +1,3 @@ -java.io.NotSerializableException: scala.reflect.api.TypeTags$PredefTypeCreator -java.io.NotSerializableException: Test$$typecreator1$1 +TypeTag[Int] +TypeTag[String] +TypeTag[Test.C[Double]] diff --git a/test/files/run/typetags_serialize.scala b/test/files/run/typetags_serialize.scala index 3c842e6cc9..a7a7845232 100644 --- a/test/files/run/typetags_serialize.scala +++ b/test/files/run/typetags_serialize.scala @@ -4,6 +4,10 @@ import scala.reflect.runtime.{universe => ru} import scala.reflect.runtime.{currentMirror => cm} object Test extends App { + class C[A] { + def m(a: A): Int = 5 + } + def test(tag: TypeTag[_]) = try { val fout = new ByteArrayOutputStream() @@ -26,4 +30,5 @@ object Test extends App { test(implicitly[TypeTag[Int]]) test(implicitly[TypeTag[String]]) + test(implicitly[TypeTag[C[Double]]]) }
\ No newline at end of file diff --git a/test/files/scalacheck/quasiquotes/TermDeconstructionProps.scala b/test/files/scalacheck/quasiquotes/TermDeconstructionProps.scala index 49ffaff630..07e8f3faac 100644 --- a/test/files/scalacheck/quasiquotes/TermDeconstructionProps.scala +++ b/test/files/scalacheck/quasiquotes/TermDeconstructionProps.scala @@ -246,4 +246,11 @@ object TermDeconstructionProps extends QuasiquoteProperties("term deconstruction assert(f ≈ `new`) assert(argss.isEmpty) } + + property("SI-8703 extract block with single expression") = test { + val q"{ $a }" = Block(Nil, q"1") + val Literal(Constant(1)) = a + val q"{ $b }" = q"2" + val Literal(Constant(2)) = b + } } diff --git a/test/junit/scala/tools/nsc/settings/SettingsTest.scala b/test/junit/scala/tools/nsc/settings/SettingsTest.scala index e4b5ecc7c3..960d7f8ac1 100644 --- a/test/junit/scala/tools/nsc/settings/SettingsTest.scala +++ b/test/junit/scala/tools/nsc/settings/SettingsTest.scala @@ -26,7 +26,7 @@ class SettingsTest { assertThrows[IllegalArgumentException](check("-Ytest-setting:rubbish")) } - @Test def userSettingsHavePredecenceOverOptimize() { + @Test def userSettingsHavePrecedenceOverOptimize() { def check(args: String*): MutableSettings#BooleanSetting = { val s = new MutableSettings(msg => throw new IllegalArgumentException(msg)) val (ok, residual) = s.processArguments(args.toList, processAll = true) @@ -38,15 +38,23 @@ class SettingsTest { assertFalse(check("-Yinline:false", "-optimise").value) } - @Test def userSettingsHavePredecenceOverLint() { - def check(args: String*): MutableSettings#BooleanSetting = { - val s = new MutableSettings(msg => throw new IllegalArgumentException(msg)) - val (ok, residual) = s.processArguments(args.toList, processAll = true) - assert(residual.isEmpty) - s.warnAdaptedArgs // among Xlint - } - assertTrue(check("-Xlint").value) - assertFalse(check("-Xlint", "-Ywarn-adapted-args:false").value) - assertFalse(check("-Ywarn-adapted-args:false", "-Xlint").value) + // for the given args, select the desired setting + private def check(args: String*)(b: MutableSettings => MutableSettings#BooleanSetting): MutableSettings#BooleanSetting = { + val s = new MutableSettings(msg => throw new IllegalArgumentException(msg)) + val (ok, residual) = s.processArguments(args.toList, processAll = true) + assert(residual.isEmpty) + b(s) + } + @Test def userSettingsHavePrecedenceOverLint() { + assertTrue(check("-Xlint")(_.warnAdaptedArgs)) + assertFalse(check("-Xlint", "-Ywarn-adapted-args:false")(_.warnAdaptedArgs)) + assertFalse(check("-Ywarn-adapted-args:false", "-Xlint")(_.warnAdaptedArgs)) + } + + @Test def anonymousLintersCanBeNamed() { + assertTrue(check("-Xlint")(_.warnMissingInterpolator)) // among Xlint + assertFalse(check("-Xlint:-missing-interpolator")(_.warnMissingInterpolator)) + assertFalse(check("-Xlint:-missing-interpolator", "-Xlint")(_.warnMissingInterpolator)) + assertFalse(check("-Xlint", "-Xlint:-missing-interpolator")(_.warnMissingInterpolator)) } } diff --git a/test/scaladoc/run/t8557.check b/test/scaladoc/run/t8557.check new file mode 100644 index 0000000000..619c56180b --- /dev/null +++ b/test/scaladoc/run/t8557.check @@ -0,0 +1 @@ +Done. diff --git a/test/scaladoc/run/t8557.scala b/test/scaladoc/run/t8557.scala new file mode 100644 index 0000000000..451f004d7d --- /dev/null +++ b/test/scaladoc/run/t8557.scala @@ -0,0 +1,32 @@ +import scala.tools.nsc.doc.base._ +import scala.tools.nsc.doc.model._ +import scala.tools.partest.ScaladocModelTest + +object Test extends ScaladocModelTest { + + override def code = """ + package scala.test.scaladoc.T8857 + + /** + * A link: + * + * [[scala.Option$ object Option]]. + */ + class A + """ + + // a non-canonical path to scala-library.jar should still work + // this is a bit fragile (depends on the current directory being the root of the repo ; + // ant & partest seem to do that properly) + def scaladocSettings = "-doc-external-doc build/pack/bin/../lib/scala-library.jar#http://www.scala-lang.org/api/current/" + + def testModel(rootPackage: Package) = { + // get the quick access implicit defs in scope (_package(s), _class(es), _trait(s), object(s) _method(s), _value(s)) + import access._ + + val a = rootPackage._package("scala")._package("test")._package("scaladoc")._package("T8857")._class("A") + + val links = countLinks(a.comment.get, _.link.isInstanceOf[LinkToExternal]) + assert(links == 1, links + " == 1 (the links to external in class A)") + } +} |