diff options
Diffstat (limited to 'test/files/neg')
-rw-r--r-- | test/files/neg/ambiguous-same.check | 6 | ||||
-rw-r--r-- | test/files/neg/ambiguous-same.scala | 15 | ||||
-rw-r--r-- | test/files/neg/specification-scopes.check | 18 | ||||
-rw-r--r-- | test/files/neg/specification-scopes/P_1.scala | 9 | ||||
-rw-r--r-- | test/files/neg/specification-scopes/P_2.scala | 43 | ||||
-rw-r--r-- | test/files/neg/t2712.flags | 1 | ||||
-rw-r--r-- | test/files/neg/t5148.check | 27 | ||||
-rw-r--r-- | test/files/neg/t6889.check | 7 | ||||
-rw-r--r-- | test/files/neg/t6889.scala | 1 | ||||
-rw-r--r-- | test/files/neg/t7475d.check | 7 | ||||
-rw-r--r-- | test/files/neg/t8417.check | 15 | ||||
-rw-r--r-- | test/files/neg/t8417.flags | 1 | ||||
-rw-r--r-- | test/files/neg/t8417.scala | 6 | ||||
-rw-r--r-- | test/files/neg/userdefined_apply.check | 25 | ||||
-rw-r--r-- | test/files/neg/userdefined_apply.scala | 57 |
15 files changed, 180 insertions, 58 deletions
diff --git a/test/files/neg/ambiguous-same.check b/test/files/neg/ambiguous-same.check new file mode 100644 index 0000000000..58f4e60ece --- /dev/null +++ b/test/files/neg/ambiguous-same.check @@ -0,0 +1,6 @@ +ambiguous-same.scala:13: error: reference to x is ambiguous; +it is both defined in object X and imported subsequently by +import X.x + x + ^ +one error found diff --git a/test/files/neg/ambiguous-same.scala b/test/files/neg/ambiguous-same.scala new file mode 100644 index 0000000000..50dba71f67 --- /dev/null +++ b/test/files/neg/ambiguous-same.scala @@ -0,0 +1,15 @@ + +// When faced with ambiguities between imports, +// an attempt is made to see if the imports intend +// identical types. +// +// Here, no attempt is made to notice that x +// names the same thing. +// +object X { + val x = 42 + def f = { + import X.x + x + } +} diff --git a/test/files/neg/specification-scopes.check b/test/files/neg/specification-scopes.check index ab986135e5..49cdbf9232 100644 --- a/test/files/neg/specification-scopes.check +++ b/test/files/neg/specification-scopes.check @@ -1,12 +1,12 @@ -P_2.scala:14: error: reference to x is ambiguous; -it is both defined in object C and imported subsequently by -import Q.X._ - println("L14: "+x) // reference to 'x' is ambiguous here - ^ -P_2.scala:19: error: reference to y is ambiguous; +P_2.scala:15: error: reference to x is ambiguous; +it is both defined in value <local Y> and imported subsequently by +import q.X._ + println(s"L15: $x") // reference to `x' is ambiguous here + ^ +P_2.scala:21: error: reference to y is ambiguous; it is imported twice in the same scope by -import P.X._ +import p.X._ and import X.y - println("L19: "+y) // reference to 'y' is ambiguous here - ^ + println(s"L21: $y") // reference to `y' is ambiguous here + ^ two errors found diff --git a/test/files/neg/specification-scopes/P_1.scala b/test/files/neg/specification-scopes/P_1.scala index 3b11f1167d..50c306fd67 100644 --- a/test/files/neg/specification-scopes/P_1.scala +++ b/test/files/neg/specification-scopes/P_1.scala @@ -1,6 +1,7 @@ -package P { - object X { val x = 1; val y = 2; } +package p { + object X { val x = 1; val y = 2 } } -package Q { - object X { val x = true; val y = "" } + +package q { + object X { val x = true; val y = false } } diff --git a/test/files/neg/specification-scopes/P_2.scala b/test/files/neg/specification-scopes/P_2.scala index d59f82e90d..856e58c6fb 100644 --- a/test/files/neg/specification-scopes/P_2.scala +++ b/test/files/neg/specification-scopes/P_2.scala @@ -1,21 +1,24 @@ -package P { // 'X' bound by package clause - import Console._ // 'println' bound by wildcard import - object A { - println("L4: "+X) // 'X' refers to 'P.X' here - object B { - import Q._ // 'X' bound by wildcard import - println("L7: "+X) // 'X' refers to 'Q.X' here - import X._ // 'x' and 'y' bound by wildcard import - println("L8: "+x) // 'x' refers to 'Q.X.x' here - object C { - val x = 3 // 'x' bound by local definition - println("L12: "+x); // 'x' refers to constant '3' here - { import Q.X._ // 'x' and 'y' bound by wildcard - println("L14: "+x) // reference to 'x' is ambiguous here - import X.y // 'y' bound by explicit import - println("L16: "+y); // 'y' refers to 'Q.X.y' here - { val x = "abc" // 'x' bound by local definition - import P.X._ // 'x' and 'y' bound by wildcard - println("L19: "+y) // reference to 'y' is ambiguous here - println("L20: "+x) // 'x' refers to string ''abc'' here +package p { // `X' bound by package clause +import Console._ // `println' bound by wildcard import +object Y { + println(s"L4: $X") // `X' refers to `p.X' here + locally { + import q._ // `X' bound by wildcard import + println(s"L7: $X") // `X' refers to `q.X' here + import X._ // `x' and `y' bound by wildcard import + println(s"L9: $x") // `x' refers to `q.X.x' here + locally { + val x = 3 // `x' bound by local definition + println(s"L12: $x") // `x' refers to constant `3' here + locally { + import q.X._ // `x' and `y' bound by wildcard import + println(s"L15: $x") // reference to `x' is ambiguous here + import X.y // `y' bound by explicit import + println(s"L17: $y") // `y' refers to `q.X.y' here + locally { + val x = "abc" // `x' bound by local definition + import p.X._ // `x' and `y' bound by wildcard import + println(s"L21: $y") // reference to `y' is ambiguous here + println(s"L22: $x") // `x' refers to string "abc" here }}}}}} + diff --git a/test/files/neg/t2712.flags b/test/files/neg/t2712.flags deleted file mode 100644 index 41565c7e32..0000000000 --- a/test/files/neg/t2712.flags +++ /dev/null @@ -1 +0,0 @@ --Ypartial-unification diff --git a/test/files/neg/t5148.check b/test/files/neg/t5148.check index 1f58c235ce..8c895d7b47 100644 --- a/test/files/neg/t5148.check +++ b/test/files/neg/t5148.check @@ -1,16 +1,13 @@ -error: missing or invalid dependency detected while loading class file 'Imports.class'. -Could not access term memberHandlers in class scala.tools.nsc.interpreter.IMain, -because it (or its dependencies) are missing. Check your build definition for -missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.) +t5148.scala:4: error: Symbol 'term scala.tools.nsc.interpreter.IMain.memberHandlers' is missing from the classpath. +This symbol is required by 'method scala.tools.nsc.interpreter.Imports.allReqAndHandlers'. +Make sure that term memberHandlers is in your classpath and check for conflicting dependencies with `-Ylog-classpath`. A full rebuild may help if 'Imports.class' was compiled against an incompatible version of scala.tools.nsc.interpreter.IMain. -error: missing or invalid dependency detected while loading class file 'Imports.class'. -Could not access type Wrapper in class scala.tools.nsc.interpreter.IMain.Request, -because it (or its dependencies) are missing. Check your build definition for -missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.) -A full rebuild may help if 'Imports.class' was compiled against an incompatible version of scala.tools.nsc.interpreter.IMain.Request. -error: missing or invalid dependency detected while loading class file 'Imports.class'. -Could not access type Request in class scala.tools.nsc.interpreter.IMain, -because it (or its dependencies) are missing. Check your build definition for -missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.) -A full rebuild may help if 'Imports.class' was compiled against an incompatible version of scala.tools.nsc.interpreter.IMain. -three errors found +class IMain extends Imports + ^ +t5148.scala:4: error: Symbol 'type <none>.Request.Wrapper' is missing from the classpath. +This symbol is required by 'value scala.tools.nsc.interpreter.Imports.wrapper'. +Make sure that type Wrapper is in your classpath and check for conflicting dependencies with `-Ylog-classpath`. +A full rebuild may help if 'Imports.class' was compiled against an incompatible version of <none>.Request. +class IMain extends Imports + ^ +two errors found diff --git a/test/files/neg/t6889.check b/test/files/neg/t6889.check index a77e8a010c..c14c3b09c0 100644 --- a/test/files/neg/t6889.check +++ b/test/files/neg/t6889.check @@ -1,7 +1,10 @@ t6889.scala:16: error: the result type of an implicit conversion must be more specific than AnyRef def f(x: Dingo): AnyRef = x // fail - no conversion to AnyRef ^ -t6889.scala:17: error: an expression of type Null is ineligible for implicit conversion +t6889.scala:17: error: the result type of an implicit conversion must be more specific than Object + def f2(x: Dingo): Object = x // fail - no conversion to Object + ^ +t6889.scala:18: error: an expression of type Null is ineligible for implicit conversion var x: Int = null // fail - no conversion from Null ^ -two errors found +three errors found diff --git a/test/files/neg/t6889.scala b/test/files/neg/t6889.scala index ef1963669c..3fc235bf7e 100644 --- a/test/files/neg/t6889.scala +++ b/test/files/neg/t6889.scala @@ -14,5 +14,6 @@ object Test { trait Dingo extends Any with bippy.Bippy[foo.unrelated.Unrelated] def f(x: Dingo): AnyRef = x // fail - no conversion to AnyRef + def f2(x: Dingo): Object = x // fail - no conversion to Object var x: Int = null // fail - no conversion from Null } diff --git a/test/files/neg/t7475d.check b/test/files/neg/t7475d.check deleted file mode 100644 index 6bd1da0d44..0000000000 --- a/test/files/neg/t7475d.check +++ /dev/null @@ -1,7 +0,0 @@ -t7475d.scala:4: error: value priv is not a member of T.this.TT - (??? : TT).priv - ^ -t7475d.scala:10: error: value priv is not a member of U.this.UU - (??? : UU).priv - ^ -two errors found diff --git a/test/files/neg/t8417.check b/test/files/neg/t8417.check new file mode 100644 index 0000000000..6ec9e1d14d --- /dev/null +++ b/test/files/neg/t8417.check @@ -0,0 +1,15 @@ +t8417.scala:5: warning: Adapting argument list by creating a 2-tuple: this may not be what you want. + signature: T.f(x: Any)(y: Any): String + given arguments: "hello", "world" + after adaptation: T.f(("hello", "world"): (String, String)) + def g = f("hello", "world")("holy", "moly") + ^ +t8417.scala:5: warning: Adapting argument list by creating a 2-tuple: this may not be what you want. + signature: T.f(x: Any)(y: Any): String + given arguments: "holy", "moly" + after adaptation: T.f(("holy", "moly"): (String, String)) + def g = f("hello", "world")("holy", "moly") + ^ +error: No warnings can be incurred under -Xfatal-warnings. +two warnings found +one error found diff --git a/test/files/neg/t8417.flags b/test/files/neg/t8417.flags new file mode 100644 index 0000000000..26b215ff2d --- /dev/null +++ b/test/files/neg/t8417.flags @@ -0,0 +1 @@ +-Xfatal-warnings -Ywarn-adapted-args diff --git a/test/files/neg/t8417.scala b/test/files/neg/t8417.scala new file mode 100644 index 0000000000..fb6449c2d1 --- /dev/null +++ b/test/files/neg/t8417.scala @@ -0,0 +1,6 @@ + + +trait T { + def f(x: Any)(y: Any) = "" + x + y + def g = f("hello", "world")("holy", "moly") +} diff --git a/test/files/neg/userdefined_apply.check b/test/files/neg/userdefined_apply.check new file mode 100644 index 0000000000..c8c8976f5f --- /dev/null +++ b/test/files/neg/userdefined_apply.check @@ -0,0 +1,25 @@ +userdefined_apply.scala:3: error: overloaded method apply needs result type + private def apply(x: Int) = if (x > 0) new ClashOverloadNoSig(x) else apply("") + ^ +userdefined_apply.scala:14: error: overloaded method apply needs result type + private def apply(x: Int) = if (x > 0) ClashRecNoSig(1) else ??? + ^ +userdefined_apply.scala:21: error: overloaded method apply needs result type + private def apply(x: Boolean) = if (x) NoClashNoSig(1) else ??? + ^ +userdefined_apply.scala:28: error: overloaded method apply needs result type + private def apply(x: Boolean) = if (x) NoClashOverload(1) else apply("") + ^ +userdefined_apply.scala:45: error: recursive method apply needs result type +case class NoClashNoSigPoly private(x: Int) + ^ +userdefined_apply.scala:39: error: NoClashNoSigPoly.type does not take parameters + def apply(x: T) = if (???) NoClashNoSigPoly(1) else ??? + ^ +userdefined_apply.scala:57: error: recursive method apply needs result type +case class ClashNoSigPoly private(x: Int) + ^ +userdefined_apply.scala:51: error: ClashNoSigPoly.type does not take parameters + def apply(x: T) = if (???) ClashNoSigPoly(1) else ??? + ^ +8 errors found diff --git a/test/files/neg/userdefined_apply.scala b/test/files/neg/userdefined_apply.scala new file mode 100644 index 0000000000..0a0d960b39 --- /dev/null +++ b/test/files/neg/userdefined_apply.scala @@ -0,0 +1,57 @@ +object ClashOverloadNoSig { + // error: overloaded method apply needs result type + private def apply(x: Int) = if (x > 0) new ClashOverloadNoSig(x) else apply("") + + def apply(x: String): ClashOverloadNoSig = ??? +} + +case class ClashOverloadNoSig private(x: Int) + +object ClashRecNoSig { + // TODO: status quo is that the error refers to an overloaded method, which is actually recursive + // (we should have unlinked the symbol in the `if(suppress)` part of `applyUnapplyMethodCompleter`) + // error: recursive method apply needs result type + private def apply(x: Int) = if (x > 0) ClashRecNoSig(1) else ??? +} + +case class ClashRecNoSig private(x: Int) + +object NoClashNoSig { + // error: overloaded method apply needs result type + private def apply(x: Boolean) = if (x) NoClashNoSig(1) else ??? +} + +case class NoClashNoSig private(x: Int) + +object NoClashOverload { + // error: overloaded method apply needs result type + private def apply(x: Boolean) = if (x) NoClashOverload(1) else apply("") + + def apply(x: String): NoClashOverload = ??? +} + +case class NoClashOverload private(x: Int) + + +class BaseNCNSP[T] { + // TODO: suppress the following error + // error: NoClashNoSigPoly.type does not take parameters + def apply(x: T) = if (???) NoClashNoSigPoly(1) else ??? +} + +object NoClashNoSigPoly extends BaseNCNSP[Boolean] +// TODO: position error at definition of apply in superclass instead of on case clss +// error: recursive method apply needs result type +case class NoClashNoSigPoly private(x: Int) + + +class BaseCNSP[T] { + // TODO: suppress the following error + // error: ClashNoSigPoly.type does not take parameters + def apply(x: T) = if (???) ClashNoSigPoly(1) else ??? +} + +object ClashNoSigPoly extends BaseCNSP[Int] +// TODO: position error at definition of apply in superclass instead of on case clss +// error: recursive method apply needs result type +case class ClashNoSigPoly private(x: Int) |