Skip to content

Commit 451fdcd

Browse files
authored
Revert unconditional lint of Inlined expansion (#22815)
The tweak to lint Inlined is reverted, on suspicion that it is the root cause of #22812 . (Investigation ongoing.) (If it reverts without a test change, then it doesn't have test coverage.) Gather legacy tests about type parameters and delete the `untried` test files. Same for `unused` test files; removing check and flags files for `warn-unused-privates` is a follow-up chore for a previous PR. Fixes #22812
2 parents a5e029a + 0b3e859 commit 451fdcd

34 files changed

+284
-363
lines changed

compiler/src/dotty/tools/dotc/transform/CheckUnused.scala

+3-2
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,10 @@ class CheckUnused private (phaseMode: PhaseMode, suffix: String) extends MiniPha
145145
refInfos.inlined.push(tree.call.srcPos)
146146
ctx
147147
override def transformInlined(tree: Inlined)(using Context): tree.type =
148-
transformAllDeep(tree.expansion) // traverse expansion with nonempty inlined stack to avoid registering defs
148+
//transformAllDeep(tree.expansion) // traverse expansion with nonempty inlined stack to avoid registering defs
149149
val _ = refInfos.inlined.pop()
150-
transformAllDeep(tree.call)
150+
if !tree.call.isEmpty && phaseMode.eq(PhaseMode.Aggregate) then
151+
transformAllDeep(tree.call)
151152
tree
152153

153154
override def prepareForBind(tree: Bind)(using Context): Context =

compiler/test/dotc/neg-best-effort-pickling.excludelist

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ i20317a.scala # recursion limit exceeded
1818
i11226.scala # missing type
1919
i974.scala # cyclic reference
2020
i13864.scala # missing symbol in pickling
21+
type-params.scala # recursion limit exceeded
2122

2223
# semantic db generation fails in the first compilation
2324
i15158.scala # cyclic reference - stack overflow

tests/neg/type-params.check

+103
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
-- [E053] Type Error: tests/neg/type-params.scala:14:13 ----------------------------------------------------------------
2+
14 | type t = x[x] // error
3+
| ^^^^
4+
| x does not take type parameters
5+
|
6+
| longer explanation available when compiling with `-explain`
7+
-- [E053] Type Error: tests/neg/type-params.scala:16:13 ----------------------------------------------------------------
8+
16 | val foo: s[Int] // error
9+
| ^^^^^^
10+
| s does not take type parameters
11+
|
12+
| longer explanation available when compiling with `-explain`
13+
-- Error: tests/neg/type-params.scala:21:26 ----------------------------------------------------------------------------
14+
21 | object mp extends Monad[Tuple2] // error
15+
| ^^^^^^
16+
| Type argument [T1, T2] =>> (T1, T2) does not have the same kind as its bound [x]
17+
-- Error: tests/neg/type-params.scala:24:26 ----------------------------------------------------------------------------
18+
24 | trait ms1 extends Monad[String] // error
19+
| ^^^^^^
20+
| Type argument String does not have the same kind as its bound [x]
21+
-- Error: tests/neg/type-params.scala:25:29 ----------------------------------------------------------------------------
22+
25 | trait ms2[t] extends Monad[t] // error
23+
| ^
24+
| Type argument t does not have the same kind as its bound [x]
25+
-- Error: tests/neg/type-params.scala:26:35 ----------------------------------------------------------------------------
26+
26 | trait ms3[m[_], t] extends Monad[m[t]] // error -- added to check regression on bug
27+
| ^^^^
28+
| Type argument m[t] does not have the same kind as its bound [x]
29+
-- Error: tests/neg/type-params.scala:31:31 ----------------------------------------------------------------------------
30+
31 | trait Bar2[m[_]] extends Foo[m] // error check that m is properly recognized as kind *->*, while * is expected
31+
| ^
32+
| Type argument m does not have the same kind as its bound
33+
-- [E053] Type Error: tests/neg/type-params.scala:37:20 ----------------------------------------------------------------
34+
37 |class t1701 extends java.lang.Cloneable[String, Option, Int] // error
35+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
36+
| Cloneable does not take type parameters
37+
|
38+
| longer explanation available when compiling with `-explain`
39+
-- [E053] Type Error: tests/neg/type-params.scala:39:24 ----------------------------------------------------------------
40+
39 |trait t0842[T] { def m: this.type[T] = this } // error
41+
| ^^^^^^^^^^^^
42+
| (t0842.this : t0842[T]) does not take type parameters
43+
|
44+
| longer explanation available when compiling with `-explain`
45+
-- [E134] Type Error: tests/neg/type-params.scala:45:10 ----------------------------------------------------------------
46+
45 | println(a[A]) // error
47+
| ^
48+
| None of the overloaded alternatives of method apply in trait Function1 with types
49+
| (v1: t278.this.A): Unit
50+
| (): Unit
51+
| match type arguments [t278.this.A] and expected type Any
52+
-- [E120] Naming Error: tests/neg/type-params.scala:44:6 ---------------------------------------------------------------
53+
44 | def a = (p: A) => () // error
54+
| ^
55+
| Double definition:
56+
| def a: () => Unit in trait t278 at line 43 and
57+
| def a: t278.this.A => Unit in trait t278 at line 44
58+
| have the same type after erasure.
59+
|
60+
| Consider adding a @targetName annotation to one of the conflicting definitions
61+
| for disambiguation.
62+
-- Error: tests/neg/type-params.scala:4:7 ------------------------------------------------------------------------------
63+
4 | "".==[Int] // error
64+
| ^^^^^^^^^^
65+
| method == in class Any does not take type parameters
66+
-- Error: tests/neg/type-params.scala:5:17 -----------------------------------------------------------------------------
67+
5 | ("": AnyRef).==[Int] // error
68+
| ^^^^^^^^^^^^^^^^^^^^
69+
| method == in class Any does not take type parameters
70+
-- Error: tests/neg/type-params.scala:6:17 -----------------------------------------------------------------------------
71+
6 | ("": Object).==[Int] // error
72+
| ^^^^^^^^^^^^^^^^^^^^
73+
| method == in class Any does not take type parameters
74+
-- Error: tests/neg/type-params.scala:9:14 -----------------------------------------------------------------------------
75+
9 | classOf[Int][Int] // error
76+
| ^^^^^^^^^^^^^^^^^
77+
| illegal repeated type application
78+
| You might have meant something like:
79+
| classOf[Int, Int]
80+
-- [E140] Cyclic Error: tests/neg/type-params.scala:34:11 --------------------------------------------------------------
81+
34 | def g[X, A[X] <: A[X]](x: A[X]) = x // error // error
82+
| ^
83+
| illegal cyclic type reference: upper bound ... of type A refers back to the type itself
84+
|
85+
| Run with -explain-cyclic for more details.
86+
-- [E053] Type Error: tests/neg/type-params.scala:34:28 ----------------------------------------------------------------
87+
34 | def g[X, A[X] <: A[X]](x: A[X]) = x // error // error
88+
| ^^^^
89+
| A does not take type parameters
90+
|
91+
| longer explanation available when compiling with `-explain`
92+
-- [E140] Cyclic Error: tests/neg/type-params.scala:35:8 ---------------------------------------------------------------
93+
35 | def f[C[X] <: C[X]](l: C[_]) = l.x // error // error
94+
| ^
95+
| illegal cyclic type reference: upper bound ... of type C refers back to the type itself
96+
|
97+
| Run with -explain-cyclic for more details.
98+
-- [E053] Type Error: tests/neg/type-params.scala:35:25 ----------------------------------------------------------------
99+
35 | def f[C[X] <: C[X]](l: C[_]) = l.x // error // error
100+
| ^^^^
101+
| C does not take type parameters
102+
|
103+
| longer explanation available when compiling with `-explain`

tests/neg/type-params.scala

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
2+
def `t8219 Any == is not overloaded in error message`: Unit =
3+
// Scala 2 once defined AnyRef == and Any == as overloaded. Spec defines only Any ==.
4+
"".==[Int] // error
5+
("": AnyRef).==[Int] // error
6+
("": Object).==[Int] // error
7+
8+
def `extra type arg to class literal` =
9+
classOf[Int][Int] // error
10+
11+
class `various ancient kindedness`:
12+
13+
class WellKinded[x]:
14+
type t = x[x] // error
15+
trait WellKindedBounded[s <: Throwable]:
16+
val foo: s[Int] // error
17+
class WellKindedWrongSyntax[s <: List] // must be s[x] <: List[x] ?
18+
19+
class Monad[m[x]]
20+
21+
object mp extends Monad[Tuple2] // error
22+
23+
// expecting types of kind *->*
24+
trait ms1 extends Monad[String] // error
25+
trait ms2[t] extends Monad[t] // error
26+
trait ms3[m[_], t] extends Monad[m[t]] // error -- added to check regression on bug
27+
28+
// expecting types of kind *
29+
trait Foo[x]
30+
trait Bar1[m[_]] extends Foo[m[Int]] // check that m[Int] is properly recognized as kind-*
31+
trait Bar2[m[_]] extends Foo[m] // error check that m is properly recognized as kind *->*, while * is expected
32+
33+
def `t2918 t5093 detect cyclic error` =
34+
def g[X, A[X] <: A[X]](x: A[X]) = x // error // error
35+
def f[C[X] <: C[X]](l: C[_]) = l.x // error // error
36+
37+
class t1701 extends java.lang.Cloneable[String, Option, Int] // error
38+
39+
trait t0842[T] { def m: this.type[T] = this } // error
40+
41+
trait t278:
42+
class A
43+
def a = () => ()
44+
def a = (p: A) => () // error
45+
println(a[A]) // error

tests/untried/neg/class-of-double-targs.check

-4
This file was deleted.

tests/untried/neg/class-of-double-targs.scala

-3
This file was deleted.

tests/untried/neg/t0842.check

-4
This file was deleted.

tests/untried/neg/t0842.scala

-1
This file was deleted.

tests/untried/neg/t1701.check

-4
This file was deleted.

tests/untried/neg/t1701.scala

-1
This file was deleted.

tests/untried/neg/t278.check

-11
This file was deleted.

tests/untried/neg/t278.scala

-6
This file was deleted.

tests/untried/neg/t2918.check

-10
This file was deleted.

tests/untried/neg/t2918.scala

-3
This file was deleted.

tests/untried/neg/t5093.check

-10
This file was deleted.

tests/untried/neg/t5093.scala

-3
This file was deleted.

tests/untried/neg/t8219-any-any-ref-equals.check

-10
This file was deleted.

tests/untried/neg/t8219-any-any-ref-equals.scala

-8
This file was deleted.

tests/untried/neg/warn-unused-imports.check

-33
This file was deleted.

tests/untried/neg/warn-unused-imports.flags

-1
This file was deleted.

0 commit comments

Comments
 (0)