diff options
Diffstat (limited to 'test/files')
46 files changed, 635 insertions, 71 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) diff --git a/test/files/pos/t10206.scala b/test/files/pos/t10206.scala new file mode 100644 index 0000000000..3ddd1ea2fd --- /dev/null +++ b/test/files/pos/t10206.scala @@ -0,0 +1,15 @@ +class Foo(val bar: String) + +object Foo { + implicit class Enrich(foo: Foo) { + def clone(x: Int, y: Int): Int = x + y + } +} + +object Main extends App { + val foo = new Foo("hello") + println(foo.clone(1, 2)) // <- does not compile + // the implicit view was being disqualified because a new check in the compiler + // that implicit views must not target Any or AnyRef considered an implicit search + // for `foo.type => ?{def clone: ?}` to targeted AnyRef. +} diff --git a/test/files/pos/userdefined_apply.scala b/test/files/pos/userdefined_apply.scala new file mode 100644 index 0000000000..e29f9f5141 --- /dev/null +++ b/test/files/pos/userdefined_apply.scala @@ -0,0 +1,54 @@ +// NOTE: the companion inherits a public apply method from Function1! +case class NeedsCompanion private (x: Int) + +object ClashNoSig { // ok + private def apply(x: Int) = if (x > 0) new ClashNoSig(x) else ??? +} +case class ClashNoSig private (x: Int) + + +object Clash { + private def apply(x: Int) = if (x > 0) new Clash(x) else ??? +} +case class Clash private (x: Int) + +object ClashSig { + private def apply(x: Int): ClashSig = if (x > 0) new ClashSig(x) else ??? +} +case class ClashSig private (x: Int) + +object ClashOverload { + private def apply(x: Int): ClashOverload = if (x > 0) new ClashOverload(x) else apply("") + def apply(x: String): ClashOverload = ??? +} +case class ClashOverload private (x: Int) + +object NoClashSig { + private def apply(x: Boolean): NoClashSig = if (x) NoClashSig(1) else ??? +} +case class NoClashSig private (x: Int) + +object NoClashOverload { + // needs full sig + private def apply(x: Boolean): NoClashOverload = if (x) NoClashOverload(1) else apply("") + def apply(x: String): NoClashOverload = ??? +} +case class NoClashOverload private (x: Int) + + + +class BaseNCP[T] { + // error: overloaded method apply needs result type + def apply(x: T): NoClashPoly = if (???) NoClashPoly(1) else ??? +} + +object NoClashPoly extends BaseNCP[Boolean] +case class NoClashPoly private(x: Int) + + +class BaseCP[T] { + // error: overloaded method apply needs result type + def apply(x: T): ClashPoly = if (???) ClashPoly(1) else ??? +} +object ClashPoly extends BaseCP[Int] +case class ClashPoly private(x: Int) diff --git a/test/files/pos/userdefined_apply_poly_overload.scala b/test/files/pos/userdefined_apply_poly_overload.scala new file mode 100644 index 0000000000..6760c1424f --- /dev/null +++ b/test/files/pos/userdefined_apply_poly_overload.scala @@ -0,0 +1,13 @@ +object Foo { + // spurious error if: + // - this definition precedes that of apply (which is overloaded with the synthetic one derived from the case class) + // - AND `Foo.apply` is explicitly applied to `[A]` (no error if `[A]` is inferred) + // + def referToPolyOverloadedApply[A]: Foo[A] = Foo.apply[A]("bla") + // ^ + // found : String("bla") + // required: Int + + def apply[A](x: Int): Foo[A] = ??? +} +case class Foo[A](x: String) // must be polymorphic diff --git a/test/files/run/StubErrorBInheritsFromA.check b/test/files/run/StubErrorBInheritsFromA.check new file mode 100644 index 0000000000..009f0887d4 --- /dev/null +++ b/test/files/run/StubErrorBInheritsFromA.check @@ -0,0 +1,6 @@ +error: newSource1.scala:4: Symbol 'type stuberrors.A' is missing from the classpath. +This symbol is required by 'class stuberrors.B'. +Make sure that type A is in your classpath and check for conflicting dependencies with `-Ylog-classpath`. +A full rebuild may help if 'B.class' was compiled against an incompatible version of stuberrors. + new B + ^ diff --git a/test/files/run/StubErrorBInheritsFromA.scala b/test/files/run/StubErrorBInheritsFromA.scala new file mode 100644 index 0000000000..3e02692171 --- /dev/null +++ b/test/files/run/StubErrorBInheritsFromA.scala @@ -0,0 +1,22 @@ +object Test extends scala.tools.partest.StubErrorMessageTest { + def codeA = """ + package stuberrors + class A + """ + + def codeB = """ + package stuberrors + class B extends A + """ + + def userCode = """ + package stuberrors + class C { + new B + } + """ + + def removeFromClasspath(): Unit = { + removeClasses("stuberrors", List("A")) + } +} diff --git a/test/files/run/StubErrorComplexInnerClass.check b/test/files/run/StubErrorComplexInnerClass.check new file mode 100644 index 0000000000..fe089de8ad --- /dev/null +++ b/test/files/run/StubErrorComplexInnerClass.check @@ -0,0 +1,6 @@ +error: newSource1.scala:9: Symbol 'type stuberrors.A' is missing from the classpath. +This symbol is required by 'class stuberrors.B.BB'. +Make sure that type A is in your classpath and check for conflicting dependencies with `-Ylog-classpath`. +A full rebuild may help if 'B.class' was compiled against an incompatible version of stuberrors. + new b.BB + ^ diff --git a/test/files/run/StubErrorComplexInnerClass.scala b/test/files/run/StubErrorComplexInnerClass.scala new file mode 100644 index 0000000000..2028644601 --- /dev/null +++ b/test/files/run/StubErrorComplexInnerClass.scala @@ -0,0 +1,42 @@ +object Test extends scala.tools.partest.StubErrorMessageTest { + def codeA = """ + package stuberrors + class A + """ + + def codeB = """ + package stuberrors + class B { + def foo: String = ??? + + // unused and should fail, but not loaded + def unsafeFoo: A = ??? + // used, B.info -> BB.info -> unpickling A -> stub error + class BB extends A + } + """ + + def userCode = """ + package stuberrors + class C { + def aloha = { + val b = new B + val d = new extra.D + d.foo + println(b.foo) + new b.BB + } + } + """ + + override def extraUserCode = """ + package extra + class D { + def foo = "Hello, World" + } + """.stripMargin + + def removeFromClasspath(): Unit = { + removeClasses("stuberrors", List("A")) + } +} diff --git a/test/files/run/StubErrorHK.check b/test/files/run/StubErrorHK.check new file mode 100644 index 0000000000..6f37f8ea41 --- /dev/null +++ b/test/files/run/StubErrorHK.check @@ -0,0 +1,6 @@ +error: newSource1.scala:4: Symbol 'type stuberrors.A' is missing from the classpath. +This symbol is required by 'type stuberrors.B.D'. +Make sure that type A is in your classpath and check for conflicting dependencies with `-Ylog-classpath`. +A full rebuild may help if 'B.class' was compiled against an incompatible version of stuberrors. + println(new B) + ^ diff --git a/test/files/run/StubErrorHK.scala b/test/files/run/StubErrorHK.scala new file mode 100644 index 0000000000..7ee8c6d6a5 --- /dev/null +++ b/test/files/run/StubErrorHK.scala @@ -0,0 +1,22 @@ +object Test extends scala.tools.partest.StubErrorMessageTest { + def codeA = """ + package stuberrors + class A + """ + + def codeB = """ + package stuberrors + class B[D <: A] + """ + + def userCode = """ + package stuberrors + object C extends App { + println(new B) + } + """ + + def removeFromClasspath(): Unit = { + removeClasses("stuberrors", List("A")) + } +} diff --git a/test/files/run/StubErrorReturnTypeFunction.check b/test/files/run/StubErrorReturnTypeFunction.check new file mode 100644 index 0000000000..bd61d5f5fa --- /dev/null +++ b/test/files/run/StubErrorReturnTypeFunction.check @@ -0,0 +1,6 @@ +error: newSource1.scala:13: Symbol 'type stuberrors.A' is missing from the classpath. +This symbol is required by 'method stuberrors.B.foo'. +Make sure that type A is in your classpath and check for conflicting dependencies with `-Ylog-classpath`. +A full rebuild may help if 'B.class' was compiled against an incompatible version of stuberrors. + b.foo + ^ diff --git a/test/files/run/StubErrorReturnTypeFunction.scala b/test/files/run/StubErrorReturnTypeFunction.scala new file mode 100644 index 0000000000..75a02cff63 --- /dev/null +++ b/test/files/run/StubErrorReturnTypeFunction.scala @@ -0,0 +1,37 @@ +object Test extends scala.tools.partest.StubErrorMessageTest { + def codeA = """ + package stuberrors + class A + class AA + """ + + def codeB = """ + package stuberrors + + abstract class B { + def bar: String = ??? + def foo: A = new A + def baz: String = ??? + } + """ + + def userCode = """ + package stuberrors + + abstract class C extends App { + val b = new B {} + + // Use other symbols in the meanwhile + val aa = new AA + val dummy = 1 + println(dummy) + + // Should blow up + b.foo + } + """ + + def removeFromClasspath(): Unit = { + removeClasses("stuberrors", List("A")) + } +} diff --git a/test/files/run/StubErrorReturnTypeFunction2.check b/test/files/run/StubErrorReturnTypeFunction2.check new file mode 100644 index 0000000000..bd61d5f5fa --- /dev/null +++ b/test/files/run/StubErrorReturnTypeFunction2.check @@ -0,0 +1,6 @@ +error: newSource1.scala:13: Symbol 'type stuberrors.A' is missing from the classpath. +This symbol is required by 'method stuberrors.B.foo'. +Make sure that type A is in your classpath and check for conflicting dependencies with `-Ylog-classpath`. +A full rebuild may help if 'B.class' was compiled against an incompatible version of stuberrors. + b.foo + ^ diff --git a/test/files/run/StubErrorReturnTypeFunction2.scala b/test/files/run/StubErrorReturnTypeFunction2.scala new file mode 100644 index 0000000000..efb2f4f190 --- /dev/null +++ b/test/files/run/StubErrorReturnTypeFunction2.scala @@ -0,0 +1,37 @@ +object Test extends scala.tools.partest.StubErrorMessageTest { + def codeA = """ + package stuberrors + class A + class AA + """ + + def codeB = """ + package stuberrors + + class B { + def bar: String = ??? + def foo: A = new A + def baz: String = ??? + } + """ + + def userCode = """ + package stuberrors + + abstract class C extends App { + val b = new B {} + + // Use other symbols in the meanwhile + val aa = new AA + val dummy = 1 + println(dummy) + + // Should blow up + b.foo + } + """ + + def removeFromClasspath(): Unit = { + removeClasses("stuberrors", List("A")) + } +} diff --git a/test/files/run/StubErrorReturnTypePolyFunction.check b/test/files/run/StubErrorReturnTypePolyFunction.check new file mode 100644 index 0000000000..78e309668e --- /dev/null +++ b/test/files/run/StubErrorReturnTypePolyFunction.check @@ -0,0 +1,15 @@ +error: newSource1.scala:13: Symbol 'type stuberrors.A' is missing from the classpath. +This symbol is required by 'class stuberrors.D'. +Make sure that type A is in your classpath and check for conflicting dependencies with `-Ylog-classpath`. +A full rebuild may help if 'D.class' was compiled against an incompatible version of stuberrors. + b.foo[D] + ^ +error: newSource1.scala:13: type arguments [stuberrors.D] do not conform to method foo's type parameter bounds [T <: stuberrors.A] + b.foo[D] + ^ +error: newSource1.scala:13: Symbol 'type stuberrors.A' is missing from the classpath. +This symbol is required by 'type stuberrors.B.T'. +Make sure that type A is in your classpath and check for conflicting dependencies with `-Ylog-classpath`. +A full rebuild may help if 'B.class' was compiled against an incompatible version of stuberrors. + b.foo[D] + ^ diff --git a/test/files/run/StubErrorReturnTypePolyFunction.scala b/test/files/run/StubErrorReturnTypePolyFunction.scala new file mode 100644 index 0000000000..8345aaade0 --- /dev/null +++ b/test/files/run/StubErrorReturnTypePolyFunction.scala @@ -0,0 +1,37 @@ +object Test extends scala.tools.partest.StubErrorMessageTest { + def codeA = """ + package stuberrors + class A + class AA + """ + + def codeB = """ + package stuberrors + + class B { + def foo[T <: A]: T = ??? + } + + class D extends A + """ + + def userCode = """ + package stuberrors + + abstract class C extends App { + val b = new B + + // Use other symbols in the meanwhile + val aa = new AA + val dummy = 1 + println(dummy) + + // Should blow up + b.foo[D] + } + """ + + def removeFromClasspath(): Unit = { + removeClasses("stuberrors", List("A")) + } +} diff --git a/test/files/run/StubErrorSubclasses.check b/test/files/run/StubErrorSubclasses.check new file mode 100644 index 0000000000..8ccd781cad --- /dev/null +++ b/test/files/run/StubErrorSubclasses.check @@ -0,0 +1,6 @@ +error: newSource1.scala:3: Symbol 'type stuberrors.A' is missing from the classpath. +This symbol is required by 'class stuberrors.B'. +Make sure that type A is in your classpath and check for conflicting dependencies with `-Ylog-classpath`. +A full rebuild may help if 'B.class' was compiled against an incompatible version of stuberrors. + class C extends B + ^ diff --git a/test/files/run/StubErrorSubclasses.scala b/test/files/run/StubErrorSubclasses.scala new file mode 100644 index 0000000000..b19155e20e --- /dev/null +++ b/test/files/run/StubErrorSubclasses.scala @@ -0,0 +1,21 @@ +object Test extends scala.tools.partest.StubErrorMessageTest { + def codeA = """ + package stuberrors + class A + """ + + def codeB = """ + package stuberrors + class B extends A + """ + + def userCode = """ + package stuberrors + class C extends B + """ + + def removeFromClasspath(): Unit = { + removeClasses("stuberrors", List("A")) + } +} + diff --git a/test/files/run/StubErrorTypeDef.check b/test/files/run/StubErrorTypeDef.check new file mode 100644 index 0000000000..955d9b0880 --- /dev/null +++ b/test/files/run/StubErrorTypeDef.check @@ -0,0 +1,16 @@ +error: newSource1.scala:4: overriding type D in class B with bounds <: stuberrors.A; + type D has incompatible type + new B { type D = E } + ^ +error: newSource1.scala:4: Symbol 'type stuberrors.A' is missing from the classpath. +This symbol is required by 'type stuberrors.B.D'. +Make sure that type A is in your classpath and check for conflicting dependencies with `-Ylog-classpath`. +A full rebuild may help if 'B.class' was compiled against an incompatible version of stuberrors. + new B { type D = E } + ^ +error: newSource1.scala:4: Symbol 'type stuberrors.A' is missing from the classpath. +This symbol is required by 'class stuberrors.E'. +Make sure that type A is in your classpath and check for conflicting dependencies with `-Ylog-classpath`. +A full rebuild may help if 'E.class' was compiled against an incompatible version of stuberrors. + new B { type D = E } + ^ diff --git a/test/files/run/StubErrorTypeDef.scala b/test/files/run/StubErrorTypeDef.scala new file mode 100644 index 0000000000..967964d815 --- /dev/null +++ b/test/files/run/StubErrorTypeDef.scala @@ -0,0 +1,26 @@ +object Test extends scala.tools.partest.StubErrorMessageTest { + def codeA = """ + package stuberrors + class A + class NestedB[T] + """ + + def codeB = """ + package stuberrors + class E extends A + abstract class B { + type D <: A + } + """ + + def userCode = """ + package stuberrors + class C { + new B { type D = E } + } + """ + + def removeFromClasspath(): Unit = { + removeClasses("stuberrors", List("A")) + } +} diff --git a/test/files/run/StubErrorTypeclass.check b/test/files/run/StubErrorTypeclass.check new file mode 100644 index 0000000000..7ecee64ec9 --- /dev/null +++ b/test/files/run/StubErrorTypeclass.check @@ -0,0 +1,6 @@ +error: newSource1.scala:4: Symbol 'type stuberrors.A' is missing from the classpath. +This symbol is required by 'value stuberrors.B.evidence$1'. +Make sure that type A is in your classpath and check for conflicting dependencies with `-Ylog-classpath`. +A full rebuild may help if 'B.class' was compiled against an incompatible version of stuberrors. + class C { println(new B(1)) } + ^ diff --git a/test/files/run/StubErrorTypeclass.scala b/test/files/run/StubErrorTypeclass.scala new file mode 100644 index 0000000000..e9a48d5430 --- /dev/null +++ b/test/files/run/StubErrorTypeclass.scala @@ -0,0 +1,21 @@ +object Test extends scala.tools.partest.StubErrorMessageTest { + def codeA = """ + package stuberrors + class A[T] + """ + + def codeB = """ + package stuberrors + class B[T: A](val t: T) + """ + + def userCode = """ + package stuberrors + // Here we want a stub error not an implicit not found error + class C { println(new B(1)) } + """ + + def removeFromClasspath(): Unit = { + removeClasses("stuberrors", List("A")) + } +} diff --git a/test/files/run/reflection-attachments.check b/test/files/run/reflection-attachments.check deleted file mode 100644 index e69de29bb2..0000000000 --- a/test/files/run/reflection-attachments.check +++ /dev/null diff --git a/test/files/run/repl-colon-type.check b/test/files/run/repl-colon-type.check index 5b7a3c7506..1217e8d8c2 100644 --- a/test/files/run/repl-colon-type.check +++ b/test/files/run/repl-colon-type.check @@ -75,7 +75,7 @@ TypeRef( ) TypeRef( TypeSymbol( - sealed abstract class List[+A] extends AbstractSeq[A] with LinearSeq[A] with Product with GenericTraversableTemplate[A,List] with LinearSeqOptimized[A,List[A]] with FilteredTraversableInternal[A,List[A]] with Serializable + sealed abstract class List[+A] extends AbstractSeq[A] with LinearSeq[A] with Product with GenericTraversableTemplate[A,List] with LinearSeqOptimized[A,List[A]] with Serializable ) args = List( @@ -142,7 +142,7 @@ TypeRef( args = List( TypeRef( TypeSymbol( - sealed abstract class List[+A] extends AbstractSeq[A] with LinearSeq[A] with Product with GenericTraversableTemplate[A,List] with LinearSeqOptimized[A,List[A]] with FilteredTraversableInternal[A,List[A]] with Serializable + sealed abstract class List[+A] extends AbstractSeq[A] with LinearSeq[A] with Product with GenericTraversableTemplate[A,List] with LinearSeqOptimized[A,List[A]] with Serializable ) args = List( @@ -175,7 +175,7 @@ PolyType( args = List( TypeRef( TypeSymbol( - sealed abstract class List[+A] extends AbstractSeq[A] with LinearSeq[A] with Product with GenericTraversableTemplate[A,List] with LinearSeqOptimized[A,List[A]] with FilteredTraversableInternal[A,List[A]] with Serializable + sealed abstract class List[+A] extends AbstractSeq[A] with LinearSeq[A] with Product with GenericTraversableTemplate[A,List] with LinearSeqOptimized[A,List[A]] with Serializable ) args = List(TypeParamTypeRef(TypeParam(T <: AnyVal))) @@ -198,7 +198,7 @@ PolyType( params = List(TermSymbol(x: T), TermSymbol(y: List[U])) resultType = TypeRef( TypeSymbol( - sealed abstract class List[+A] extends AbstractSeq[A] with LinearSeq[A] with Product with GenericTraversableTemplate[A,List] with LinearSeqOptimized[A,List[A]] with FilteredTraversableInternal[A,List[A]] with Serializable + sealed abstract class List[+A] extends AbstractSeq[A] with LinearSeq[A] with Product with GenericTraversableTemplate[A,List] with LinearSeqOptimized[A,List[A]] with Serializable ) args = List(TypeParamTypeRef(TypeParam(U >: T))) diff --git a/test/files/run/t10231/A_1.java b/test/files/run/t10231/A_1.java new file mode 100644 index 0000000000..5cc2ed3606 --- /dev/null +++ b/test/files/run/t10231/A_1.java @@ -0,0 +1,11 @@ +/* + * javac: -parameters + */ +public class A_1 { + public class Inner { + public int x; + public Inner(int i) { + x = i; + } + } +} diff --git a/test/files/run/t10231/Test_2.scala b/test/files/run/t10231/Test_2.scala new file mode 100644 index 0000000000..8f8150cab1 --- /dev/null +++ b/test/files/run/t10231/Test_2.scala @@ -0,0 +1,5 @@ +object Test extends App { + val a = new A_1 + val i = new a.Inner(i = 99) + assert(i.x == 99) +} diff --git a/test/files/run/t5717.check b/test/files/run/t5717.check new file mode 100644 index 0000000000..5001b57ffc --- /dev/null +++ b/test/files/run/t5717.check @@ -0,0 +1 @@ +error: error writing a/B: t5717-run.obj/a/B.class: t5717-run.obj/a is not a directory diff --git a/test/files/run/t5717.scala b/test/files/run/t5717.scala index a0997f5a49..1434f40a6a 100644 --- a/test/files/run/t5717.scala +++ b/test/files/run/t5717.scala @@ -1,7 +1,7 @@ import scala.tools.partest._ import java.io.File -object Test extends StoreReporterDirectTest { +object Test extends DirectTest { def code = ??? def compileCode(code: String) = { diff --git a/test/files/run/t6440b.check b/test/files/run/t6440b.check index a6100d6d1e..07ec4f2a19 100644 --- a/test/files/run/t6440b.check +++ b/test/files/run/t6440b.check @@ -1,5 +1,6 @@ -pos: NoPosition missing or invalid dependency detected while loading class file 'U.class'. -Could not access type T in package pack1, -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 'U.class' was compiled against an incompatible version of pack1. ERROR +error: newSource1.scala:4: Symbol 'type pack1.T' is missing from the classpath. +This symbol is required by 'method pack1.U.t'. +Make sure that type T is in your classpath and check for conflicting dependencies with `-Ylog-classpath`. +A full rebuild may help if 'U.class' was compiled against an incompatible version of pack1. + pack2.V.u.t // we have to fail if T.class is missing + ^ diff --git a/test/files/run/t6440b.scala b/test/files/run/t6440b.scala index 7ab9529ccb..a1ad717162 100644 --- a/test/files/run/t6440b.scala +++ b/test/files/run/t6440b.scala @@ -56,6 +56,10 @@ object Test extends StoreReporterDirectTest { // bad symbolic reference error expected (but no stack trace!) compileCode(app2) - println(filteredInfos.mkString("\n")) + import scala.reflect.internal.util.Position + filteredInfos.map { report => + print(if (report.severity == storeReporter.ERROR) "error: " else "") + println(Position.formatMessage(report.pos, report.msg, true)) + } } } diff --git a/test/files/run/typetags_without_scala_reflect_typetag_lookup.scala b/test/files/run/typetags_without_scala_reflect_typetag_lookup.scala index 3d2b9f77be..dccb2af8f5 100644 --- a/test/files/run/typetags_without_scala_reflect_typetag_lookup.scala +++ b/test/files/run/typetags_without_scala_reflect_typetag_lookup.scala @@ -38,6 +38,6 @@ object Test extends StoreReporterDirectTest { compileApp(); // we should get "missing or invalid dependency detected" errors, because we're trying to use an implicit that can't be unpickled // but we don't know the number of these errors and their order, so I just ignore them all - println(filteredInfos.filterNot(_.msg.contains("missing or invalid dependency detected")).mkString("\n")) + println(filteredInfos.filterNot(_.msg.contains("is missing from the classpath")).mkString("\n")) } } diff --git a/test/files/run/typetags_without_scala_reflect_typetag_manifest_interop.scala b/test/files/run/typetags_without_scala_reflect_typetag_manifest_interop.scala index a865f4d137..c865759588 100644 --- a/test/files/run/typetags_without_scala_reflect_typetag_manifest_interop.scala +++ b/test/files/run/typetags_without_scala_reflect_typetag_manifest_interop.scala @@ -42,6 +42,6 @@ object Test extends StoreReporterDirectTest { compileApp(); // we should get "missing or invalid dependency detected" errors, because we're trying to use an implicit that can't be unpickled // but we don't know the number of these errors and their order, so I just ignore them all - println(filteredInfos.filterNot (_.msg.contains("missing or invalid dependency detected")).mkString("\n")) + println(filteredInfos.filterNot (_.msg.contains("is missing from the classpath")).mkString("\n")) } } |