diff options
Diffstat (limited to 'test/files/neg')
38 files changed, 286 insertions, 62 deletions
diff --git a/test/files/neg/beanInfoDeprecation.check b/test/files/neg/beanInfoDeprecation.check new file mode 100644 index 0000000000..788b277818 --- /dev/null +++ b/test/files/neg/beanInfoDeprecation.check @@ -0,0 +1,6 @@ +beanInfoDeprecation.scala:2: warning: class BeanInfo in package beans is deprecated: the generation of BeanInfo classes is no longer supported +class C + ^ +error: No warnings can be incurred under -Xfatal-warnings. +one warning found +one error found diff --git a/test/files/neg/beanInfoDeprecation.flags b/test/files/neg/beanInfoDeprecation.flags new file mode 100644 index 0000000000..c6bfaf1f64 --- /dev/null +++ b/test/files/neg/beanInfoDeprecation.flags @@ -0,0 +1 @@ +-deprecation -Xfatal-warnings diff --git a/test/files/neg/beanInfoDeprecation.scala b/test/files/neg/beanInfoDeprecation.scala new file mode 100644 index 0000000000..c7e3a86202 --- /dev/null +++ b/test/files/neg/beanInfoDeprecation.scala @@ -0,0 +1,2 @@ +@scala.beans.BeanInfo +class C diff --git a/test/files/neg/deprecated-target.check b/test/files/neg/deprecated-target.check new file mode 100644 index 0000000000..307d3d25ab --- /dev/null +++ b/test/files/neg/deprecated-target.check @@ -0,0 +1,4 @@ +warning: -target is deprecated: -target:jvm-1.7 is deprecated, forcing use of jvm-1.8 +error: No warnings can be incurred under -Xfatal-warnings. +one warning found +one error found diff --git a/test/files/neg/deprecated-target.flags b/test/files/neg/deprecated-target.flags new file mode 100644 index 0000000000..458ded8123 --- /dev/null +++ b/test/files/neg/deprecated-target.flags @@ -0,0 +1 @@ +-target:jvm-1.7 -deprecation -Xfatal-warnings diff --git a/test/files/neg/deprecated-target.scala b/test/files/neg/deprecated-target.scala new file mode 100644 index 0000000000..9dccdd5e59 --- /dev/null +++ b/test/files/neg/deprecated-target.scala @@ -0,0 +1 @@ +class C
\ No newline at end of file diff --git a/test/files/neg/implicit-ambiguous-2.check b/test/files/neg/implicit-ambiguous-2.check new file mode 100644 index 0000000000..4a10b0dd65 --- /dev/null +++ b/test/files/neg/implicit-ambiguous-2.check @@ -0,0 +1,4 @@ +implicit-ambiguous-2.scala:10: error: Could not prove Int =!= Int + implicitly[Int =!= Int] + ^ +one error found diff --git a/test/files/neg/implicit-ambiguous-2.scala b/test/files/neg/implicit-ambiguous-2.scala new file mode 100644 index 0000000000..563c8c583f --- /dev/null +++ b/test/files/neg/implicit-ambiguous-2.scala @@ -0,0 +1,11 @@ +object Test { + trait =!=[C, D] + + implicit def neq[E, F] : E =!= F = null + + implicit def neqAmbig1[G, H, J] : J =!= J = null + @annotation.implicitAmbiguous("Could not prove ${I} =!= ${I}") + implicit def neqAmbig2[I] : I =!= I = null + + implicitly[Int =!= Int] +} diff --git a/test/files/neg/implicit-ambiguous-invalid.check b/test/files/neg/implicit-ambiguous-invalid.check new file mode 100644 index 0000000000..68b607c4c2 --- /dev/null +++ b/test/files/neg/implicit-ambiguous-invalid.check @@ -0,0 +1,7 @@ +implicit-ambiguous-invalid.scala:5: warning: Invalid implicitAmbiguous message for method neqAmbig1 in object Test: +The type parameter B referenced in the message of the @implicitAmbiguous annotation is not defined by method neqAmbig1. + implicit def neqAmbig1[A] : A =!= A = null + ^ +error: No warnings can be incurred under -Xfatal-warnings. +one warning found +one error found diff --git a/test/files/neg/implicit-ambiguous-invalid.flags b/test/files/neg/implicit-ambiguous-invalid.flags new file mode 100644 index 0000000000..85d8eb2ba2 --- /dev/null +++ b/test/files/neg/implicit-ambiguous-invalid.flags @@ -0,0 +1 @@ +-Xfatal-warnings diff --git a/test/files/neg/implicit-ambiguous-invalid.scala b/test/files/neg/implicit-ambiguous-invalid.scala new file mode 100644 index 0000000000..f8f9da655f --- /dev/null +++ b/test/files/neg/implicit-ambiguous-invalid.scala @@ -0,0 +1,6 @@ +object Test { + trait =!=[C, D] + + @annotation.implicitAmbiguous("Could not prove ${A} =!= ${B}") + implicit def neqAmbig1[A] : A =!= A = null +} diff --git a/test/files/neg/implicit-ambiguous.check b/test/files/neg/implicit-ambiguous.check new file mode 100644 index 0000000000..0b3cebcb6f --- /dev/null +++ b/test/files/neg/implicit-ambiguous.check @@ -0,0 +1,4 @@ +implicit-ambiguous.scala:10: error: Could not prove Int =!= Int + implicitly[Int =!= Int] + ^ +one error found diff --git a/test/files/neg/implicit-ambiguous.scala b/test/files/neg/implicit-ambiguous.scala new file mode 100644 index 0000000000..79b1297915 --- /dev/null +++ b/test/files/neg/implicit-ambiguous.scala @@ -0,0 +1,11 @@ +object Test { + trait =!=[C, D] + + implicit def neq[E, F] : E =!= F = null + + @annotation.implicitAmbiguous("Could not prove ${J} =!= ${J}") + implicit def neqAmbig1[G, H, J] : J =!= J = null + implicit def neqAmbig2[I] : I =!= I = null + + implicitly[Int =!= Int] +} diff --git a/test/files/neg/incompatibleSettings.check b/test/files/neg/incompatibleSettings.check new file mode 100644 index 0000000000..0f28d41825 --- /dev/null +++ b/test/files/neg/incompatibleSettings.check @@ -0,0 +1,6 @@ +warning: Conflicting compiler settings were detected. Some settings will be ignored. +Compiler settings for the 2.11 optimizer (-optimise) are incompatible with -Ybackend:GenBCode (which is the default in 2.12). +The optimizer settings are ignored. See -Yopt:help for enabling the new optimizer in 2.12. +error: No warnings can be incurred under -Xfatal-warnings. +one warning found +one error found diff --git a/test/files/neg/incompatibleSettings.flags b/test/files/neg/incompatibleSettings.flags new file mode 100644 index 0000000000..00dd9c1c24 --- /dev/null +++ b/test/files/neg/incompatibleSettings.flags @@ -0,0 +1 @@ +-optimise -Ybackend:GenBCode -Xfatal-warnings diff --git a/test/files/neg/incompatibleSettings.scala b/test/files/neg/incompatibleSettings.scala new file mode 100644 index 0000000000..826a1a5bc2 --- /dev/null +++ b/test/files/neg/incompatibleSettings.scala @@ -0,0 +1 @@ +class C diff --git a/test/files/neg/inlineIndyLambdaPrivate.check b/test/files/neg/inlineIndyLambdaPrivate.check new file mode 100644 index 0000000000..dbd142f59e --- /dev/null +++ b/test/files/neg/inlineIndyLambdaPrivate.check @@ -0,0 +1,16 @@ +Test_2.scala:2: warning: A_1::test()Ljava/lang/String; could not be inlined: +The callee A_1::test()Ljava/lang/String; contains the instruction INVOKEDYNAMIC m()LA_1$Fun; [ + // handle kind 0x6 : INVOKESTATIC + java/lang/invoke/LambdaMetafactory.metafactory(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite; + // arguments: + (Ljava/lang/String;)Ljava/lang/String;, + // handle kind 0x6 : INVOKESTATIC + A_1.lambda$test$0(Ljava/lang/String;)Ljava/lang/String;, + (Ljava/lang/String;)Ljava/lang/String; + ] +that would cause an IllegalAccessError when inlined into class Test. + def foo = A_1.test + ^ +error: No warnings can be incurred under -Xfatal-warnings. +one warning found +one error found diff --git a/test/files/neg/inlineIndyLambdaPrivate.flags b/test/files/neg/inlineIndyLambdaPrivate.flags new file mode 100644 index 0000000000..01b466bd8c --- /dev/null +++ b/test/files/neg/inlineIndyLambdaPrivate.flags @@ -0,0 +1 @@ +-Yopt:l:classpath -Yopt-inline-heuristics:everything -Yopt-warnings:_ -Xfatal-warnings
\ No newline at end of file diff --git a/test/files/neg/inlineIndyLambdaPrivate/A_1.java b/test/files/neg/inlineIndyLambdaPrivate/A_1.java new file mode 100644 index 0000000000..a9144a9fa6 --- /dev/null +++ b/test/files/neg/inlineIndyLambdaPrivate/A_1.java @@ -0,0 +1,9 @@ +public class A_1 { + interface Fun { + String m(String s); + } + public static final String test() { + Fun f = s -> s.trim(); + return f.m(" eh "); + } +} diff --git a/test/files/neg/inlineIndyLambdaPrivate/Test_2.scala b/test/files/neg/inlineIndyLambdaPrivate/Test_2.scala new file mode 100644 index 0000000000..dd59c05176 --- /dev/null +++ b/test/files/neg/inlineIndyLambdaPrivate/Test_2.scala @@ -0,0 +1,3 @@ +class Test { + def foo = A_1.test +} diff --git a/test/files/neg/logImplicits.check b/test/files/neg/logImplicits.check index 270882b71a..df7b359767 100644 --- a/test/files/neg/logImplicits.check +++ b/test/files/neg/logImplicits.check @@ -1,10 +1,10 @@ -logImplicits.scala:2: applied implicit conversion from xs.type to ?{def size: ?} = implicit def byteArrayOps(xs: Array[Byte]): scala.collection.mutable.ArrayOps[Byte] +logImplicits.scala:2: applied implicit conversion from xs.type to ?{def size: ?} = implicit def _byteArrayOps(xs: Array[Byte]): scala.collection.mutable.ArrayOps.ofByte def f(xs: Array[Byte]) = xs.size ^ logImplicits.scala:7: applied implicit conversion from String("abc") to ?{def map: ?} = implicit def augmentString(x: String): scala.collection.immutable.StringOps def f = "abc" map (_ + 1) ^ -logImplicits.scala:15: inferred view from String("abc") to Int = C.this.convert:(p: String("abc"))Int +logImplicits.scala:15: inferred view from String("abc") to Int = C.this.convert:(p: String)Int math.max(122, x: Int) ^ logImplicits.scala:19: applied implicit conversion from Int(1) to ?{def ->: ?} = implicit def ArrowAssoc[A](self: A): ArrowAssoc[A] diff --git a/test/files/neg/names-defaults-neg.check b/test/files/neg/names-defaults-neg.check index a43bf66811..8a6aafd67a 100644 --- a/test/files/neg/names-defaults-neg.check +++ b/test/files/neg/names-defaults-neg.check @@ -118,68 +118,74 @@ names-defaults-neg.scala:93: warning: the parameter name y has been deprecated. names-defaults-neg.scala:93: error: parameter 'b' is already specified at parameter position 1 deprNam3(y = 10, b = 2) ^ -names-defaults-neg.scala:98: error: unknown parameter name: m +names-defaults-neg.scala:96: warning: naming parameter deprNam4Arg has been deprecated. + deprNam4(deprNam4Arg = null) + ^ +names-defaults-neg.scala:98: warning: naming parameter deprNam5Arg has been deprecated. + deprNam5(deprNam5Arg = null) + ^ +names-defaults-neg.scala:102: error: unknown parameter name: m f3818(y = 1, m = 1) ^ -names-defaults-neg.scala:131: error: reference to var2 is ambiguous; it is both a method parameter and a variable in scope. +names-defaults-neg.scala:135: error: reference to var2 is ambiguous; it is both a method parameter and a variable in scope. delay(var2 = 40) ^ -names-defaults-neg.scala:134: error: missing parameter type for expanded function ((x$1) => a = x$1) +names-defaults-neg.scala:138: error: missing parameter type for expanded function ((x$1) => a = x$1) val taf2: Int => Unit = testAnnFun(a = _, b = get("+")) ^ -names-defaults-neg.scala:134: error: not found: value a +names-defaults-neg.scala:138: error: not found: value a val taf2: Int => Unit = testAnnFun(a = _, b = get("+")) ^ -names-defaults-neg.scala:134: error: not found: value get +names-defaults-neg.scala:138: error: not found: value get val taf2: Int => Unit = testAnnFun(a = _, b = get("+")) ^ -names-defaults-neg.scala:135: error: parameter 'a' is already specified at parameter position 1 +names-defaults-neg.scala:139: error: parameter 'a' is already specified at parameter position 1 val taf3 = testAnnFun(b = _: String, a = get(8)) ^ -names-defaults-neg.scala:136: error: missing parameter type for expanded function ((x$3) => testAnnFun(x$3, ((x$4) => b = x$4))) +names-defaults-neg.scala:140: error: missing parameter type for expanded function ((x$3) => testAnnFun(x$3, ((x$4) => b = x$4))) val taf4: (Int, String) => Unit = testAnnFun(_, b = _) ^ -names-defaults-neg.scala:136: error: missing parameter type for expanded function ((x$4) => b = x$4) +names-defaults-neg.scala:140: error: missing parameter type for expanded function ((x$4) => b = x$4) val taf4: (Int, String) => Unit = testAnnFun(_, b = _) ^ -names-defaults-neg.scala:136: error: not found: value b +names-defaults-neg.scala:140: error: not found: value b val taf4: (Int, String) => Unit = testAnnFun(_, b = _) ^ -names-defaults-neg.scala:144: error: variable definition needs type because 'x' is used as a named argument in its body. +names-defaults-neg.scala:148: error: variable definition needs type because 'x' is used as a named argument in its body. def t3 { var x = t.f(x = 1) } ^ -names-defaults-neg.scala:147: error: variable definition needs type because 'x' is used as a named argument in its body. +names-defaults-neg.scala:151: error: variable definition needs type because 'x' is used as a named argument in its body. object t6 { var x = t.f(x = 1) } ^ -names-defaults-neg.scala:147: warning: failed to determine if 'x = ...' is a named argument or an assignment expression. +names-defaults-neg.scala:151: warning: failed to determine if 'x = ...' is a named argument or an assignment expression. an explicit type is required for the definition mentioned in the error message above. object t6 { var x = t.f(x = 1) } ^ -names-defaults-neg.scala:150: error: variable definition needs type because 'x' is used as a named argument in its body. +names-defaults-neg.scala:154: error: variable definition needs type because 'x' is used as a named argument in its body. class t9 { var x = t.f(x = 1) } ^ -names-defaults-neg.scala:150: warning: failed to determine if 'x = ...' is a named argument or an assignment expression. +names-defaults-neg.scala:154: warning: failed to determine if 'x = ...' is a named argument or an assignment expression. an explicit type is required for the definition mentioned in the error message above. class t9 { var x = t.f(x = 1) } ^ -names-defaults-neg.scala:164: error: variable definition needs type because 'x' is used as a named argument in its body. +names-defaults-neg.scala:168: error: variable definition needs type because 'x' is used as a named argument in its body. def u3 { var x = u.f(x = 1) } ^ -names-defaults-neg.scala:167: error: variable definition needs type because 'x' is used as a named argument in its body. +names-defaults-neg.scala:171: error: variable definition needs type because 'x' is used as a named argument in its body. def u6 { var x = u.f(x = "32") } ^ -names-defaults-neg.scala:170: error: reference to x is ambiguous; it is both a method parameter and a variable in scope. +names-defaults-neg.scala:174: error: reference to x is ambiguous; it is both a method parameter and a variable in scope. def u9 { var x: Int = u.f(x = 1) } ^ -names-defaults-neg.scala:177: error: variable definition needs type because 'x' is used as a named argument in its body. +names-defaults-neg.scala:181: error: variable definition needs type because 'x' is used as a named argument in its body. class u15 { var x = u.f(x = 1) } ^ -names-defaults-neg.scala:177: warning: failed to determine if 'x = ...' is a named argument or an assignment expression. +names-defaults-neg.scala:181: warning: failed to determine if 'x = ...' is a named argument or an assignment expression. an explicit type is required for the definition mentioned in the error message above. class u15 { var x = u.f(x = 1) } ^ -names-defaults-neg.scala:180: error: reference to x is ambiguous; it is both a method parameter and a variable in scope. +names-defaults-neg.scala:184: error: reference to x is ambiguous; it is both a method parameter and a variable in scope. class u18 { var x: Int = u.f(x = 1) } ^ -four warnings found +6 warnings found 46 errors found diff --git a/test/files/neg/names-defaults-neg.scala b/test/files/neg/names-defaults-neg.scala index a97b590bf2..b326d3b5bd 100644 --- a/test/files/neg/names-defaults-neg.scala +++ b/test/files/neg/names-defaults-neg.scala @@ -92,6 +92,10 @@ object Test extends App { def deprNam3(@deprecatedName('x) a: Int, @deprecatedName('y) b: Int) = a + b deprNam3(y = 10, b = 2) + def deprNam4(@deprecatedName('deprNam4Arg) deprNam4Arg: String) = 0 + deprNam4(deprNam4Arg = null) + def deprNam5(@deprecatedName deprNam5Arg: String) = 0 + deprNam5(deprNam5Arg = null) // t3818 def f3818(x: Int = 1, y: Int, z: Int = 1) = 0 diff --git a/test/files/neg/sealed-final-neg.flags b/test/files/neg/sealed-final-neg.flags index cfabf7a5b4..3f0fcd2201 100644 --- a/test/files/neg/sealed-final-neg.flags +++ b/test/files/neg/sealed-final-neg.flags @@ -1 +1 @@ --Xfatal-warnings -Yinline-warnings -optimise
\ No newline at end of file +-Xfatal-warnings -Ybackend:GenASM -Yinline-warnings -optimise
\ No newline at end of file diff --git a/test/files/neg/t4425.flags b/test/files/neg/t4425.flags deleted file mode 100644 index 1182725e86..0000000000 --- a/test/files/neg/t4425.flags +++ /dev/null @@ -1 +0,0 @@ --optimize
\ No newline at end of file diff --git a/test/files/neg/t5639b.flags b/test/files/neg/t5639b.flags new file mode 100644 index 0000000000..90b87663af --- /dev/null +++ b/test/files/neg/t5639b.flags @@ -0,0 +1 @@ +-Xsource:2.11
\ No newline at end of file diff --git a/test/files/neg/t6289.check b/test/files/neg/t6289.check index 989932750f..7b2b4b2d32 100644 --- a/test/files/neg/t6289.check +++ b/test/files/neg/t6289.check @@ -1,9 +1,3 @@ -#partest java6 -t6289/J.java:2: method does not override or implement a method from a supertype - @Override public void foo() { } - ^ -1 error -#partest !java6 t6289/J.java:2: error: method does not override or implement a method from a supertype @Override public void foo() { } ^ diff --git a/test/files/neg/t6323a.check b/test/files/neg/t6323a.check index 261a60ef3c..c4e92d93f0 100644 --- a/test/files/neg/t6323a.check +++ b/test/files/neg/t6323a.check @@ -1,10 +1,10 @@ -t6323a.scala:10: materializing requested scala.reflect.type.ClassTag[Test] using `package`.this.materializeClassTag[Test]() +t6323a.scala:10: materializing requested scala.reflect.type.ClassTag[Test] using scala.reflect.`package`.materializeClassTag[Test]() val lookAtMe = m.reflect(Test("a",List(5))) ^ -t6323a.scala:11: materializing requested reflect.runtime.universe.type.TypeTag[Test] using `package`.this.materializeTypeTag[Test](scala.reflect.runtime.`package`.universe) +t6323a.scala:11: materializing requested reflect.runtime.universe.type.TypeTag[Test] using scala.reflect.api.`package`.materializeTypeTag[Test](scala.reflect.runtime.`package`.universe) val value = u.typeOf[Test] ^ -t6323a.scala:11: `package`.this.materializeTypeTag[Test](scala.reflect.runtime.`package`.universe) is not a valid implicit value for reflect.runtime.universe.TypeTag[Test] because: +t6323a.scala:11: scala.reflect.api.`package`.materializeTypeTag[Test](scala.reflect.runtime.`package`.universe) is not a valid implicit value for reflect.runtime.universe.TypeTag[Test] because: failed to typecheck the materialized tag: cannot create a TypeTag referring to class Test.Test local to the reifee: use WeakTypeTag instead val value = u.typeOf[Test] diff --git a/test/files/neg/t6810.check b/test/files/neg/t6810.check new file mode 100644 index 0000000000..497ef35070 --- /dev/null +++ b/test/files/neg/t6810.check @@ -0,0 +1,28 @@ +t6810.scala:4: error: unclosed character literal + val y = ' + ^ +t6810.scala:5: error: unclosed character literal +' // but not embedded EOL sequences not represented as escapes +^ +t6810.scala:9: error: unclosed string literal + val Y = " + ^ +t6810.scala:10: error: unclosed string literal +" // obviously not +^ +t6810.scala:20: error: unclosed quoted identifier + val ` + ^ +t6810.scala:21: error: unclosed quoted identifier +` = EOL // not raw string literals aka triple-quoted, multiline strings +^ +t6810.scala:24: error: unclosed character literal + val b = ' + ^ +t6810.scala:25: error: unclosed character literal +' // CR seen as EOL by scanner +^ +t6810.scala:24: error: '=' expected but ';' found. + val b = ' +^ +9 errors found diff --git a/test/files/neg/t6810.scala b/test/files/neg/t6810.scala new file mode 100644 index 0000000000..50c305d70c --- /dev/null +++ b/test/files/neg/t6810.scala @@ -0,0 +1,26 @@ + +trait t6810 { + val x = '\u000A' // char literals accept arbitrary unicode escapes + val y = ' +' // but not embedded EOL sequences not represented as escapes + val z = '\n' // normally, expect this escape + + val X = "\u000A" // it's the same as ordinary string literals + val Y = " +" // obviously not + val Z = "\n" // normally, expect this escape + + val A = """ +""" // which is what these are for + val B = s""" +""" // or the same for interpolated strings + + import scala.compat.Platform.EOL + val `\u000A` = EOL // backquoted identifiers are arbitrary string literals + val ` +` = EOL // not raw string literals aka triple-quoted, multiline strings + + val a = '\u000D' // similar treatment of CR + val b = '
' // CR seen as EOL by scanner + val c = '\r' // traditionally +} diff --git a/test/files/neg/t8764.check b/test/files/neg/t8764.check deleted file mode 100644 index 6d89ebe106..0000000000 --- a/test/files/neg/t8764.check +++ /dev/null @@ -1,6 +0,0 @@ -t8764.scala:8: error: type mismatch; - found : AnyVal - required: Double - val d: Double = a.productElement(0) - ^ -one error found diff --git a/test/files/neg/t8764.flags b/test/files/neg/t8764.flags deleted file mode 100644 index 48fd867160..0000000000 --- a/test/files/neg/t8764.flags +++ /dev/null @@ -1 +0,0 @@ --Xexperimental diff --git a/test/files/neg/t8764.scala b/test/files/neg/t8764.scala deleted file mode 100644 index dc5bfb0160..0000000000 --- a/test/files/neg/t8764.scala +++ /dev/null @@ -1,9 +0,0 @@ -object Main { - - case class IntAndDouble(i: Int, d: Double) - - // a.productElement used to be Int => Double - // now: Int => AnyVal - val a = IntAndDouble(1, 5.0) - val d: Double = a.productElement(0) -} diff --git a/test/files/neg/t8849.check b/test/files/neg/t8849.check new file mode 100644 index 0000000000..15b00aee8b --- /dev/null +++ b/test/files/neg/t8849.check @@ -0,0 +1,7 @@ +t8849.scala:8: error: ambiguous implicit values: + both value global in object Implicits of type => scala.concurrent.ExecutionContext + and value dummy of type scala.concurrent.ExecutionContext + match expected type scala.concurrent.ExecutionContext + require(implicitly[ExecutionContext] eq dummy) + ^ +one error found diff --git a/test/files/neg/t8849.scala b/test/files/neg/t8849.scala new file mode 100644 index 0000000000..336f16b40f --- /dev/null +++ b/test/files/neg/t8849.scala @@ -0,0 +1,10 @@ +import scala.concurrent.ExecutionContext +import ExecutionContext.Implicits.global + +object Test { + def main(args: Array[String]): Unit = { + implicit val dummy: ExecutionContext = null + require(scala.concurrent.ExecutionContext.Implicits.global ne null) + require(implicitly[ExecutionContext] eq dummy) + } +}
\ No newline at end of file diff --git a/test/files/neg/warn-unused-imports.check b/test/files/neg/warn-unused-imports.check index 36c6dd03c3..0a53d7a9cd 100644 --- a/test/files/neg/warn-unused-imports.check +++ b/test/files/neg/warn-unused-imports.check @@ -1,33 +1,55 @@ -warn-unused-imports.scala:57: warning: Unused import +warn-unused-imports_2.scala:133: error: type mismatch; + found : Int(42) + required: Sample.X + f(42) // error + ^ +warn-unused-imports_2.scala:57: warning: Unused import import p1.A // warn ^ -warn-unused-imports.scala:62: warning: Unused import +warn-unused-imports_2.scala:62: warning: Unused import import p1.{ A, B } // warn on A ^ -warn-unused-imports.scala:67: warning: Unused import +warn-unused-imports_2.scala:67: warning: Unused import import p1.{ A, B } // warn on both ^ -warn-unused-imports.scala:67: warning: Unused import +warn-unused-imports_2.scala:67: warning: Unused import import p1.{ A, B } // warn on both ^ -warn-unused-imports.scala:73: warning: Unused import +warn-unused-imports_2.scala:73: warning: Unused import import c._ // warn ^ -warn-unused-imports.scala:78: warning: Unused import +warn-unused-imports_2.scala:78: warning: Unused import import p1._ // warn ^ -warn-unused-imports.scala:85: warning: Unused import +warn-unused-imports_2.scala:85: warning: Unused import import c._ // warn ^ -warn-unused-imports.scala:91: warning: Unused import +warn-unused-imports_2.scala:91: warning: Unused import import p1.c._ // warn ^ -warn-unused-imports.scala:98: warning: Unused import +warn-unused-imports_2.scala:98: warning: Unused import import p1._ // warn ^ -warn-unused-imports.scala:118: warning: Unused import +warn-unused-imports_2.scala:118: warning: Unused import import p1.A // warn ^ -error: No warnings can be incurred under -Xfatal-warnings. -10 warnings found +warn-unused-imports_2.scala:132: warning: Unused import + import Sample.Implicits._ // warn + ^ +warn-unused-imports_2.scala:143: warning: Unused import + import Sample.Implicits.useless // warn + ^ +warn-unused-imports_2.scala:147: warning: Unused import + import java.io.File // warn + ^ +warn-unused-imports_2.scala:148: warning: Unused import + import scala.concurrent.Future // warn + ^ +warn-unused-imports_2.scala:149: warning: Unused import + import scala.concurrent.ExecutionContext.Implicits.global // warn + ^ +warn-unused-imports_2.scala:150: warning: Unused import + import p1.A // warn + ^ +16 warnings found one error found diff --git a/test/files/neg/warn-unused-imports/sample_1.scala b/test/files/neg/warn-unused-imports/sample_1.scala new file mode 100644 index 0000000000..d2f86239db --- /dev/null +++ b/test/files/neg/warn-unused-imports/sample_1.scala @@ -0,0 +1,17 @@ + +import language._ + +object Sample { + trait X + trait Y + + // import of the non-implicit should be unused + object Implicits { + def `int to X`(i: Int): X = null + implicit def `int to Y`(i: Int): Y = null + implicit def useless(i: Int): String = null + } + + def f(x: X) = ??? + def g(y: Y) = ??? +} diff --git a/test/files/neg/warn-unused-imports.scala b/test/files/neg/warn-unused-imports/warn-unused-imports_2.scala index b7a2f1c414..ded1186209 100644 --- a/test/files/neg/warn-unused-imports.scala +++ b/test/files/neg/warn-unused-imports/warn-unused-imports_2.scala @@ -123,3 +123,33 @@ trait Nested { println(new Warn { }) } } + +// test unusage of imports from other compilation units after implicit search +trait Outsiders { + { + //implicit search should not disable warning + import Sample._ + import Sample.Implicits._ // warn + f(42) // error + } + { + import Sample._ + import Sample.Implicits._ // nowarn + g(42) // ok + } + { + import Sample._ + import Sample.Implicits.`int to Y` // nowarn + import Sample.Implicits.useless // warn + g(42) // ok + } + { + import java.io.File // warn + import scala.concurrent.Future // warn + import scala.concurrent.ExecutionContext.Implicits.global // warn + import p1.A // warn + import p1.B // no warn + println("abc".bippy) + //Future("abc".bippy) + } +} |