diff options
Diffstat (limited to 'test/files/neg')
48 files changed, 443 insertions, 13 deletions
diff --git a/test/files/neg/divergent-implicit.check b/test/files/neg/divergent-implicit.check index 60d876409f..d4a3ddfc71 100644 --- a/test/files/neg/divergent-implicit.check +++ b/test/files/neg/divergent-implicit.check @@ -3,6 +3,10 @@ divergent-implicit.scala:4: error: type mismatch; required: String val x1: String = 1 ^ +divergent-implicit.scala:5: error: diverging implicit expansion for type Int => String +starting with method $conforms in object Predef + val x2: String = cast[Int, String](1) + ^ divergent-implicit.scala:14: error: type mismatch; found : Test2.Foo required: Test2.Bar @@ -13,4 +17,4 @@ divergent-implicit.scala:15: error: type mismatch; required: Test2.Bar val y: Bar = new Baz ^ -three errors found +four errors found diff --git a/test/files/neg/macro-incompatible-macro-engine-a.check b/test/files/neg/macro-incompatible-macro-engine-a.check new file mode 100644 index 0000000000..8ae08bd164 --- /dev/null +++ b/test/files/neg/macro-incompatible-macro-engine-a.check @@ -0,0 +1,7 @@ +Test_3.scala:2: error: macro cannot be expanded, because it was compiled by an incompatible macro engine + Macros.foo + ^ +Test_3.scala:3: error: macro cannot be expanded, because it was compiled by an incompatible macro engine + Macros.foo + ^ +two errors found diff --git a/test/files/neg/macro-incompatible-macro-engine/Macros_2.flags b/test/files/neg/macro-incompatible-macro-engine-a/Macros_2.flags index 966df731d0..966df731d0 100644 --- a/test/files/neg/macro-incompatible-macro-engine/Macros_2.flags +++ b/test/files/neg/macro-incompatible-macro-engine-a/Macros_2.flags diff --git a/test/files/neg/macro-incompatible-macro-engine/Macros_2.scala b/test/files/neg/macro-incompatible-macro-engine-a/Macros_2.scala index 39708eee49..39708eee49 100644 --- a/test/files/neg/macro-incompatible-macro-engine/Macros_2.scala +++ b/test/files/neg/macro-incompatible-macro-engine-a/Macros_2.scala diff --git a/test/files/neg/macro-incompatible-macro-engine/Plugin_1.scala b/test/files/neg/macro-incompatible-macro-engine-a/Plugin_1.scala index 44ed91d2fb..44ed91d2fb 100644 --- a/test/files/neg/macro-incompatible-macro-engine/Plugin_1.scala +++ b/test/files/neg/macro-incompatible-macro-engine-a/Plugin_1.scala diff --git a/test/files/neg/macro-incompatible-macro-engine/Test_3.scala b/test/files/neg/macro-incompatible-macro-engine-a/Test_3.scala index 7e4fae5236..7e4fae5236 100644 --- a/test/files/neg/macro-incompatible-macro-engine/Test_3.scala +++ b/test/files/neg/macro-incompatible-macro-engine-a/Test_3.scala diff --git a/test/files/neg/macro-incompatible-macro-engine/scalac-plugin.xml b/test/files/neg/macro-incompatible-macro-engine-a/scalac-plugin.xml index 42b9cdd75d..42b9cdd75d 100644 --- a/test/files/neg/macro-incompatible-macro-engine/scalac-plugin.xml +++ b/test/files/neg/macro-incompatible-macro-engine-a/scalac-plugin.xml diff --git a/test/files/neg/macro-incompatible-macro-engine-b.check b/test/files/neg/macro-incompatible-macro-engine-b.check new file mode 100644 index 0000000000..2a7510cf86 --- /dev/null +++ b/test/files/neg/macro-incompatible-macro-engine-b.check @@ -0,0 +1,7 @@ +Test_3.scala:2: error: macro cannot be expanded, because it was compiled by an incompatible macro engine (internal diagnostic: expected = v7.0 (implemented in Scala 2.11.0-M8), actual = vxxx (implemented in the incompatibleMacroEngine plugin)) + Macros.foo + ^ +Test_3.scala:3: error: macro cannot be expanded, because it was compiled by an incompatible macro engine (internal diagnostic: expected = v7.0 (implemented in Scala 2.11.0-M8), actual = vxxx (implemented in the incompatibleMacroEngine plugin)) + Macros.foo + ^ +two errors found diff --git a/test/files/neg/macro-incompatible-macro-engine-b.flags b/test/files/neg/macro-incompatible-macro-engine-b.flags new file mode 100644 index 0000000000..037a693bbd --- /dev/null +++ b/test/files/neg/macro-incompatible-macro-engine-b.flags @@ -0,0 +1 @@ +-Ymacro-debug-lite
\ No newline at end of file diff --git a/test/files/neg/macro-incompatible-macro-engine-b/Macros_2.flags b/test/files/neg/macro-incompatible-macro-engine-b/Macros_2.flags new file mode 100644 index 0000000000..966df731d0 --- /dev/null +++ b/test/files/neg/macro-incompatible-macro-engine-b/Macros_2.flags @@ -0,0 +1 @@ +-Xplugin:.
\ No newline at end of file diff --git a/test/files/neg/macro-incompatible-macro-engine-b/Macros_2.scala b/test/files/neg/macro-incompatible-macro-engine-b/Macros_2.scala new file mode 100644 index 0000000000..39708eee49 --- /dev/null +++ b/test/files/neg/macro-incompatible-macro-engine-b/Macros_2.scala @@ -0,0 +1,7 @@ +import scala.language.experimental.macros +import scala.reflect.macros.blackbox.Context + +object Macros { + def impl(c: Context) = c.universe.Literal(c.universe.Constant(())) + def foo: Unit = macro impl +}
\ No newline at end of file diff --git a/test/files/neg/macro-incompatible-macro-engine-b/Plugin_1.scala b/test/files/neg/macro-incompatible-macro-engine-b/Plugin_1.scala new file mode 100644 index 0000000000..44ed91d2fb --- /dev/null +++ b/test/files/neg/macro-incompatible-macro-engine-b/Plugin_1.scala @@ -0,0 +1,35 @@ +package incompatibleMacroEngine + +import scala.tools.nsc.Global +import scala.tools.nsc.plugins.{Plugin => NscPlugin} + +class Plugin(val global: Global) extends NscPlugin { + import global._ + import analyzer._ + + val name = "incompatibleMacroEngine" + val description = "A sample analyzer plugin that crafts a macro impl binding with a non-standard macro engine." + val components = Nil + addMacroPlugin(MacroPlugin) + + object MacroPlugin extends MacroPlugin { + def fixupBinding(tree: Tree) = new Transformer { + override def transform(tree: Tree) = { + tree match { + case Literal(const @ Constant(x)) if tree.tpe == null => tree setType ConstantType(const) + case _ if tree.tpe == null => tree setType NoType + case _ => ; + } + super.transform(tree) + } + }.transform(tree) + + override def pluginsTypedMacroBody(typer: Typer, ddef: DefDef): Option[Tree] = { + val result = standardTypedMacroBody(typer, ddef) + val List(AnnotationInfo(atp, List(Apply(nucleus, _ :: others)), Nil)) = ddef.symbol.annotations + val updatedBinding = Apply(nucleus, Assign(Literal(Constant("macroEngine")), Literal(Constant("vxxx (implemented in the incompatibleMacroEngine plugin)"))) :: others) + ddef.symbol.setAnnotations(List(AnnotationInfo(atp, List(fixupBinding(updatedBinding)), Nil))) + Some(result) + } + } +}
\ No newline at end of file diff --git a/test/files/neg/macro-incompatible-macro-engine-b/Test_3.scala b/test/files/neg/macro-incompatible-macro-engine-b/Test_3.scala new file mode 100644 index 0000000000..7e4fae5236 --- /dev/null +++ b/test/files/neg/macro-incompatible-macro-engine-b/Test_3.scala @@ -0,0 +1,4 @@ +object Test extends App { + Macros.foo + Macros.foo +}
\ No newline at end of file diff --git a/test/files/neg/macro-incompatible-macro-engine-b/scalac-plugin.xml b/test/files/neg/macro-incompatible-macro-engine-b/scalac-plugin.xml new file mode 100644 index 0000000000..42b9cdd75d --- /dev/null +++ b/test/files/neg/macro-incompatible-macro-engine-b/scalac-plugin.xml @@ -0,0 +1,4 @@ +<plugin> + <name>incompatible-macro-engine</name> + <classname>incompatibleMacroEngine.Plugin</classname> +</plugin>
\ No newline at end of file diff --git a/test/files/neg/macro-incompatible-macro-engine-c.check b/test/files/neg/macro-incompatible-macro-engine-c.check new file mode 100644 index 0000000000..fb6c59ab7c --- /dev/null +++ b/test/files/neg/macro-incompatible-macro-engine-c.check @@ -0,0 +1,4 @@ +macro-incompatible-macro-engine-c.scala:2: error: can't expand macros compiled by previous versions of Scala + MacroLibCompiledByScala210x.foo + ^ +one error found diff --git a/test/files/neg/macro-incompatible-macro-engine-c.scala b/test/files/neg/macro-incompatible-macro-engine-c.scala new file mode 100644 index 0000000000..037ac5f456 --- /dev/null +++ b/test/files/neg/macro-incompatible-macro-engine-c.scala @@ -0,0 +1,3 @@ +object Test extends App { + MacroLibCompiledByScala210x.foo +}
\ No newline at end of file diff --git a/test/files/neg/macro-incompatible-macro-engine.check b/test/files/neg/macro-incompatible-macro-engine.check deleted file mode 100644 index 1d582e5ed6..0000000000 --- a/test/files/neg/macro-incompatible-macro-engine.check +++ /dev/null @@ -1,7 +0,0 @@ -Test_3.scala:2: error: macro cannot be expanded, because it was compiled by an incompatible macro engine vxxx (implemented in the incompatibleMacroEngine plugin) - Macros.foo - ^ -Test_3.scala:3: error: macro cannot be expanded, because it was compiled by an incompatible macro engine vxxx (implemented in the incompatibleMacroEngine plugin) - Macros.foo - ^ -two errors found diff --git a/test/files/neg/quasiquotes-syntax-error-position.check b/test/files/neg/quasiquotes-syntax-error-position.check index fd55bd25b5..9fd6ce0417 100644 --- a/test/files/neg/quasiquotes-syntax-error-position.check +++ b/test/files/neg/quasiquotes-syntax-error-position.check @@ -32,4 +32,16 @@ quasiquotes-syntax-error-position.scala:14: error: ')' expected but end of quote quasiquotes-syntax-error-position.scala:15: error: ':' expected but ')' found. q"def foo(x)" ^ -11 errors found +quasiquotes-syntax-error-position.scala:16: error: illegal start of simple expression + q"$a(])" + ^ +quasiquotes-syntax-error-position.scala:17: error: in XML literal: '>' expected instead of '$' + q"foo bar <xml$a>" + ^ +quasiquotes-syntax-error-position.scala:19: error: ';' expected but '<:' found. + q"val $x: $x <: $x" + ^ +quasiquotes-syntax-error-position.scala:20: error: '=' expected but '.' found. + q"def f ( $x ) . $x" + ^ +15 errors found diff --git a/test/files/neg/quasiquotes-syntax-error-position.scala b/test/files/neg/quasiquotes-syntax-error-position.scala index 7b1d66ba00..823fe9a551 100644 --- a/test/files/neg/quasiquotes-syntax-error-position.scala +++ b/test/files/neg/quasiquotes-syntax-error-position.scala @@ -13,4 +13,9 @@ object test extends App { cq"pattern => body ; case pattern2 =>" pq"$a(bar" q"def foo(x)" + q"$a(])" + q"foo bar <xml$a>" + val x = q"x" + q"val $x: $x <: $x" + q"def f ( $x ) . $x" } diff --git a/test/files/neg/t4728.check b/test/files/neg/t4728.check new file mode 100644 index 0000000000..c6ef182d34 --- /dev/null +++ b/test/files/neg/t4728.check @@ -0,0 +1,7 @@ +t4728.scala:10: error: ambiguous reference to overloaded definition, +both method f in object Ambiguous of type (ys: Y*)Int +and method f in object Ambiguous of type (x: X)Int +match argument types (Y) and expected result type Any + println(Ambiguous.f(new Y)) + ^ +one error found diff --git a/test/files/neg/t4728.scala b/test/files/neg/t4728.scala new file mode 100644 index 0000000000..36f7860613 --- /dev/null +++ b/test/files/neg/t4728.scala @@ -0,0 +1,11 @@ +class X +class Y extends X +object Ambiguous { + def f(x: X) = 1 + def f(ys: Y*) = 2 +} + +object Test extends App { + println(Ambiguous.f(new X)) + println(Ambiguous.f(new Y)) +}
\ No newline at end of file diff --git a/test/files/neg/t5148.check b/test/files/neg/t5148.check index f426bd2010..8a667f4b88 100644 --- a/test/files/neg/t5148.check +++ b/test/files/neg/t5148.check @@ -1,5 +1,5 @@ -error: bad symbolic reference. A signature in Imports.class refers to type Request -in class scala.tools.nsc.interpreter.IMain which is not available. -It may be completely missing from the current classpath, or the version on -the classpath might be incompatible with the version used when compiling Imports.class. +error: bad symbolic reference to scala.tools.nsc.interpreter.IMain.Request encountered in class file 'Imports.class'. +Cannot access type Request in class scala.tools.nsc.interpreter.IMain. The current classpath may be +missing a definition for scala.tools.nsc.interpreter.IMain.Request, or Imports.class may have been compiled against a version that's +incompatible with the one found on the current classpath. one error found diff --git a/test/files/neg/t6988.check b/test/files/neg/t6988.check new file mode 100644 index 0000000000..acb7b3cb08 --- /dev/null +++ b/test/files/neg/t6988.check @@ -0,0 +1,7 @@ +t6988.scala:3: error: annotation argument needs to be a constant; found: 13.asInstanceOf[Long] +@SerialVersionUID(13.asInstanceOf[Long]) case class IdentifyMessage1(userName: String, user: User, code: Int) + ^ +t6988.scala:8: error: annotation argument needs to be a constant; found: O.SerialUID +@SerialVersionUID(O.SerialUID) case class IdentifyMessage3(userName: String, user: User, code: Int) + ^ +two errors found diff --git a/test/files/neg/t6988.scala b/test/files/neg/t6988.scala new file mode 100644 index 0000000000..8171dc9dd0 --- /dev/null +++ b/test/files/neg/t6988.scala @@ -0,0 +1,10 @@ +case class User() + +@SerialVersionUID(13.asInstanceOf[Long]) case class IdentifyMessage1(userName: String, user: User, code: Int) +@SerialVersionUID(13l) case class IdentifyMessage2(userName: String, user: User, code: Int) +object O { + val SerialUID = "13".toLong +} +@SerialVersionUID(O.SerialUID) case class IdentifyMessage3(userName: String, user: User, code: Int) + + diff --git a/test/files/neg/t8265.check b/test/files/neg/t8265.check new file mode 100644 index 0000000000..7b1db1c4e5 --- /dev/null +++ b/test/files/neg/t8265.check @@ -0,0 +1,6 @@ +t8265.scala:1: warning: Construct depends on unsound variance analysis and will not compile in scala 2.11 and beyond +class Foo[+CC[X]] { type Coll = CC[_] } + ^ +error: No warnings can be incurred under -Xfatal-warnings. +one warning found +one error found diff --git a/test/files/neg/t8265.flags b/test/files/neg/t8265.flags new file mode 100644 index 0000000000..9d7ba7abd8 --- /dev/null +++ b/test/files/neg/t8265.flags @@ -0,0 +1 @@ +-Xsource:2.10 -deprecation -language:higherKinds -Xfatal-warnings diff --git a/test/files/neg/t8265.scala b/test/files/neg/t8265.scala new file mode 100644 index 0000000000..a215903ebc --- /dev/null +++ b/test/files/neg/t8265.scala @@ -0,0 +1 @@ +class Foo[+CC[X]] { type Coll = CC[_] } diff --git a/test/files/neg/t8325-b.check b/test/files/neg/t8325-b.check new file mode 100644 index 0000000000..ec80826dc0 --- /dev/null +++ b/test/files/neg/t8325-b.check @@ -0,0 +1,10 @@ +t8325-b.scala:3: error: Unmatched closing brace '}' ignored here + def k(is: Int*} = ??? + ^ +t8325-b.scala:3: error: ';' expected but '=' found. + def k(is: Int*} = ??? + ^ +t8325-b.scala:4: error: eof expected but '}' found. +} +^ +three errors found diff --git a/test/files/neg/t8325-b.scala b/test/files/neg/t8325-b.scala new file mode 100644 index 0000000000..6ac78708bb --- /dev/null +++ b/test/files/neg/t8325-b.scala @@ -0,0 +1,4 @@ + +trait Test { + def k(is: Int*} = ??? +} diff --git a/test/files/neg/t8325-c.check b/test/files/neg/t8325-c.check new file mode 100644 index 0000000000..51ea4988a6 --- /dev/null +++ b/test/files/neg/t8325-c.check @@ -0,0 +1,7 @@ +t8325-c.scala:3: error: identifier expected but ')' found. + def k(xx: Int`*`) = ??? + ^ +t8325-c.scala:4: error: ')' expected but '}' found. +} +^ +two errors found diff --git a/test/files/neg/t8325-c.scala b/test/files/neg/t8325-c.scala new file mode 100644 index 0000000000..076202df3f --- /dev/null +++ b/test/files/neg/t8325-c.scala @@ -0,0 +1,4 @@ + +trait Test { + def k(xx: Int`*`) = ??? +} diff --git a/test/files/neg/t8325.check b/test/files/neg/t8325.check new file mode 100644 index 0000000000..175a0db415 --- /dev/null +++ b/test/files/neg/t8325.check @@ -0,0 +1,15 @@ +t8325.scala:5: error: *-parameter must come last + def f(is: Int*, s: String) = ??? + ^ +t8325.scala:7: error: *-parameter must come last + def h(is: Int * String *, s: String) = ??? + ^ +t8325.scala:10: error: type mismatch; + found : Int(5) + required: Int* + def j(is: Int* = 5) = ??? + ^ +t8325.scala:10: error: a parameter section with a `*'-parameter is not allowed to have default arguments + def j(is: Int* = 5) = ??? + ^ +four errors found diff --git a/test/files/neg/t8325.scala b/test/files/neg/t8325.scala new file mode 100644 index 0000000000..3813797e83 --- /dev/null +++ b/test/files/neg/t8325.scala @@ -0,0 +1,11 @@ + +trait Test { + type OK[A,B] = A Tuple2 B + type *[A,B] = A Tuple2 B + def f(is: Int*, s: String) = ??? + def g(is: Int * String, s: String) = ??? // OK + def h(is: Int * String *, s: String) = ??? + // won't recover from following + //def i(is: Int OK) = ??? //error: identifier expected but ')' found. + def j(is: Int* = 5) = ??? +} diff --git a/test/files/neg/t8372.check b/test/files/neg/t8372.check new file mode 100644 index 0000000000..6a6424a834 --- /dev/null +++ b/test/files/neg/t8372.check @@ -0,0 +1,7 @@ +t8372.scala:7: error: No ClassTag available for T1 + def unzip[T1, T2](a: Array[(T1, T2)]) = a.unzip + ^ +t8372.scala:9: error: No ClassTag available for T1 + def unzip3[T1, T2, T3](a: Array[(T1, T2, T3)]): (Array[T1], Array[T2], Array[T3]) = a.unzip3 + ^ +two errors found diff --git a/test/files/neg/t8372.scala b/test/files/neg/t8372.scala new file mode 100644 index 0000000000..60a674f4d8 --- /dev/null +++ b/test/files/neg/t8372.scala @@ -0,0 +1,10 @@ +class t8372 { + // failed with "error: tpe T1 is an unresolved spliceable type"; that was caused by + // misguided type inference of type parameters in ArrayOps.unzip + // the type inference failed because the order of implicit arguments was wrong + // the evidence that T <: (T1, T2) came as last argument so it couldn't guide the + // type inference early enough + def unzip[T1, T2](a: Array[(T1, T2)]) = a.unzip + // the same as above + def unzip3[T1, T2, T3](a: Array[(T1, T2, T3)]): (Array[T1], Array[T2], Array[T3]) = a.unzip3 +} diff --git a/test/files/neg/t8376.check b/test/files/neg/t8376.check new file mode 100644 index 0000000000..22ed942d51 --- /dev/null +++ b/test/files/neg/t8376.check @@ -0,0 +1,7 @@ +S.scala:2: error: overloaded method value m with alternatives: + (a: J*)Unit <and> + (a: String*)Unit + cannot be applied to (Int) + J.m(0) + ^ +one error found diff --git a/test/files/neg/t8376/J.java b/test/files/neg/t8376/J.java new file mode 100644 index 0000000000..29aa23da84 --- /dev/null +++ b/test/files/neg/t8376/J.java @@ -0,0 +1,4 @@ +class J { + public static void m(String... a) { } + public static void m(J... a) { } +} diff --git a/test/files/neg/t8376/S.scala b/test/files/neg/t8376/S.scala new file mode 100644 index 0000000000..a19f0d3c06 --- /dev/null +++ b/test/files/neg/t8376/S.scala @@ -0,0 +1,4 @@ +object S { + J.m(0) + // the error message should show `T*` in the method signatures rather than `<repeated>[T]` +} diff --git a/test/files/neg/t8430.check b/test/files/neg/t8430.check new file mode 100644 index 0000000000..7c6a73ce53 --- /dev/null +++ b/test/files/neg/t8430.check @@ -0,0 +1,27 @@ +t8430.scala:15: warning: match may not be exhaustive. +It would fail on the following inputs: ??, LetC, LetF, LetL(IntLit), LetP + (tree: Tree) => tree match {case LetL(CharLit) => ??? } + ^ +t8430.scala:16: warning: match may not be exhaustive. +It would fail on the following inputs: ??, LetC, LetF, LetL(IntLit), LetP + (tree: Tree) => tree match {case LetL(CharLit) => ??? } + ^ +t8430.scala:17: warning: match may not be exhaustive. +It would fail on the following inputs: ??, LetC, LetF, LetL(IntLit), LetP + (tree: Tree) => tree match {case LetL(CharLit) => ??? } + ^ +t8430.scala:18: warning: match may not be exhaustive. +It would fail on the following inputs: ??, LetC, LetF, LetL(IntLit), LetP + (tree: Tree) => tree match {case LetL(CharLit) => ??? } + ^ +t8430.scala:19: warning: match may not be exhaustive. +It would fail on the following inputs: ??, LetC, LetF, LetL(IntLit), LetP + (tree: Tree) => tree match {case LetL(CharLit) => ??? } + ^ +t8430.scala:20: warning: match may not be exhaustive. +It would fail on the following inputs: ??, LetC, LetF, LetL(IntLit), LetP + (tree: Tree) => tree match {case LetL(CharLit) => ??? } + ^ +error: No warnings can be incurred under -Xfatal-warnings. +6 warnings found +one error found diff --git a/test/files/neg/t8430.flags b/test/files/neg/t8430.flags new file mode 100644 index 0000000000..85d8eb2ba2 --- /dev/null +++ b/test/files/neg/t8430.flags @@ -0,0 +1 @@ +-Xfatal-warnings diff --git a/test/files/neg/t8430.scala b/test/files/neg/t8430.scala new file mode 100644 index 0000000000..4166b08a0a --- /dev/null +++ b/test/files/neg/t8430.scala @@ -0,0 +1,32 @@ +sealed trait CL3Literal +case object IntLit extends CL3Literal +case object CharLit extends CL3Literal +case object BooleanLit extends CL3Literal +case object UnitLit extends CL3Literal + + +sealed trait Tree +case class LetL(value: CL3Literal) extends Tree +case object LetP extends Tree +case object LetC extends Tree +case object LetF extends Tree + +object Test { + (tree: Tree) => tree match {case LetL(CharLit) => ??? } + (tree: Tree) => tree match {case LetL(CharLit) => ??? } + (tree: Tree) => tree match {case LetL(CharLit) => ??? } + (tree: Tree) => tree match {case LetL(CharLit) => ??? } + (tree: Tree) => tree match {case LetL(CharLit) => ??? } + (tree: Tree) => tree match {case LetL(CharLit) => ??? } + // After the first patch for SI-8430, we achieve stability: all of + // these get the same warning: + // + // ??, LetC, LetF, LetL(IntLit), LetP + // + // Before, it was non-deterministic. + // + // However, we our list of counter examples is itself non-exhaustive. + // We need to rework counter example generation to fix that. + // + // That work is the subject of SI-7746 +} diff --git a/test/files/neg/t8431.check b/test/files/neg/t8431.check new file mode 100644 index 0000000000..75351a8ae7 --- /dev/null +++ b/test/files/neg/t8431.check @@ -0,0 +1,27 @@ +t8431.scala:24: error: type mismatch; + found : CanBuildFrom[Invariant[Nothing]] + required: CanBuildFrom[Invariant[G]] + s.combined // fail + ^ +t8431.scala:24: error: value combined is not a member of Invariant[Nothing] + s.combined // fail + ^ +t8431.scala:35: error: type mismatch; + found : CanBuildFrom[Invariant[Nothing]] + required: CanBuildFrom[Invariant[G]] + s.combined // was okay! + ^ +t8431.scala:35: error: value combined is not a member of Invariant[Nothing] + s.combined // was okay! + ^ +t8431.scala:45: error: type mismatch; + found : CanBuildFrom[Invariant[Nothing]] + required: CanBuildFrom[Invariant[G]] + convert2(s).combined + ^ +t8431.scala:48: error: type mismatch; + found : CanBuildFrom[Invariant[Nothing]] + required: CanBuildFrom[Invariant[G]] + {val c1 = convert2(s); c1.combined} + ^ +6 errors found diff --git a/test/files/neg/t8431.scala b/test/files/neg/t8431.scala new file mode 100644 index 0000000000..032a1f394d --- /dev/null +++ b/test/files/neg/t8431.scala @@ -0,0 +1,63 @@ +trait Covariant[+A] +trait Invariant[A] extends Covariant[A @annotation.unchecked.uncheckedVariance] + +trait Combinable[G] { + def combined = 0 +} + +trait CanBuildFrom[+C] + +object C { + implicit def convert1[G, TRAVONCE[+e] <: Covariant[e]] + (xs: TRAVONCE[G]): Combinable[G] = ??? + + implicit def convert2[G, SET[e] <: Invariant[e]] + (xs: SET[_ <: G]) + (implicit cbf: CanBuildFrom[SET[G]]): Combinable[G] = ??? + + implicit def cbf[A]: CanBuildFrom[Invariant[A]] = ??? +} +// always failed +class Test1 { + import C.{cbf, convert1, convert2} + val s: Invariant[Nothing] = ??? + s.combined // fail +} +// didn't fail, now correctly fails +class Test2 { + import C.{cbf, convert2, convert1} + + val s: Invariant[Nothing] = ??? + + // Non-uniformity with Test1 was due to order of typechecking implicit candidates: + // the last candidate typechecked was the only one that could contribute undetermined type parameters + // to the enclosing context, due to mutation of `Context#undetparam` in `doTypedApply`. + s.combined // was okay! +} + + +class TestExplicit { + import C.{cbf, convert2} + + val s: Invariant[Nothing] = ??? + + // Now the implicit Test fail uniformly as per this explicit conversion + convert2(s).combined + + // Breaking this expression down doesn't make it work. + {val c1 = convert2(s); c1.combined} +} + +// These ones work before and after; infering G=Null doesn't need to contribute an undetermined type param. +class Test3 { + import C.{cbf, convert1, convert2} + val s: Invariant[Null] = ??? + s.combined // okay +} + +class Test4 { + import C.{cbf, convert2, convert1} + + val s: Invariant[Null] = ??? + s.combined // okay +} diff --git a/test/files/neg/t8450.check b/test/files/neg/t8450.check new file mode 100644 index 0000000000..eeabb9730c --- /dev/null +++ b/test/files/neg/t8450.check @@ -0,0 +1,6 @@ +t8450.scala:5: warning: implicit numeric widening + def elapsed: Foo = (System.nanoTime - 100L).foo + ^ +error: No warnings can be incurred under -Xfatal-warnings. +one warning found +one error found diff --git a/test/files/neg/t8450.flags b/test/files/neg/t8450.flags new file mode 100644 index 0000000000..9a1332d7af --- /dev/null +++ b/test/files/neg/t8450.flags @@ -0,0 +1 @@ +-Ywarn-numeric-widen -Xfatal-warnings
\ No newline at end of file diff --git a/test/files/neg/t8450.scala b/test/files/neg/t8450.scala new file mode 100644 index 0000000000..f20ed2bc31 --- /dev/null +++ b/test/files/neg/t8450.scala @@ -0,0 +1,12 @@ +trait Foo + +class WarnWidening { + implicit class FooDouble(d: Double) { def foo = new Foo {} } + def elapsed: Foo = (System.nanoTime - 100L).foo +} + +class NoWarnWidening { + implicit class FooLong(l: Long) { def foo = new Foo {} } + implicit class FooDouble(d: Double) { def foo = new Foo {} } + def elapsed: Foo = (System.nanoTime - 100L).foo +} diff --git a/test/files/neg/t8463.check b/test/files/neg/t8463.check new file mode 100644 index 0000000000..1a3eea2870 --- /dev/null +++ b/test/files/neg/t8463.check @@ -0,0 +1,10 @@ +t8463.scala:5: error: type mismatch; + found : Long + required: ?T[Long] +Note that implicit conversions are not applicable because they are ambiguous: + both method longWrapper in class LowPriorityImplicits of type (x: Long)scala.runtime.RichLong + and method ArrowAssoc in object Predef of type [A](self: A)ArrowAssoc[A] + are possible conversion functions from Long to ?T[Long] + insertCell(Foo(5)) + ^ +one error found diff --git a/test/files/neg/t8463.scala b/test/files/neg/t8463.scala new file mode 100644 index 0000000000..7c954fd834 --- /dev/null +++ b/test/files/neg/t8463.scala @@ -0,0 +1,38 @@ +object Test { + case class Foo[+T[_]](activity:T[Long]) + type Cell[T] = T + def insertCell(u:Foo[Cell]) = ??? + insertCell(Foo(5)) +} + +/* If SI-8230 is fixed, and `viewExists` is changed to no longer leak + ambiguity errors, you might expect the check file for this test to + change as folloes: + +@@ -1,18 +1,10 @@ +-t8463.scala:5: error: no type parameters for method apply: (activity: +- --- because --- +-argument expression's type is not compatible with formal parameter ty ++t8463.scala:5: error: type mismatch; + found : Long + required: ?T[Long] ++Note that implicit conversions are not applicable because they are am ++ both method longWrapper in class LowPriorityImplicits of type (x: Lo ++ and method ArrowAssoc in object Predef of type [A](self: A)ArrowAsso ++ are possible conversion functions from Long to ?T[Long] + insertCell(Foo(5)) +- ^ +-t8463.scala:5: error: type mismatch; +- found : Long(5L) +- required: T[Long] +- insertCell(Foo(5)) +- ^ +-t8463.scala:5: error: type mismatch; +- found : Test.Foo[T] +- required: Test.Foo[Test.Cell] +- insertCell(Foo(5)) +- ^ +-three errors found ++ ^ ++one error found +*/ |