diff --git a/compiler/src/dotty/tools/dotc/transform/CheckUnused.scala b/compiler/src/dotty/tools/dotc/transform/CheckUnused.scala index 24763abc21b4..2ee3ea825edc 100644 --- a/compiler/src/dotty/tools/dotc/transform/CheckUnused.scala +++ b/compiler/src/dotty/tools/dotc/transform/CheckUnused.scala @@ -145,9 +145,10 @@ class CheckUnused private (phaseMode: PhaseMode, suffix: String) extends MiniPha refInfos.inlined.push(tree.call.srcPos) ctx override def transformInlined(tree: Inlined)(using Context): tree.type = - transformAllDeep(tree.expansion) // traverse expansion with nonempty inlined stack to avoid registering defs + //transformAllDeep(tree.expansion) // traverse expansion with nonempty inlined stack to avoid registering defs val _ = refInfos.inlined.pop() - transformAllDeep(tree.call) + if !tree.call.isEmpty && phaseMode.eq(PhaseMode.Aggregate) then + transformAllDeep(tree.call) tree override def prepareForBind(tree: Bind)(using Context): Context = diff --git a/compiler/test/dotc/neg-best-effort-pickling.excludelist b/compiler/test/dotc/neg-best-effort-pickling.excludelist index 13fd5669dd8a..52371ecf17a5 100644 --- a/compiler/test/dotc/neg-best-effort-pickling.excludelist +++ b/compiler/test/dotc/neg-best-effort-pickling.excludelist @@ -18,6 +18,7 @@ i20317a.scala # recursion limit exceeded i11226.scala # missing type i974.scala # cyclic reference i13864.scala # missing symbol in pickling +type-params.scala # recursion limit exceeded # semantic db generation fails in the first compilation i15158.scala # cyclic reference - stack overflow diff --git a/tests/neg/type-params.check b/tests/neg/type-params.check new file mode 100644 index 000000000000..e1eefb4c6fe9 --- /dev/null +++ b/tests/neg/type-params.check @@ -0,0 +1,103 @@ +-- [E053] Type Error: tests/neg/type-params.scala:14:13 ---------------------------------------------------------------- +14 | type t = x[x] // error + | ^^^^ + | x does not take type parameters + | + | longer explanation available when compiling with `-explain` +-- [E053] Type Error: tests/neg/type-params.scala:16:13 ---------------------------------------------------------------- +16 | val foo: s[Int] // error + | ^^^^^^ + | s does not take type parameters + | + | longer explanation available when compiling with `-explain` +-- Error: tests/neg/type-params.scala:21:26 ---------------------------------------------------------------------------- +21 | object mp extends Monad[Tuple2] // error + | ^^^^^^ + | Type argument [T1, T2] =>> (T1, T2) does not have the same kind as its bound [x] +-- Error: tests/neg/type-params.scala:24:26 ---------------------------------------------------------------------------- +24 | trait ms1 extends Monad[String] // error + | ^^^^^^ + | Type argument String does not have the same kind as its bound [x] +-- Error: tests/neg/type-params.scala:25:29 ---------------------------------------------------------------------------- +25 | trait ms2[t] extends Monad[t] // error + | ^ + | Type argument t does not have the same kind as its bound [x] +-- Error: tests/neg/type-params.scala:26:35 ---------------------------------------------------------------------------- +26 | trait ms3[m[_], t] extends Monad[m[t]] // error -- added to check regression on bug + | ^^^^ + | Type argument m[t] does not have the same kind as its bound [x] +-- Error: tests/neg/type-params.scala:31:31 ---------------------------------------------------------------------------- +31 | trait Bar2[m[_]] extends Foo[m] // error check that m is properly recognized as kind *->*, while * is expected + | ^ + | Type argument m does not have the same kind as its bound +-- [E053] Type Error: tests/neg/type-params.scala:37:20 ---------------------------------------------------------------- +37 |class t1701 extends java.lang.Cloneable[String, Option, Int] // error + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | Cloneable does not take type parameters + | + | longer explanation available when compiling with `-explain` +-- [E053] Type Error: tests/neg/type-params.scala:39:24 ---------------------------------------------------------------- +39 |trait t0842[T] { def m: this.type[T] = this } // error + | ^^^^^^^^^^^^ + | (t0842.this : t0842[T]) does not take type parameters + | + | longer explanation available when compiling with `-explain` +-- [E134] Type Error: tests/neg/type-params.scala:45:10 ---------------------------------------------------------------- +45 | println(a[A]) // error + | ^ + | None of the overloaded alternatives of method apply in trait Function1 with types + | (v1: t278.this.A): Unit + | (): Unit + | match type arguments [t278.this.A] and expected type Any +-- [E120] Naming Error: tests/neg/type-params.scala:44:6 --------------------------------------------------------------- +44 | def a = (p: A) => () // error + | ^ + | Double definition: + | def a: () => Unit in trait t278 at line 43 and + | def a: t278.this.A => Unit in trait t278 at line 44 + | have the same type after erasure. + | + | Consider adding a @targetName annotation to one of the conflicting definitions + | for disambiguation. +-- Error: tests/neg/type-params.scala:4:7 ------------------------------------------------------------------------------ +4 | "".==[Int] // error + | ^^^^^^^^^^ + | method == in class Any does not take type parameters +-- Error: tests/neg/type-params.scala:5:17 ----------------------------------------------------------------------------- +5 | ("": AnyRef).==[Int] // error + | ^^^^^^^^^^^^^^^^^^^^ + | method == in class Any does not take type parameters +-- Error: tests/neg/type-params.scala:6:17 ----------------------------------------------------------------------------- +6 | ("": Object).==[Int] // error + | ^^^^^^^^^^^^^^^^^^^^ + | method == in class Any does not take type parameters +-- Error: tests/neg/type-params.scala:9:14 ----------------------------------------------------------------------------- +9 | classOf[Int][Int] // error + | ^^^^^^^^^^^^^^^^^ + | illegal repeated type application + | You might have meant something like: + | classOf[Int, Int] +-- [E140] Cyclic Error: tests/neg/type-params.scala:34:11 -------------------------------------------------------------- +34 | def g[X, A[X] <: A[X]](x: A[X]) = x // error // error + | ^ + | illegal cyclic type reference: upper bound ... of type A refers back to the type itself + | + | Run with -explain-cyclic for more details. +-- [E053] Type Error: tests/neg/type-params.scala:34:28 ---------------------------------------------------------------- +34 | def g[X, A[X] <: A[X]](x: A[X]) = x // error // error + | ^^^^ + | A does not take type parameters + | + | longer explanation available when compiling with `-explain` +-- [E140] Cyclic Error: tests/neg/type-params.scala:35:8 --------------------------------------------------------------- +35 | def f[C[X] <: C[X]](l: C[_]) = l.x // error // error + | ^ + | illegal cyclic type reference: upper bound ... of type C refers back to the type itself + | + | Run with -explain-cyclic for more details. +-- [E053] Type Error: tests/neg/type-params.scala:35:25 ---------------------------------------------------------------- +35 | def f[C[X] <: C[X]](l: C[_]) = l.x // error // error + | ^^^^ + | C does not take type parameters + | + | longer explanation available when compiling with `-explain` diff --git a/tests/neg/type-params.scala b/tests/neg/type-params.scala new file mode 100644 index 000000000000..2803141f3b85 --- /dev/null +++ b/tests/neg/type-params.scala @@ -0,0 +1,45 @@ + +def `t8219 Any == is not overloaded in error message`: Unit = + // Scala 2 once defined AnyRef == and Any == as overloaded. Spec defines only Any ==. + "".==[Int] // error + ("": AnyRef).==[Int] // error + ("": Object).==[Int] // error + +def `extra type arg to class literal` = + classOf[Int][Int] // error + +class `various ancient kindedness`: + + class WellKinded[x]: + type t = x[x] // error + trait WellKindedBounded[s <: Throwable]: + val foo: s[Int] // error + class WellKindedWrongSyntax[s <: List] // must be s[x] <: List[x] ? + + class Monad[m[x]] + + object mp extends Monad[Tuple2] // error + + // expecting types of kind *->* + trait ms1 extends Monad[String] // error + trait ms2[t] extends Monad[t] // error + trait ms3[m[_], t] extends Monad[m[t]] // error -- added to check regression on bug + + // expecting types of kind * + trait Foo[x] + trait Bar1[m[_]] extends Foo[m[Int]] // check that m[Int] is properly recognized as kind-* + trait Bar2[m[_]] extends Foo[m] // error check that m is properly recognized as kind *->*, while * is expected + +def `t2918 t5093 detect cyclic error` = + def g[X, A[X] <: A[X]](x: A[X]) = x // error // error + def f[C[X] <: C[X]](l: C[_]) = l.x // error // error + +class t1701 extends java.lang.Cloneable[String, Option, Int] // error + +trait t0842[T] { def m: this.type[T] = this } // error + +trait t278: + class A + def a = () => () + def a = (p: A) => () // error + println(a[A]) // error diff --git a/tests/untried/neg/class-of-double-targs.check b/tests/untried/neg/class-of-double-targs.check deleted file mode 100644 index f7e2094f9778..000000000000 --- a/tests/untried/neg/class-of-double-targs.check +++ /dev/null @@ -1,4 +0,0 @@ -class-of-double-targs.scala:2: error: expression of type Class[Int](classOf[scala.Int]) does not take type parameters. - classOf[Int][Int] - ^ -one error found diff --git a/tests/untried/neg/class-of-double-targs.scala b/tests/untried/neg/class-of-double-targs.scala deleted file mode 100644 index 26a2fa838136..000000000000 --- a/tests/untried/neg/class-of-double-targs.scala +++ /dev/null @@ -1,3 +0,0 @@ -object Test { - classOf[Int][Int] -} diff --git a/tests/untried/neg/t0842.check b/tests/untried/neg/t0842.check deleted file mode 100644 index 3351aa1174ce..000000000000 --- a/tests/untried/neg/t0842.check +++ /dev/null @@ -1,4 +0,0 @@ -t0842.scala:1: error: A.this.type does not take type parameters -trait A[T] { def m: this.type[T] = this } - ^ -one error found diff --git a/tests/untried/neg/t0842.scala b/tests/untried/neg/t0842.scala deleted file mode 100644 index f32c2ba26d71..000000000000 --- a/tests/untried/neg/t0842.scala +++ /dev/null @@ -1 +0,0 @@ -trait A[T] { def m: this.type[T] = this } diff --git a/tests/untried/neg/t1701.check b/tests/untried/neg/t1701.check deleted file mode 100644 index d603e62e5a6a..000000000000 --- a/tests/untried/neg/t1701.check +++ /dev/null @@ -1,4 +0,0 @@ -t1701.scala:1: error: Cloneable does not take type parameters -class A extends java.lang.Cloneable[String, Option, Int] - ^ -one error found diff --git a/tests/untried/neg/t1701.scala b/tests/untried/neg/t1701.scala deleted file mode 100644 index 7cd6ff9953be..000000000000 --- a/tests/untried/neg/t1701.scala +++ /dev/null @@ -1 +0,0 @@ -class A extends java.lang.Cloneable[String, Option, Int] diff --git a/tests/untried/neg/t278.check b/tests/untried/neg/t278.check deleted file mode 100644 index 405f7d225c17..000000000000 --- a/tests/untried/neg/t278.check +++ /dev/null @@ -1,11 +0,0 @@ -t278.scala:5: error: overloaded method value a with alternatives: - => C.this.A => Unit <and> - => () => Unit - does not take type parameters - println(a[A]) - ^ -t278.scala:4: error: method a is defined twice - conflicting symbols both originated in file 't278.scala' - def a = (p:A) => () - ^ -two errors found diff --git a/tests/untried/neg/t278.scala b/tests/untried/neg/t278.scala deleted file mode 100644 index 39a711bb0985..000000000000 --- a/tests/untried/neg/t278.scala +++ /dev/null @@ -1,6 +0,0 @@ -class C { - class A - def a = () => () - def a = (p:A) => () - println(a[A]) -} diff --git a/tests/untried/neg/t2918.check b/tests/untried/neg/t2918.check deleted file mode 100644 index aae3045e8af7..000000000000 --- a/tests/untried/neg/t2918.check +++ /dev/null @@ -1,10 +0,0 @@ -t2918.scala:2: error: illegal cyclic reference involving type A - def g[X, A[X] <: A[X]](x: A[X]) = x - ^ -t2918.scala:2: error: cyclic aliasing or subtyping involving type A - def g[X, A[X] <: A[X]](x: A[X]) = x - ^ -t2918.scala:2: error: A does not take type parameters - def g[X, A[X] <: A[X]](x: A[X]) = x - ^ -three errors found diff --git a/tests/untried/neg/t2918.scala b/tests/untried/neg/t2918.scala deleted file mode 100644 index ff2be39ae0c4..000000000000 --- a/tests/untried/neg/t2918.scala +++ /dev/null @@ -1,3 +0,0 @@ -object Test { - def g[X, A[X] <: A[X]](x: A[X]) = x -} diff --git a/tests/untried/neg/t5093.check b/tests/untried/neg/t5093.check deleted file mode 100644 index daba46001153..000000000000 --- a/tests/untried/neg/t5093.check +++ /dev/null @@ -1,10 +0,0 @@ -t5093.scala:2: error: illegal cyclic reference involving type C - def f[C[X] <: C[X]](l: C[_]) = l.x - ^ -t5093.scala:2: error: cyclic aliasing or subtyping involving type C - def f[C[X] <: C[X]](l: C[_]) = l.x - ^ -t5093.scala:2: error: C does not take type parameters - def f[C[X] <: C[X]](l: C[_]) = l.x - ^ -three errors found diff --git a/tests/untried/neg/t5093.scala b/tests/untried/neg/t5093.scala deleted file mode 100644 index 9cde364dee4c..000000000000 --- a/tests/untried/neg/t5093.scala +++ /dev/null @@ -1,3 +0,0 @@ -class T { - def f[C[X] <: C[X]](l: C[_]) = l.x -} diff --git a/tests/untried/neg/t8219-any-any-ref-equals.check b/tests/untried/neg/t8219-any-any-ref-equals.check deleted file mode 100644 index 95d2536fba06..000000000000 --- a/tests/untried/neg/t8219-any-any-ref-equals.check +++ /dev/null @@ -1,10 +0,0 @@ -t8219-any-any-ref-equals.scala:5: error: method ==: (x$1: Any)Boolean does not take type parameters. - "".==[Int] - ^ -t8219-any-any-ref-equals.scala:6: error: method ==: (x$1: Any)Boolean does not take type parameters. - ("": AnyRef).==[Int] - ^ -t8219-any-any-ref-equals.scala:7: error: method ==: (x$1: Any)Boolean does not take type parameters. - ("": Object).==[Int] - ^ -three errors found diff --git a/tests/untried/neg/t8219-any-any-ref-equals.scala b/tests/untried/neg/t8219-any-any-ref-equals.scala deleted file mode 100644 index f1b81fa734c1..000000000000 --- a/tests/untried/neg/t8219-any-any-ref-equals.scala +++ /dev/null @@ -1,8 +0,0 @@ -object Test { - // The error message tells us that AnyRef#== and Any#== are overloaded. - // A real class couldn't define such an overload, why do we allow AnyRef - // to do so? - "".==[Int] - ("": AnyRef).==[Int] - ("": Object).==[Int] -} diff --git a/tests/untried/neg/warn-unused-imports.check b/tests/untried/neg/warn-unused-imports.check deleted file mode 100644 index 36c6dd03c38d..000000000000 --- a/tests/untried/neg/warn-unused-imports.check +++ /dev/null @@ -1,33 +0,0 @@ -warn-unused-imports.scala:57: warning: Unused import - import p1.A // warn - ^ -warn-unused-imports.scala:62: warning: Unused import - import p1.{ A, B } // warn on A - ^ -warn-unused-imports.scala:67: warning: Unused import - import p1.{ A, B } // warn on both - ^ -warn-unused-imports.scala:67: warning: Unused import - import p1.{ A, B } // warn on both - ^ -warn-unused-imports.scala:73: warning: Unused import - import c._ // warn - ^ -warn-unused-imports.scala:78: warning: Unused import - import p1._ // warn - ^ -warn-unused-imports.scala:85: warning: Unused import - import c._ // warn - ^ -warn-unused-imports.scala:91: warning: Unused import - import p1.c._ // warn - ^ -warn-unused-imports.scala:98: warning: Unused import - import p1._ // warn - ^ -warn-unused-imports.scala:118: warning: Unused import - import p1.A // warn - ^ -error: No warnings can be incurred under -Xfatal-warnings. -10 warnings found -one error found diff --git a/tests/untried/neg/warn-unused-imports.flags b/tests/untried/neg/warn-unused-imports.flags deleted file mode 100644 index 24db705df164..000000000000 --- a/tests/untried/neg/warn-unused-imports.flags +++ /dev/null @@ -1 +0,0 @@ --Xfatal-warnings -Ywarn-unused-import diff --git a/tests/untried/neg/warn-unused-imports.scala b/tests/untried/neg/warn-unused-imports.scala deleted file mode 100644 index 4b1c1183dcba..000000000000 --- a/tests/untried/neg/warn-unused-imports.scala +++ /dev/null @@ -1,125 +0,0 @@ -class Bippo { - def length: Int = 123 - class Tree -} - -package object p1 { - class A - implicit class B(val s: String) { def bippy = s } - val c: Bippo = new Bippo - type D = String -} -package object p2 { - class A - implicit class B(val s: String) { def bippy = s } - val c: Bippo = new Bippo - type D = Int -} - -trait NoWarn { - { - import p1._ // no warn - println("abc".bippy) - } - - { - import p1._ // no warn - println(new A) - } - - { - import p1.B // no warn - println("abc".bippy) - } - - { - import p1._ // no warn - import c._ // no warn - println(length) - } - - { - import p1._ // no warn - import c._ // no warn - val x: Tree = null - println(x) - } - - { - import p1.D // no warn - val x: D = null - println(x) - } -} - -trait Warn { - { - import p1.A // warn - println(123) - } - - { - import p1.{ A, B } // warn on A - println("abc".bippy) - } - - { - import p1.{ A, B } // warn on both - println(123) - } - - { - import p1._ // no warn (technically this could warn, but not worth the effort to unroll unusedness transitively) - import c._ // warn - println(123) - } - - { - import p1._ // warn - println(123) - } - - { - class Tree - import p1._ // no warn - import c._ // warn - val x: Tree = null - println(x) - } - - { - import p1.c._ // warn - println(123) - } -} - -trait Nested { - { - import p1._ // warn - trait Warn { // warn about unused local trait for good measure - import p2.* - println(new A) - println("abc".bippy) - } - println("") - } - - { - import p1._ // no warn - trait NoWarn { - import p2.B // no warn - println("abc".bippy) - println(new A) - } - println(new NoWarn { }) - } - - { - import p1.A // warn - trait Warn { - import p2.A - println(new A) - } - println(new Warn { }) - } -} diff --git a/tests/untried/neg/warn-unused-privates.check b/tests/untried/neg/warn-unused-privates.check deleted file mode 100644 index d012869c934a..000000000000 --- a/tests/untried/neg/warn-unused-privates.check +++ /dev/null @@ -1,66 +0,0 @@ -warn-unused-privates.scala:2: warning: private constructor in class Bippy is never used - private def this(c: Int) = this(c, c) // warn - ^ -warn-unused-privates.scala:4: warning: private method in class Bippy is never used - private def boop(x: Int) = x+a+b // warn - ^ -warn-unused-privates.scala:6: warning: private val in class Bippy is never used - final private val MILLIS2: Int = 1000 // warn - ^ -warn-unused-privates.scala:13: warning: private val in object Bippy is never used - private val HEY_INSTANCE: Int = 1000 // warn - ^ -warn-unused-privates.scala:35: warning: private val in class Boppy is never used - private val hummer = "def" // warn - ^ -warn-unused-privates.scala:42: warning: private var in trait Accessors is never used - private var v1: Int = 0 // warn - ^ -warn-unused-privates.scala:42: warning: private setter in trait Accessors is never used - private var v1: Int = 0 // warn - ^ -warn-unused-privates.scala:43: warning: private setter in trait Accessors is never used - private var v2: Int = 0 // warn, never set - ^ -warn-unused-privates.scala:44: warning: private var in trait Accessors is never used - private var v3: Int = 0 // warn, never got - ^ -warn-unused-privates.scala:56: warning: private default argument in trait DefaultArgs is never used - private def bippy(x1: Int, x2: Int = 10, x3: Int = 15): Int = x1 + x2 + x3 - ^ -warn-unused-privates.scala:56: warning: private default argument in trait DefaultArgs is never used - private def bippy(x1: Int, x2: Int = 10, x3: Int = 15): Int = x1 + x2 + x3 - ^ -warn-unused-privates.scala:67: warning: local var in method f0 is never used - var x = 1 // warn - ^ -warn-unused-privates.scala:74: warning: local val in method f1 is never used - val b = new Outer // warn - ^ -warn-unused-privates.scala:84: warning: private object in object Types is never used - private object Dongo { def f = this } // warn - ^ -warn-unused-privates.scala:94: warning: local object in method l1 is never used - object HiObject { def f = this } // warn - ^ -warn-unused-privates.scala:78: warning: local var x in method f2 is never set - it could be a val - var x = 100 // warn about it being a var - ^ -warn-unused-privates.scala:85: warning: private class Bar1 in object Types is never used - private class Bar1 // warn - ^ -warn-unused-privates.scala:87: warning: private type Alias1 in object Types is never used - private type Alias1 = String // warn - ^ -warn-unused-privates.scala:95: warning: local class Hi is never used - class Hi { // warn - ^ -warn-unused-privates.scala:99: warning: local class DingDongDoobie is never used - class DingDongDoobie // warn - ^ -warn-unused-privates.scala:102: warning: local type OtherThing is never used - type OtherThing = String // warn - ^ -error: No warnings can be incurred under -Xfatal-warnings. -21 warnings found -one error found diff --git a/tests/untried/neg/warn-unused-privates.flags b/tests/untried/neg/warn-unused-privates.flags deleted file mode 100644 index 25474aefb362..000000000000 --- a/tests/untried/neg/warn-unused-privates.flags +++ /dev/null @@ -1 +0,0 @@ --Ywarn-unused -Xfatal-warnings diff --git a/tests/untried/neg/wellkinded_app.check b/tests/untried/neg/wellkinded_app.check deleted file mode 100644 index d57a0e4b5648..000000000000 --- a/tests/untried/neg/wellkinded_app.check +++ /dev/null @@ -1,4 +0,0 @@ -wellkinded_app.scala:3: error: x does not take type parameters - type t = x[x] - ^ -one error found diff --git a/tests/untried/neg/wellkinded_app.scala b/tests/untried/neg/wellkinded_app.scala deleted file mode 100644 index 7fa3f95a9848..000000000000 --- a/tests/untried/neg/wellkinded_app.scala +++ /dev/null @@ -1,4 +0,0 @@ -// test well-kindedness checks -class WellKinded[x] { - type t = x[x] -} diff --git a/tests/untried/neg/wellkinded_app2.check b/tests/untried/neg/wellkinded_app2.check deleted file mode 100644 index 20a177ea590e..000000000000 --- a/tests/untried/neg/wellkinded_app2.check +++ /dev/null @@ -1,4 +0,0 @@ -wellkinded_app2.scala:3: error: s does not take type parameters - val foo: s[Int] - ^ -one error found diff --git a/tests/untried/neg/wellkinded_app2.scala b/tests/untried/neg/wellkinded_app2.scala deleted file mode 100644 index 7bb4c87f6b17..000000000000 --- a/tests/untried/neg/wellkinded_app2.scala +++ /dev/null @@ -1,4 +0,0 @@ -// test well-kindedness checks -class WellKinded[s <: Throwable] { - val foo: s[Int] -} diff --git a/tests/untried/neg/wellkinded_bounds.check b/tests/untried/neg/wellkinded_bounds.check deleted file mode 100644 index 806eb09a76d7..000000000000 --- a/tests/untried/neg/wellkinded_bounds.check +++ /dev/null @@ -1,4 +0,0 @@ -wellkinded_bounds.scala:2: error: type List takes type parameters -class WellKindedWrongSyntax[s <: List] { // must be s[x] <: List[x] - ^ -one error found diff --git a/tests/untried/neg/wellkinded_bounds.scala b/tests/untried/neg/wellkinded_bounds.scala deleted file mode 100644 index cfa5e74c115f..000000000000 --- a/tests/untried/neg/wellkinded_bounds.scala +++ /dev/null @@ -1,3 +0,0 @@ -// test well-kindedness checks -- syntax error -class WellKindedWrongSyntax[s <: List] { // must be s[x] <: List[x] -} diff --git a/tests/untried/neg/wellkinded_wrongarity.check b/tests/untried/neg/wellkinded_wrongarity.check deleted file mode 100644 index b9f033b4536b..000000000000 --- a/tests/untried/neg/wellkinded_wrongarity.check +++ /dev/null @@ -1,4 +0,0 @@ -wellkinded_wrongarity.scala:5: error: Tuple2 takes two type parameters, expected: one -object mp extends Monad[Tuple2] - ^ -one error found diff --git a/tests/untried/neg/wellkinded_wrongarity.scala b/tests/untried/neg/wellkinded_wrongarity.scala deleted file mode 100644 index 39c7601d53a3..000000000000 --- a/tests/untried/neg/wellkinded_wrongarity.scala +++ /dev/null @@ -1,5 +0,0 @@ -// test well-kindedness checks -- arity error - -class Monad[m[x]] - -object mp extends Monad[Tuple2] diff --git a/tests/untried/neg/wellkinded_wrongarity2.check b/tests/untried/neg/wellkinded_wrongarity2.check deleted file mode 100644 index 922f73381e29..000000000000 --- a/tests/untried/neg/wellkinded_wrongarity2.check +++ /dev/null @@ -1,13 +0,0 @@ -wellkinded_wrongarity2.scala:5: error: String takes no type parameters, expected: one -trait ms1 extends Monad[String] // wrong - ^ -wellkinded_wrongarity2.scala:6: error: t takes no type parameters, expected: one -trait ms2[t] extends Monad[t] // wrong - ^ -wellkinded_wrongarity2.scala:7: error: m[t] takes no type parameters, expected: one -trait ms3[m[_], t] extends Monad[m[t]] // wrong -- added to check regression on bug - ^ -wellkinded_wrongarity2.scala:12: error: type m takes type parameters -trait Bar2[m[_]] extends Foo[m] // check that m is properly recognized as kind *->*, while * is expected - ^ -four errors found diff --git a/tests/untried/neg/wellkinded_wrongarity2.scala b/tests/untried/neg/wellkinded_wrongarity2.scala deleted file mode 100644 index aac617bd8770..000000000000 --- a/tests/untried/neg/wellkinded_wrongarity2.scala +++ /dev/null @@ -1,12 +0,0 @@ -// test well-kindedness checks - -// expecting types of kind *->* -class Monad[m[x]] -trait ms1 extends Monad[String] // wrong -trait ms2[t] extends Monad[t] // wrong -trait ms3[m[_], t] extends Monad[m[t]] // wrong -- added to check regression on bug - -// expecting types of kind * -trait Foo[x] -trait Bar1[m[_]] extends Foo[m[Int]] // check that m[Int] is properly recognized as kind-* -trait Bar2[m[_]] extends Foo[m] // check that m is properly recognized as kind *->*, while * is expected diff --git a/tests/warn/i15503a.scala b/tests/warn/i15503a.scala index 3707b18d316e..884261e140a7 100644 --- a/tests/warn/i15503a.scala +++ b/tests/warn/i15503a.scala @@ -328,3 +328,135 @@ package i22692: type b = AbstractButton type t = swingEvent.AncestorListener + +package ancient: + package p { + class Bippo { + def length: Int = 123 + class Tree + } + } + + package object p1 { + import p._ + class A + implicit class B(val s: String) { def bippy = s } + val c: Bippo = new Bippo + type D = String + } + package object p2 { + import p._ + class A + implicit class B(val s: String) { def bippy = s } + val c: Bippo = new Bippo + type D = Int + } + + trait NoWarn { + { + import p1._ // no warn + println("abc".bippy) + } + + { + import p1._ // no warn + println(new A) + } + + { + import p1.B // no warn + println("abc".bippy) + } + + { + import p1._ // no warn + import c._ // no warn + println(length) + } + + { + import p1._ // no warn + import c._ // no warn + val x: Tree = null + println(x) + } + + { + import p1.D // no warn + val x: D = null + println(x) + } + } + + trait Warn { + { + import p1.A // warn + println(123) + } + + { + import p1.{ A, B } // warn on A + println("abc".bippy) + } + + { + import p1.{ A, B } //warn // warn on both + println(123) + } + + { + import p1._ // no warn (technically this could warn, but not worth the effort to unroll unusedness transitively) + import c._ // warn + println(123) + } + + { + import p1._ // warn + println(123) + } + + { + class Tree + import p1._ // no warn + import c._ // warn + val x: Tree = null + println(x) + } + + { + import p1.c._ // warn + println(123) + } + } + + trait Nested { + { + import p1._ // warn + trait Warn { + import p2.* + println(new A) + println("abc".bippy) + } + println("") + } + + { + import p1._ // no warn + trait NoWarn { + import p2.B // no warn + println("abc".bippy) + println(new A) + } + println(new NoWarn { }) + } + + { + import p1.A // warn + trait Warn { + import p2.A + println(new A) + } + println(new Warn { }) + } + } +end ancient