-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Several improvements: - Follow opaque aliases as if they were aliases. Otherwise we risk crashing in phases where the `opaque` is dropped and these become regular aliases. - Update the `isInteresting` test to follow more types. Previously the test was too strict so some cycles were missed. - Make -explain-cyclic also explain for cycles detected by this check. Fixes #19372
- Loading branch information
Showing
7 changed files
with
177 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,70 @@ | ||
-- Error: tests/neg/i15507.scala:2:40 ---------------------------------------------------------------------------------- | ||
2 | type _NestedSet1[X] = Set[_NestedSet1[?]] // error | ||
-- Error: tests/neg/i15507.scala:3:40 ---------------------------------------------------------------------------------- | ||
3 | type _NestedSet1[X] = Set[_NestedSet1[?]] // error | ||
| ^ | ||
| no wildcard type allowed here | ||
-- Error: tests/neg/i15507.scala:3:41 ---------------------------------------------------------------------------------- | ||
3 | type _NestedSet2[X] <: Set[_NestedSet2[?]] // error | ||
-- Error: tests/neg/i15507.scala:4:41 ---------------------------------------------------------------------------------- | ||
4 | type _NestedSet2[X] <: Set[_NestedSet2[?]] // error | ||
| ^ | ||
| no wildcard type allowed here | ||
-- [E140] Cyclic Error: tests/neg/i15507.scala:5:7 --------------------------------------------------------------------- | ||
5 | type _NestedSet4[X] >: Set[_NestedSet4[X]] // error | ||
-- [E140] Cyclic Error: tests/neg/i15507.scala:6:7 --------------------------------------------------------------------- | ||
6 | type _NestedSet4[X] >: Set[_NestedSet4[X]] // error | ||
| ^ | ||
| illegal cyclic type reference: lower bound ... of type _NestedSet4 refers back to the type itself | ||
-- [E140] Cyclic Error: tests/neg/i15507.scala:6:7 --------------------------------------------------------------------- | ||
6 | type _NestedSet5[X] = Set[_NestedSet5[X]] // error | ||
| | ||
| The error occurred while trying to compute the signature of type _NestedSet4 | ||
| which required to explore type _NestedSet4 for cyclic references | ||
| | ||
| Run with both -explain-cyclic and -Ydebug-cyclic to see full stack trace. | ||
-- [E140] Cyclic Error: tests/neg/i15507.scala:7:7 --------------------------------------------------------------------- | ||
7 | type _NestedSet5[X] = Set[_NestedSet5[X]] // error | ||
| ^ | ||
| illegal cyclic type reference: alias ... of type _NestedSet5 refers back to the type itself | ||
-- [E140] Cyclic Error: tests/neg/i15507.scala:7:7 --------------------------------------------------------------------- | ||
7 | type _NestedSet6[X] = Set[_NestedSet6[Int]] // error | ||
| | ||
| The error occurred while trying to compute the signature of type _NestedSet5 | ||
| which required to explore type _NestedSet5 for cyclic references | ||
| | ||
| Run with both -explain-cyclic and -Ydebug-cyclic to see full stack trace. | ||
-- [E140] Cyclic Error: tests/neg/i15507.scala:8:7 --------------------------------------------------------------------- | ||
8 | type _NestedSet6[X] = Set[_NestedSet6[Int]] // error | ||
| ^ | ||
| illegal cyclic type reference: alias ... of type _NestedSet6 refers back to the type itself | ||
-- Error: tests/neg/i15507.scala:9:43 ---------------------------------------------------------------------------------- | ||
9 | type _NestedList1[X] = List[_NestedList1[?]] // error | ||
| ^ | ||
| no wildcard type allowed here | ||
-- Error: tests/neg/i15507.scala:10:44 --------------------------------------------------------------------------------- | ||
10 | type _NestedList2[X] <: List[_NestedList2[?]] // error | ||
| | ||
| The error occurred while trying to compute the signature of type _NestedSet6 | ||
| which required to explore type _NestedSet6 for cyclic references | ||
| | ||
| Run with both -explain-cyclic and -Ydebug-cyclic to see full stack trace. | ||
-- Error: tests/neg/i15507.scala:10:43 --------------------------------------------------------------------------------- | ||
10 | type _NestedList1[X] = List[_NestedList1[?]] // error | ||
| ^ | ||
| no wildcard type allowed here | ||
-- Error: tests/neg/i15507.scala:11:44 --------------------------------------------------------------------------------- | ||
11 | type _NestedList2[X] <: List[_NestedList2[?]] // error | ||
| ^ | ||
| no wildcard type allowed here | ||
-- [E140] Cyclic Error: tests/neg/i15507.scala:12:7 -------------------------------------------------------------------- | ||
12 | type _NestedList4[X] >: List[_NestedList4[X]] // error | ||
-- [E140] Cyclic Error: tests/neg/i15507.scala:13:7 -------------------------------------------------------------------- | ||
13 | type _NestedList4[X] >: List[_NestedList4[X]] // error | ||
| ^ | ||
| illegal cyclic type reference: lower bound ... of type _NestedList4 refers back to the type itself | ||
-- [E140] Cyclic Error: tests/neg/i15507.scala:13:7 -------------------------------------------------------------------- | ||
13 | type _NestedList5[X] = List[_NestedList5[X]] // error | ||
| | ||
| The error occurred while trying to compute the signature of type _NestedList4 | ||
| which required to explore type _NestedList4 for cyclic references | ||
| | ||
| Run with both -explain-cyclic and -Ydebug-cyclic to see full stack trace. | ||
-- [E140] Cyclic Error: tests/neg/i15507.scala:14:7 -------------------------------------------------------------------- | ||
14 | type _NestedList5[X] = List[_NestedList5[X]] // error | ||
| ^ | ||
| illegal cyclic type reference: alias ... of type _NestedList5 refers back to the type itself | ||
-- [E140] Cyclic Error: tests/neg/i15507.scala:14:7 -------------------------------------------------------------------- | ||
14 | type _NestedList6[X] = List[_NestedList6[Int]] // error | ||
| | ||
| The error occurred while trying to compute the signature of type _NestedList5 | ||
| which required to explore type _NestedList5 for cyclic references | ||
| | ||
| Run with both -explain-cyclic and -Ydebug-cyclic to see full stack trace. | ||
-- [E140] Cyclic Error: tests/neg/i15507.scala:15:7 -------------------------------------------------------------------- | ||
15 | type _NestedList6[X] = List[_NestedList6[Int]] // error | ||
| ^ | ||
| illegal cyclic type reference: alias ... of type _NestedList6 refers back to the type itself | ||
| | ||
| The error occurred while trying to compute the signature of type _NestedList6 | ||
| which required to explore type _NestedList6 for cyclic references | ||
| | ||
| Run with both -explain-cyclic and -Ydebug-cyclic to see full stack trace. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
-- [E140] Cyclic Error: tests/neg/i19372.scala:3:7 --------------------------------------------------------------------- | ||
3 | type AAA = List[bar.BBB] // error: cyclic | ||
| ^ | ||
| illegal cyclic type reference: alias List[Test1.bar.BBB] of type AAA refers back to the type itself | ||
| | ||
| The error occurred while trying to compute the signature of type AAA | ||
| which required to explore type BBB for cyclic references | ||
| which required to explore type AAA for cyclic references | ||
| | ||
| Run with both -explain-cyclic and -Ydebug-cyclic to see full stack trace. | ||
-- [E140] Cyclic Error: tests/neg/i19372.scala:9:7 --------------------------------------------------------------------- | ||
9 | type A = bar.B // error: cyclic | ||
| ^ | ||
| illegal cyclic type reference: alias Test2.bar.B of type A refers back to the type itself | ||
| | ||
| The error occurred while trying to compute the signature of type A | ||
| which required to explore type B for cyclic references | ||
| which required to explore type A for cyclic references | ||
| | ||
| Run with both -explain-cyclic and -Ydebug-cyclic to see full stack trace. | ||
-- [E140] Cyclic Error: tests/neg/i19372.scala:15:7 -------------------------------------------------------------------- | ||
15 | type AAA = List[bar.BBB] // error: cyclic | ||
| ^ | ||
| illegal cyclic type reference: alias List[Test3.bar.BBB] of type AAA refers back to the type itself | ||
| | ||
| The error occurred while trying to compute the signature of type AAA | ||
| which required to explore type BBB for cyclic references | ||
| which required to explore type AAA for cyclic references | ||
| | ||
| Run with both -explain-cyclic and -Ydebug-cyclic to see full stack trace. | ||
-- [E140] Cyclic Error: tests/neg/i19372.scala:21:7 -------------------------------------------------------------------- | ||
21 | type A = bar.B // error: cyclic | ||
| ^ | ||
| illegal cyclic type reference: alias Test4.bar.B of type A refers back to the type itself | ||
| | ||
| The error occurred while trying to compute the signature of type A | ||
| which required to explore type B for cyclic references | ||
| which required to explore type A for cyclic references | ||
| | ||
| Run with both -explain-cyclic and -Ydebug-cyclic to see full stack trace. | ||
-- [E140] Cyclic Error: tests/neg/i19372.scala:30:7 -------------------------------------------------------------------- | ||
30 | type UCharIteratorReserved = Ptr[UCharIterator] // error: cyclic | ||
| ^ | ||
|illegal cyclic type reference: alias Ptr[structs.UCharIterator] of type UCharIteratorReserved refers back to the type itself | ||
| | ||
|The error occurred while trying to compute the signature of type UCharIteratorReserved | ||
| which required to explore type UCharIterator for cyclic references | ||
| which required to explore type UCharIteratorReserved for cyclic references | ||
| | ||
| Run with both -explain-cyclic and -Ydebug-cyclic to see full stack trace. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
//> using options -explain-cyclic | ||
object Test1: | ||
type AAA = List[bar.BBB] // error: cyclic | ||
def foo: AAA = ??? | ||
object bar: | ||
opaque type BBB = AAA | ||
|
||
object Test2: | ||
type A = bar.B // error: cyclic | ||
def foo: A = ??? | ||
object bar: | ||
opaque type B = A | ||
|
||
object Test3: | ||
type AAA = List[bar.BBB] // error: cyclic | ||
def foo: AAA = ??? | ||
object bar: | ||
type BBB = AAA | ||
|
||
object Test4: | ||
type A = bar.B // error: cyclic | ||
def foo: A = ??? | ||
object bar: | ||
type B = A | ||
|
||
trait Ptr[T] | ||
|
||
object aliases: | ||
import structs.* | ||
type UCharIteratorReserved = Ptr[UCharIterator] // error: cyclic | ||
object UCharIteratorReserved: | ||
def iterator: UCharIterator = ??? | ||
|
||
object structs: | ||
import aliases.{*, given} | ||
opaque type UCharIterator = Ptr[UCharIteratorReserved] | ||
object UCharIterator: | ||
def reservedFn: UCharIteratorReserved = ??? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters