diff options
Diffstat (limited to 'test')
49 files changed, 460 insertions, 49 deletions
diff --git a/test/files/continuations-run/t5472.check b/test/files/continuations-run/t5472.check index 3192c746eb..2468b6b27d 100644 --- a/test/files/continuations-run/t5472.check +++ b/test/files/continuations-run/t5472.check @@ -6,6 +6,16 @@ t5472.scala:12: warning: expression case4(){ } is cps-transformed unexpectedly (location, accessors) <- new ContinuationizedParallelIterable(map) ^ +t5472.scala:12: warning: expression case5(){ + matchEnd3(false) +} is cps-transformed unexpectedly + (location, accessors) <- new ContinuationizedParallelIterable(map) + ^ +t5472.scala:12: warning: expression matchEnd3(x: Boolean){ + x +} is cps-transformed unexpectedly + (location, accessors) <- new ContinuationizedParallelIterable(map) + ^ t5472.scala:12: warning: expression matchEnd3(x: Int){ x } is cps-transformed unexpectedly diff --git a/test/files/neg/checksensible.check b/test/files/neg/checksensible.check index e5f1a38d96..ef3aee5ee4 100644 --- a/test/files/neg/checksensible.check +++ b/test/files/neg/checksensible.check @@ -28,6 +28,9 @@ checksensible.scala:27: warning: comparing values of types Int and Unit using `= checksensible.scala:29: warning: comparing values of types Int and String using `==' will always yield false 1 == "abc" ^ +checksensible.scala:29: warning: Int and String are unrelated: they will most likely never compare equal + 1 == "abc" + ^ checksensible.scala:33: warning: comparing values of types Some[Int] and Int using `==' will always yield false Some(1) == 1 // as above ^ @@ -61,12 +64,18 @@ checksensible.scala:51: warning: comparing values of types Int and Unit using `! checksensible.scala:52: warning: comparing values of types Int and Symbol using `!=' will always yield true (1 != 'sym) ^ +checksensible.scala:52: warning: Int and Symbol are unrelated: they will most likely always compare unequal + (1 != 'sym) + ^ checksensible.scala:58: warning: comparing a fresh object using `==' will always yield false ((x: Int) => x + 1) == null ^ checksensible.scala:59: warning: comparing a fresh object using `==' will always yield false Bep == ((_: Int) + 1) ^ +checksensible.scala:59: warning: Bep.type and Int => Int are unrelated: they will most likely never compare equal + Bep == ((_: Int) + 1) + ^ checksensible.scala:61: warning: comparing a fresh object using `==' will always yield false new Object == new Object ^ @@ -82,6 +91,9 @@ checksensible.scala:66: warning: comparing values of types Int and Null using `= checksensible.scala:71: warning: comparing values of types Bip and Bop using `==' will always yield false (x1 == x2) ^ +checksensible.scala:71: warning: Bip and Bop are unrelated: they will most likely never compare equal + (x1 == x2) + ^ checksensible.scala:81: warning: comparing values of types EqEqRefTest.this.C3 and EqEqRefTest.this.Z1 using `==' will always yield false c3 == z1 ^ @@ -94,9 +106,12 @@ checksensible.scala:83: warning: comparing values of types EqEqRefTest.this.Z1 a checksensible.scala:84: warning: comparing values of types EqEqRefTest.this.C3 and String using `!=' will always yield true c3 != "abc" ^ +checksensible.scala:84: warning: EqEqRefTest.this.C3 and String are unrelated: they will most likely always compare unequal + c3 != "abc" + ^ checksensible.scala:95: warning: comparing values of types Unit and Int using `!=' will always yield true while ((c = in.read) != -1) ^ error: No warnings can be incurred under -Xfatal-warnings. -33 warnings found +38 warnings found one error found diff --git a/test/files/neg/forgot-interpolator.check b/test/files/neg/forgot-interpolator.check index a96431841f..98440fe657 100644 --- a/test/files/neg/forgot-interpolator.check +++ b/test/files/neg/forgot-interpolator.check @@ -1,24 +1,21 @@ forgot-interpolator.scala:4: warning: `$bippy` looks like an interpolated identifier! Did you forget the interpolator? - def f = "Put the $bippy in the $bippy!" // warn + 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? - def f = """Put the ${println("bippy")} in the bippy!""" // warn + 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? - def f = "$beppo was a marx bros who saw dollars." // warn + 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? - def f = "$aleppo is a pepper and a city." // warn + def f = "$aleppo is a pepper and a city." // warn 4 ^ -forgot-interpolator.scala:40: warning: `$bar` looks like an interpolated identifier! Did you forget the interpolator? - def f = "$bar is private, shall we warn just in case?" // warn +forgot-interpolator.scala:42: warning: `$bar` looks like an interpolated identifier! Did you forget the interpolator? + def f = "$bar is private, shall we warn just in case?" // warn 5 ^ -forgot-interpolator.scala:45: warning: `$hippo` looks like an interpolated identifier! Did you forget the interpolator? - def h = "$hippo takes an implicit" // warn +forgot-interpolator.scala:47: warning: `$hippo` looks like an interpolated identifier! Did you forget the interpolator? + def h = "$hippo takes an implicit" // warn 6 ^ -forgot-interpolator.scala:37: warning: private method in class Bar is never used - private def bar = 8 - ^ error: No warnings can be incurred under -Xfatal-warnings. -7 warnings found +6 warnings found one error found diff --git a/test/files/neg/forgot-interpolator.scala b/test/files/neg/forgot-interpolator.scala index 5067f1dce9..e007f15009 100644 --- a/test/files/neg/forgot-interpolator.scala +++ b/test/files/neg/forgot-interpolator.scala @@ -1,7 +1,7 @@ class A { val bippy = 123 - def f = "Put the $bippy in the $bippy!" // warn + def f = "Put the $bippy in the $bippy!" // warn 1 } class B { @@ -11,7 +11,7 @@ class B { } class C { - def f = """Put the ${println("bippy")} in the bippy!""" // warn + def f = """Put the ${println("bippy")} in the bippy!""" // warn 2 } package object test { @@ -27,21 +27,33 @@ package test { def beppo(i: Int) = 8 * i def beppo = 8 class Dah extends Doo { - def f = "$beppo was a marx bros who saw dollars." // warn + def f = "$beppo was a marx bros who saw dollars." // warn 3 } } class E { - def f = "$aleppo is a pepper and a city." // warn + def f = "$aleppo is a pepper and a city." // warn 4 + def k = s"Just an interpolation of $aleppo" // no warn } class Bar { private def bar = 8 + if (bar > 8) ??? // use it to avoid extra warning } class Baz extends Bar { - def f = "$bar is private, shall we warn just in case?" // warn + def f = "$bar is private, shall we warn just in case?" // warn 5 } class G { def g = "$greppo takes an arg" // no warn def z = "$zappos takes an arg too" // no warn - def h = "$hippo takes an implicit" // warn + def h = "$hippo takes an implicit" // warn 6 } + class J { + def j = 8 + class J2 { + def j(i: Int) = 2 * i + def jj = "shadowed $j" // no warn + } + } + import annotation._ + @implicitNotFound("No Z in ${A}") // no warn + class Z[A] } diff --git a/test/files/neg/newpat_unreachable.check b/test/files/neg/newpat_unreachable.check index a928e3853a..4463e2f1a4 100644 --- a/test/files/neg/newpat_unreachable.check +++ b/test/files/neg/newpat_unreachable.check @@ -13,6 +13,9 @@ If you intended to match against value d in class A, you must use backticks, lik newpat_unreachable.scala:9: warning: unreachable code due to variable pattern 'b' on line 6 case _ => println("matched neither") ^ +newpat_unreachable.scala:7: warning: unreachable code + case c => println("matched c") + ^ newpat_unreachable.scala:22: warning: patterns after a variable pattern cannot match (SLS 8.1.1) If you intended to match against parameter b of method g, you must use backticks, like: case `b` => case b => 1 @@ -24,6 +27,9 @@ If you intended to match against parameter c of method h, you must use backticks newpat_unreachable.scala:24: warning: unreachable code due to variable pattern 'b' on line 22 case _ => 3 ^ +newpat_unreachable.scala:23: warning: unreachable code + case c => 2 + ^ error: No warnings can be incurred under -Xfatal-warnings. -7 warnings found +9 warnings found one error found diff --git a/test/files/neg/package-ob-case.check b/test/files/neg/package-ob-case.check index 063a120db1..9b0ede1c6d 100644 --- a/test/files/neg/package-ob-case.check +++ b/test/files/neg/package-ob-case.check @@ -2,6 +2,9 @@ package-ob-case.scala:3: warning: it is not recommended to define classes/object If possible, define class X in package foo instead. case class X(z: Int) { } ^ +package-ob-case.scala:3: warning: class X should be placed directly in package foo instead of package object foo. Under some circumstances companion objects and case classes in package objects can fail to recompile. See https://issues.scala-lang.org/browse/SI-5954. + case class X(z: Int) { } + ^ error: No warnings can be incurred under -Xfatal-warnings. -one warning found +two warnings found one error found diff --git a/test/files/neg/pat_unreachable.check b/test/files/neg/pat_unreachable.check index b4c0e7e104..374ee4e9cf 100644 --- a/test/files/neg/pat_unreachable.check +++ b/test/files/neg/pat_unreachable.check @@ -9,6 +9,9 @@ If you intended to match against parameter c of method contrivedExample, you mus pat_unreachable.scala:24: warning: unreachable code due to variable pattern 'b' on line 22 case _ => println("matched neither") ^ +pat_unreachable.scala:23: warning: unreachable code + case c => println("matched c") + ^ error: No warnings can be incurred under -Xfatal-warnings. -three warnings found +four warnings found one error found diff --git a/test/files/neg/t2462b.check b/test/files/neg/t2462b.check index bc0d9aa469..b3b8007a93 100644 --- a/test/files/neg/t2462b.check +++ b/test/files/neg/t2462b.check @@ -6,9 +6,6 @@ t2462b.scala:9: warning: Invalid implicitNotFound message for trait Meh2 in pack The type parameter Elem referenced in the message of the @implicitNotFound annotation is not defined by trait Meh2. trait Meh2[-From, +To] ^ -t2462b.scala:12: error: overriding method x in class thankyoupartest of type => Int; - method x needs `override' modifier -class testmustfail extends thankyoupartest { def x = 43 } - ^ +error: No warnings can be incurred under -Xfatal-warnings. two warnings found one error found diff --git a/test/files/neg/t2462b.flags b/test/files/neg/t2462b.flags new file mode 100644 index 0000000000..85d8eb2ba2 --- /dev/null +++ b/test/files/neg/t2462b.flags @@ -0,0 +1 @@ +-Xfatal-warnings diff --git a/test/files/neg/t2462b.scala b/test/files/neg/t2462b.scala index 7a1389cc8e..576db4bd3f 100644 --- a/test/files/neg/t2462b.scala +++ b/test/files/neg/t2462b.scala @@ -7,6 +7,3 @@ trait Meh[-From, +To] @implicitNotFound(msg = "Cannot construct a collection of type ${To} ${Elem}.") trait Meh2[-From, +To] - -class thankyoupartest { def x = 42 } -class testmustfail extends thankyoupartest { def x = 43 } diff --git a/test/files/neg/t2462c.check b/test/files/neg/t2462c.check new file mode 100644 index 0000000000..edeead55d6 --- /dev/null +++ b/test/files/neg/t2462c.check @@ -0,0 +1,7 @@ +t2462c.scala:18: error: No C of X$Y + f[X$Y] + ^ +t2462c.scala:24: error: No C of Foo[Int] + f[Foo[Int]] + ^ +two errors found diff --git a/test/files/neg/t2462c.flags b/test/files/neg/t2462c.flags new file mode 100644 index 0000000000..85d8eb2ba2 --- /dev/null +++ b/test/files/neg/t2462c.flags @@ -0,0 +1 @@ +-Xfatal-warnings diff --git a/test/files/neg/t2462c.scala b/test/files/neg/t2462c.scala new file mode 100644 index 0000000000..acf04afba9 --- /dev/null +++ b/test/files/neg/t2462c.scala @@ -0,0 +1,25 @@ + +import annotation._ + +@implicitNotFound("No C of ${ A }") +class C[A] + +trait X$Y +/* using the $$ separator for expanded names is unwise +trait X$$Y +trait X$$$Y +trait X$$$$Y + */ + +trait Foo[A] + +class Test { + def f[A: C] = ??? + f[X$Y] +/* using the $$ separator for expanded names is unwise + f[X$$Y] + f[X$$$Y] + f[X$$$$Y] + */ + f[Foo[Int]] +} diff --git a/test/files/neg/t3971.check b/test/files/neg/t3971.check new file mode 100644 index 0000000000..8685119876 --- /dev/null +++ b/test/files/neg/t3971.check @@ -0,0 +1,21 @@ +t3971.scala:6: error: type mismatch; + found : Int + required: String + f(g("abc")("def")) // g returns Int, needs String + ^ +t3971.scala:7: error: type mismatch; + found : Int(5) + required: String + f(5) + ^ +t3971.scala:8: error: type mismatch; + found : Int + required: String + f(h("abc")) + ^ +t3971.scala:11: error: type mismatch; + found : Boolean + required: String + ({"ab".reverse; "ba".equals})(0): String + ^ +four errors found diff --git a/test/files/neg/t3971.scala b/test/files/neg/t3971.scala new file mode 100644 index 0000000000..35f64fde0c --- /dev/null +++ b/test/files/neg/t3971.scala @@ -0,0 +1,12 @@ +class A { + def f(x: String) = x + def g(x: String)(y: String): Int = x.length + y.length + def h(x: String) = x.length + + f(g("abc")("def")) // g returns Int, needs String + f(5) + f(h("abc")) + + // a perverse piece of code from a perverse coder + ({"ab".reverse; "ba".equals})(0): String +} diff --git a/test/files/neg/t5426.check b/test/files/neg/t5426.check index 98f3ddaaae..c042cdcec3 100644 --- a/test/files/neg/t5426.check +++ b/test/files/neg/t5426.check @@ -4,12 +4,18 @@ t5426.scala:2: warning: comparing values of types Some[Int] and Int using `==' w t5426.scala:3: warning: comparing values of types Int and Some[Int] using `==' will always yield false def f2 = 5 == Some(5) ^ +t5426.scala:3: warning: Int and Some[Int] are unrelated: they will most likely never compare equal + def f2 = 5 == Some(5) + ^ t5426.scala:8: warning: comparing values of types Int and Some[Int] using `==' will always yield false (x1 == x2) ^ +t5426.scala:8: warning: Int and Some[Int] are unrelated: they will most likely never compare equal + (x1 == x2) + ^ t5426.scala:9: warning: comparing values of types Some[Int] and Int using `==' will always yield false (x2 == x1) ^ error: No warnings can be incurred under -Xfatal-warnings. -four warnings found +6 warnings found one error found diff --git a/test/files/neg/t5663-badwarneq.check b/test/files/neg/t5663-badwarneq.check index 732e4f44d0..4b7795585b 100644 --- a/test/files/neg/t5663-badwarneq.check +++ b/test/files/neg/t5663-badwarneq.check @@ -25,6 +25,9 @@ t5663-badwarneq.scala:72: warning: ValueClass1 and Int are unrelated: they will t5663-badwarneq.scala:74: warning: comparing values of types Int and ValueClass1 using `==' will always yield false println(5 == new ValueClass1(5)) // bad ^ +t5663-badwarneq.scala:74: warning: Int and ValueClass1 are unrelated: they will never compare equal + println(5 == new ValueClass1(5)) // bad + ^ t5663-badwarneq.scala:78: warning: ValueClass2[String] and String are unrelated: they will never compare equal println(new ValueClass2("abc") == "abc") // bad ^ @@ -38,5 +41,5 @@ t5663-badwarneq.scala:82: warning: comparing values of types ValueClass3 and Int println(ValueClass3(5) == 5) // bad ^ error: No warnings can be incurred under -Xfatal-warnings. -13 warnings found +14 warnings found one error found diff --git a/test/files/neg/t6048.check b/test/files/neg/t6048.check index 5e11d24fde..f8eddf5471 100644 --- a/test/files/neg/t6048.check +++ b/test/files/neg/t6048.check @@ -10,6 +10,9 @@ t6048.scala:13: warning: patterns after a variable pattern cannot match (SLS 8.1 t6048.scala:14: warning: unreachable code due to variable pattern on line 13 case 5 if true => x // unreachable ^ +t6048.scala:14: warning: unreachable code + case 5 if true => x // unreachable + ^ error: No warnings can be incurred under -Xfatal-warnings. -four warnings found +5 warnings found one error found diff --git a/test/files/neg/t6120.check b/test/files/neg/t6120.check new file mode 100644 index 0000000000..a7d17e29cf --- /dev/null +++ b/test/files/neg/t6120.check @@ -0,0 +1,20 @@ +t6120.scala:5: warning: postfix operator bippy should be enabled +by making the implicit value scala.language.postfixOps visible. +This can be achieved by adding the import clause 'import scala.language.postfixOps' +or by setting the compiler option -language:postfixOps. +See the Scala docs for value scala.language.postfixOps for a discussion +why the feature should be explicitly enabled. + def f = null == null bippy + ^ +t6120.scala:5: warning: method bippy in class BooleanOps is deprecated: bobo + def f = null == null bippy + ^ +t6120.scala:5: warning: comparing values of types Null and Null using `==' will always yield true + def f = null == null bippy + ^ +t6120.scala:6: warning: method bippy in class BooleanOps is deprecated: bobo + def g = true.bippy + ^ +error: No warnings can be incurred under -Xfatal-warnings. +four warnings found +one error found diff --git a/test/files/neg/t6120.flags b/test/files/neg/t6120.flags new file mode 100644 index 0000000000..04d7c7d417 --- /dev/null +++ b/test/files/neg/t6120.flags @@ -0,0 +1 @@ +-feature -deprecation -Xfatal-warnings
\ No newline at end of file diff --git a/test/files/neg/t6120.scala b/test/files/neg/t6120.scala new file mode 100644 index 0000000000..425f09db47 --- /dev/null +++ b/test/files/neg/t6120.scala @@ -0,0 +1,7 @@ +class A { + implicit class BooleanOps(val b: Boolean) { + @deprecated("bobo", "2.11.0") def bippy() = 5 + } + def f = null == null bippy + def g = true.bippy +} diff --git a/test/files/neg/t7721.check b/test/files/neg/t7721.check index e056b9a293..ade1ca3b20 100644 --- a/test/files/neg/t7721.check +++ b/test/files/neg/t7721.check @@ -7,6 +7,9 @@ t7721.scala:15: warning: abstract type pattern A.this.Foo is unchecked since it t7721.scala:19: warning: abstract type pattern A.this.Foo is unchecked since it is eliminated by erasure case x: Foo with Bar => x.bippy + x.barry ^ +t7721.scala:19: warning: abstract type pattern A.this.Bar is unchecked since it is eliminated by erasure + case x: Foo with Bar => x.bippy + x.barry + ^ t7721.scala:39: warning: abstract type pattern B.this.Foo is unchecked since it is eliminated by erasure case x: Foo with Concrete => x.bippy + x.dingo + x.conco ^ @@ -16,6 +19,9 @@ t7721.scala:43: warning: abstract type pattern B.this.Foo is unchecked since it t7721.scala:47: warning: abstract type pattern B.this.Foo is unchecked since it is eliminated by erasure case x: Foo with Bar with Concrete => x.bippy + x.barry + x.dingo + x.conco + x.bongo ^ +t7721.scala:47: warning: abstract type pattern B.this.Bar is unchecked since it is eliminated by erasure + case x: Foo with Bar with Concrete => x.bippy + x.barry + x.dingo + x.conco + x.bongo + ^ error: No warnings can be incurred under -Xfatal-warnings. -6 warnings found +8 warnings found one error found diff --git a/test/files/neg/t7756b.check b/test/files/neg/t7756b.check index 2817a7e230..e764783241 100644 --- a/test/files/neg/t7756b.check +++ b/test/files/neg/t7756b.check @@ -1,6 +1,9 @@ t7756b.scala:3: warning: comparing values of types Int and String using `==' will always yield false case _ => 0 == "" ^ +t7756b.scala:3: warning: Int and String are unrelated: they will most likely never compare equal + case _ => 0 == "" + ^ error: No warnings can be incurred under -Xfatal-warnings. -one warning found +two warnings found one error found diff --git a/test/files/neg/t7848-interp-warn.check b/test/files/neg/t7848-interp-warn.check index cbdc9f4c27..b7df6d8ce2 100644 --- a/test/files/neg/t7848-interp-warn.check +++ b/test/files/neg/t7848-interp-warn.check @@ -1,9 +1,12 @@ -t7848-interp-warn.scala:7: warning: `$foo` looks like an interpolated identifier! Did you forget the interpolator? +t7848-interp-warn.scala:8: warning: `$foo` looks like an interpolated identifier! Did you forget the interpolator? "An important $foo message!" ^ -t7848-interp-warn.scala:11: warning: That looks like an interpolated expression! Did you forget the interpolator? +t7848-interp-warn.scala:12: warning: That looks like an interpolated expression! Did you forget the interpolator? "A doubly important ${foo * 2} message!" ^ +t7848-interp-warn.scala:16: warning: `$bar` looks like an interpolated identifier! Did you forget the interpolator? + def j = s"Try using '${ "something like $bar" }' instead." // warn + ^ error: No warnings can be incurred under -Xfatal-warnings. -two warnings found +three warnings found one error found diff --git a/test/files/neg/t7848-interp-warn.scala b/test/files/neg/t7848-interp-warn.scala index bb3eeff60c..3887aff8de 100644 --- a/test/files/neg/t7848-interp-warn.scala +++ b/test/files/neg/t7848-interp-warn.scala @@ -2,6 +2,7 @@ package test object Test { + def bar = "bar" def f = { val foo = "bar" "An important $foo message!" @@ -10,4 +11,8 @@ object Test { val foo = "bar" "A doubly important ${foo * 2} message!" } + def h = s"Try using '$$bar' instead." // no warn + def i = s"Try using '${ "$bar" }' instead." // no warn on space test + def j = s"Try using '${ "something like $bar" }' instead." // warn + def k = f"Try using '$bar' instead." // no warn on other std interps } diff --git a/test/files/neg/t7870.check b/test/files/neg/t7870.check new file mode 100644 index 0000000000..d9db911ac1 --- /dev/null +++ b/test/files/neg/t7870.check @@ -0,0 +1,4 @@ +t7870.scala:1: error: in class C, multiple overloaded alternatives of constructor C define default arguments. +class C(a: Int = 0, b: Any) { + ^ +one error found diff --git a/test/files/neg/t7870.scala b/test/files/neg/t7870.scala new file mode 100644 index 0000000000..5d48d43b3a --- /dev/null +++ b/test/files/neg/t7870.scala @@ -0,0 +1,3 @@ +class C(a: Int = 0, b: Any) { + def this(a: Int = 0) = this(???, ???) +} diff --git a/test/files/neg/t7877.check b/test/files/neg/t7877.check new file mode 100644 index 0000000000..7f7f832463 --- /dev/null +++ b/test/files/neg/t7877.check @@ -0,0 +1,7 @@ +t7877.scala:6: error: not found: value Y + case Y() => () // not allowed + ^ +t7877.scala:7: error: OnNext[Any] does not take parameters + case OnNext[Any]() => () // should *not* be allowed, but was. + ^ +two errors found diff --git a/test/files/neg/t7877.scala b/test/files/neg/t7877.scala new file mode 100644 index 0000000000..52e167f3b8 --- /dev/null +++ b/test/files/neg/t7877.scala @@ -0,0 +1,13 @@ +class Test { + val X: OnNext[Any] = null + def Y: OnNext[Any] = null + (null: Any) match { + case X() => () // allowed + case Y() => () // not allowed + case OnNext[Any]() => () // should *not* be allowed, but was. + } +} + +class OnNext[+T] { + def unapply(x: Any) = false +} diff --git a/test/files/neg/unreachablechar.check b/test/files/neg/unreachablechar.check index 121f12a0c7..a621196c56 100644 --- a/test/files/neg/unreachablechar.check +++ b/test/files/neg/unreachablechar.check @@ -4,6 +4,9 @@ unreachablechar.scala:4: warning: patterns after a variable pattern cannot match unreachablechar.scala:5: warning: unreachable code due to variable pattern on line 4 case 'f' => println("not stuff?"); ^ +unreachablechar.scala:5: warning: unreachable code + case 'f' => println("not stuff?"); + ^ error: No warnings can be incurred under -Xfatal-warnings. -two warnings found +three warnings found one error found diff --git a/test/files/neg/warn-unused-privates.check b/test/files/neg/warn-unused-privates.check index 9c41a33e8f..d012869c93 100644 --- a/test/files/neg/warn-unused-privates.check +++ b/test/files/neg/warn-unused-privates.check @@ -16,6 +16,9 @@ warn-unused-privates.scala:35: warning: private val in class Boppy is never used warn-unused-privates.scala:42: warning: private var in trait Accessors is never used private var v1: Int = 0 // warn ^ +warn-unused-privates.scala:42: warning: private setter in trait Accessors is never used + private var v1: Int = 0 // warn + ^ warn-unused-privates.scala:43: warning: private setter in trait Accessors is never used private var v2: Int = 0 // warn, never set ^ @@ -59,5 +62,5 @@ warn-unused-privates.scala:102: warning: local type OtherThing is never used type OtherThing = String // warn ^ error: No warnings can be incurred under -Xfatal-warnings. -20 warnings found +21 warnings found one error found diff --git a/test/files/pos/t7815.scala b/test/files/pos/t7815.scala new file mode 100644 index 0000000000..12a434c5b0 --- /dev/null +++ b/test/files/pos/t7815.scala @@ -0,0 +1,30 @@ +import language.higherKinds + +trait Foo[A <: AnyRef] { + type Repr + def f(a: A): Repr + def g(a: A): Option[Repr] + + type M[X] + def m(a: A): M[a.type] + + type Id[X] = X + def n(a: A): Id[(Repr, M[a.type])] + +} + +object Foo { + type Aux[A <: AnyRef, B] = Foo[A] { type Repr = B; type M[X] = Int } + +} + +object Main extends App { + def mapWithFoo[A <: AnyRef, B](as: List[A])(implicit foo: Foo.Aux[A, B]) = { + // Should be Eta expandable because the result type of `f` is not + // dependant on the value, it is just `B`. + as map foo.f + as map foo.g + as map foo.m + as map foo.n + } +} diff --git a/test/files/run/future-flatmap-exec-count.check b/test/files/run/future-flatmap-exec-count.check new file mode 100644 index 0000000000..dd9dce64ed --- /dev/null +++ b/test/files/run/future-flatmap-exec-count.check @@ -0,0 +1,6 @@ +mapping +execute() +flatmapping +execute() +recovering +execute() diff --git a/test/files/run/future-flatmap-exec-count.scala b/test/files/run/future-flatmap-exec-count.scala new file mode 100644 index 0000000000..86c37be938 --- /dev/null +++ b/test/files/run/future-flatmap-exec-count.scala @@ -0,0 +1,61 @@ +import scala.concurrent._ +import java.util.concurrent.atomic.AtomicInteger + +object Test { + def main(args: Array[String]) { + test() + } + + def test() = { + def await(f: Future[Any]) = + Await.result(f, duration.Duration.Inf) + + val ec = new TestExecutionContext(ExecutionContext.Implicits.global) + + { + val p = Promise[Int]() + val fp = p.future + println("mapping") + val mapped = fp.map(x => x)(ec) + p.success(0) + await(mapped) + } + + { + println("flatmapping") + val p = Promise[Int]() + val fp = p.future + val flatMapped = fp.flatMap({ (x: Int) => + Future.successful(2 * x) + })(ec) + p.success(0) + await(flatMapped) + } + + { + println("recovering") + val recovered = Future.failed(new Throwable()).recoverWith { + case _ => Future.successful(2) + }(ec) + await(recovered) + } + } + + class TestExecutionContext(delegate: ExecutionContext) extends ExecutionContext { + def execute(runnable: Runnable): Unit = ??? + + def reportFailure(t: Throwable): Unit = ??? + + override def prepare(): ExecutionContext = { + val preparedDelegate = delegate.prepare() + return new ExecutionContext { + def execute(runnable: Runnable): Unit = { + println("execute()") + preparedDelegate.execute(runnable) + } + + def reportFailure(t: Throwable): Unit = ??? + } + } + } +} diff --git a/test/files/run/macro-reflective-mamd-normal-mi.check b/test/files/run/macro-reflective-mamd-normal-mi.check index ac4213d6e9..f77196b2db 100644 --- a/test/files/run/macro-reflective-mamd-normal-mi.check +++ b/test/files/run/macro-reflective-mamd-normal-mi.check @@ -1 +1,2 @@ -43
\ No newline at end of file +warning: there were 1 deprecation warning(s); re-run with -deprecation for details +43 diff --git a/test/files/run/private-inline.check b/test/files/run/private-inline.check index 3e44989521..e71aec2fcf 100644 --- a/test/files/run/private-inline.check +++ b/test/files/run/private-inline.check @@ -1,7 +1,13 @@ private-inline.scala:24: warning: Could not inline required method wrapper1 because callee contains exception handlers / finally clause, and is invoked with non-empty operand stack. def f1b() = identity(wrapper1(5)) ^ +private-inline.scala:24: warning: At the end of the day, could not inline @inline-marked method wrapper1 + def f1b() = identity(wrapper1(5)) + ^ private-inline.scala:29: warning: Could not inline required method wrapper2 because callee contains exception handlers / finally clause, and is invoked with non-empty operand stack. def f2b() = identity(wrapper2(5)) ^ +private-inline.scala:29: warning: At the end of the day, could not inline @inline-marked method wrapper2 + def f2b() = identity(wrapper2(5)) + ^ 20 diff --git a/test/files/run/repl-power.check b/test/files/run/repl-power.check index d6a0d8c931..c1992e89aa 100644 --- a/test/files/run/repl-power.check +++ b/test/files/run/repl-power.check @@ -11,7 +11,8 @@ scala> :power scala> // guarding against "error: reference to global is ambiguous" scala> global.emptyValDef // "it is imported twice in the same scope by ..." -res0: $r.global.emptyValDef.type = private val _ = _ +warning: there were 1 deprecation warning(s); re-run with -deprecation for details +res0: $r.global.noSelfType.type = private val _ = _ scala> val tp = ArrayClass[scala.util.Random] // magic with tags warning: there were 1 feature warning(s); re-run with -feature for details diff --git a/test/files/run/showraw_mods.check b/test/files/run/showraw_mods.check index 3ec868542d..4d34160422 100644 --- a/test/files/run/showraw_mods.check +++ b/test/files/run/showraw_mods.check @@ -1 +1 @@ -Block(List(ClassDef(Modifiers(ABSTRACT | DEFAULTPARAM/TRAIT), TypeName("C"), List(), Template(List(Ident(TypeName("AnyRef"))), emptyValDef, List(DefDef(Modifiers(), TermName("$init$"), List(), List(List()), TypeTree(), Block(List(), Literal(Constant(())))), ValDef(Modifiers(PRIVATE | LOCAL), TermName("x"), TypeTree(), Literal(Constant(2))), ValDef(Modifiers(MUTABLE), TermName("y"), TypeTree(), Select(This(TypeName("C")), TermName("x"))), ValDef(Modifiers(LAZY), TermName("z"), TypeTree(), Select(This(TypeName("C")), TermName("y"))))))), Literal(Constant(()))) +Block(List(ClassDef(Modifiers(ABSTRACT | DEFAULTPARAM/TRAIT), TypeName("C"), List(), Template(List(Ident(TypeName("AnyRef"))), noSelfType, List(DefDef(Modifiers(), TermName("$init$"), List(), List(List()), TypeTree(), Block(List(), Literal(Constant(())))), ValDef(Modifiers(PRIVATE | LOCAL), TermName("x"), TypeTree(), Literal(Constant(2))), ValDef(Modifiers(MUTABLE), TermName("y"), TypeTree(), Select(This(TypeName("C")), TermName("x"))), ValDef(Modifiers(LAZY), TermName("z"), TypeTree(), Select(This(TypeName("C")), TermName("y"))))))), Literal(Constant(()))) diff --git a/test/files/run/t2106.check b/test/files/run/t2106.check index b14e9d1c41..f8f625ff46 100644 --- a/test/files/run/t2106.check +++ b/test/files/run/t2106.check @@ -1,3 +1,6 @@ t2106.scala:7: warning: Could not inline required method foo because access level required by callee not matched by caller. def main(args: Array[String]): Unit = x.foo ^ +t2106.scala:7: warning: At the end of the day, could not inline @inline-marked method foo + def main(args: Array[String]): Unit = x.foo + ^ diff --git a/test/files/run/t6392b.check b/test/files/run/t6392b.check index 1ccfced1c6..c2cc103373 100644 --- a/test/files/run/t6392b.check +++ b/test/files/run/t6392b.check @@ -1 +1 @@ -ModuleDef(Modifiers(), TermName("C")#MOD, Template(List(Select(Ident(scala#PK), TypeName("AnyRef")#TPE)), emptyValDef, List(DefDef(Modifiers(), nme.CONSTRUCTOR#PCTOR, List(), List(List()), TypeTree(), Block(List(Apply(Select(Super(This(TypeName("C")), tpnme.EMPTY), nme.CONSTRUCTOR#PCTOR), List())), Literal(Constant(()))))))) +ModuleDef(Modifiers(), TermName("C")#MOD, Template(List(Select(Ident(scala#PK), TypeName("AnyRef")#TPE)), noSelfType, List(DefDef(Modifiers(), nme.CONSTRUCTOR#PCTOR, List(), List(List()), TypeTree(), Block(List(Apply(Select(Super(This(TypeName("C")), tpnme.EMPTY), nme.CONSTRUCTOR#PCTOR), List())), Literal(Constant(()))))))) diff --git a/test/files/run/t7331c.check b/test/files/run/t7331c.check index fd3ac1d9ef..b35d831f83 100644 --- a/test/files/run/t7331c.check +++ b/test/files/run/t7331c.check @@ -1,3 +1,3 @@ -ClassDef(Modifiers(), TypeName("C"), List(), Template(List(Select(Ident(scala), TypeName("AnyRef"))), emptyValDef, List(DefDef(Modifiers(), nme.CONSTRUCTOR, List(), List(List()), TypeTree(), Block(List(pendingSuperCall), Literal(Constant(()))))))) +ClassDef(Modifiers(), TypeName("C"), List(), Template(List(Select(Ident(scala), TypeName("AnyRef"))), noSelfType, List(DefDef(Modifiers(), nme.CONSTRUCTOR, List(), List(List()), TypeTree(), Block(List(pendingSuperCall), Literal(Constant(()))))))) source-<toolbox>,line-1,offset=6 NoPosition diff --git a/test/files/run/t7398.scala b/test/files/run/t7398.scala index dd59697b71..493c4dcf40 100644 --- a/test/files/run/t7398.scala +++ b/test/files/run/t7398.scala @@ -3,11 +3,9 @@ import scala.tools.partest._ object Test extends CompilerTest { import global._ - // This way we auto-pass on non-java8 since there's nothing to check - override lazy val units: List[CompilationUnit] = testUnderJavaAtLeast("1.8") { + override lazy val units: List[CompilationUnit] = { + // This test itself does not depend on JDK8. javaCompilationUnits(global)(defaultMethodSource) - } otherwise { - Nil } private def defaultMethodSource = """ diff --git a/test/files/run/t7825.scala b/test/files/run/t7825.scala new file mode 100644 index 0000000000..65ca06fdfc --- /dev/null +++ b/test/files/run/t7825.scala @@ -0,0 +1,34 @@ +import scala.tools.partest._ + +object Test extends CompilerTest { + import global._ + + override lazy val units: List[CompilationUnit] = { + // We can test this on JDK6. + javaCompilationUnits(global)(defaultMethodSource) ++ compilationUnits(global)(scalaExtendsDefault) + } + + private def defaultMethodSource = """ +public interface Iterator<E> { + boolean hasNext(); + E next(); + default void remove() { + throw new UnsupportedOperationException("remove"); + } +} + """ + + private def scalaExtendsDefault = """ +object Test { + object X extends Iterator[String] { + def hasNext = true + def next = "!" + } +} + """ + + // We're only checking we that the Scala compilation unit passes refchecks + // No further checks are needed here. + def check(source: String, unit: global.CompilationUnit): Unit = { + } +} diff --git a/test/files/run/t7876.scala b/test/files/run/t7876.scala new file mode 100644 index 0000000000..aeec8c8cce --- /dev/null +++ b/test/files/run/t7876.scala @@ -0,0 +1,26 @@ +import scala.tools.partest._ + +// Type constructors for FunctionN and TupleN should not be considered as function type / tuple types. +object Test extends DirectTest { + override def extraSettings: String = "-usejavacp" + + def code = "" + + def show() { + val global = newCompiler() + new global.Run() + import global._, definitions._ + val function0TC = FunctionClass(0).typeConstructor + val tuple1TC = TupleClass(1).typeConstructor + FunctionClass.seq.foreach { sym => + val tc = sym.typeConstructor + assert(!isFunctionType(tc), s"$tc") + assert(!isFunctionTypeDirect(tc), s"$tc (direct)") + } + TupleClass.seq.foreach { sym => + val tc = sym.typeConstructor + assert(!isTupleType(tc), s"$sym") + assert(!isTupleTypeDirect(tc), s"$tc (direct)") + } + } +} diff --git a/test/scaladoc/run/SI-4676.scala b/test/scaladoc/run/SI-4676.scala index b83a59a472..99b3c5568a 100644 --- a/test/scaladoc/run/SI-4676.scala +++ b/test/scaladoc/run/SI-4676.scala @@ -21,6 +21,7 @@ object Test extends ScaladocModelTest { // check correct expansion of the use case signature val x = rootPackage._class("SI_4676")._method("x") - assert(x.valueParams(0)(0).resultType.name == "(String, String)", "parameter ss of method x has type (String, String") + val resultType = x.valueParams(0)(0).resultType.name + assert(resultType == "SS", s"parameter ss of method x has type $resultType, expected SS!") } }
\ No newline at end of file diff --git a/test/scaladoc/run/t7876.check b/test/scaladoc/run/t7876.check new file mode 100644 index 0000000000..619c56180b --- /dev/null +++ b/test/scaladoc/run/t7876.check @@ -0,0 +1 @@ +Done. diff --git a/test/scaladoc/run/t7876.scala b/test/scaladoc/run/t7876.scala new file mode 100644 index 0000000000..63c63f8a0c --- /dev/null +++ b/test/scaladoc/run/t7876.scala @@ -0,0 +1,19 @@ +import scala.tools.nsc.doc.model._ +import scala.tools.partest.ScaladocModelTest + +object Test extends ScaladocModelTest { + + override def code = """ + import language.higherKinds + trait T[M[_]] + class C extends T[Function0] + class D extends T[Tuple1] + """ + + def scaladocSettings = "" + + def testModel(rootPackage: Package) = { + import access._ + // did not crash + } +} diff --git a/test/scaladoc/run/t7876b.check b/test/scaladoc/run/t7876b.check new file mode 100644 index 0000000000..21aaf3b295 --- /dev/null +++ b/test/scaladoc/run/t7876b.check @@ -0,0 +1,3 @@ +foo: FInt +foo: TInt +Done. diff --git a/test/scaladoc/run/t7876b.scala b/test/scaladoc/run/t7876b.scala new file mode 100644 index 0000000000..4d5b8c22cf --- /dev/null +++ b/test/scaladoc/run/t7876b.scala @@ -0,0 +1,24 @@ +import scala.tools.nsc.doc.model._ +import scala.tools.partest.ScaladocModelTest + +// Don't dealias just to print a Function or Tuple type. +object Test extends ScaladocModelTest { + + override def code = """ + class Test { + type FInt = Function0[Int] + type TInt = Tuple1[Int] + def foo: FInt + def bar: TInt + } + """ + + def scaladocSettings = "" + + def testModel(rootPackage: Package) = { + import access._ + List("foo", "bar").foreach { name => + println("foo: " + rootPackage._class("Test")._method(name).resultType.name) + } + } +} |