Skip to content

Commit 93cff1e

Browse files
safeDealias for underlyingMatchType
We already dealias the tycon of an applied type for the underlyingMatchType This generalizes to all TypeRefs
1 parent 83f573d commit 93cff1e

File tree

6 files changed

+9
-9
lines changed

6 files changed

+9
-9
lines changed

compiler/src/dotty/tools/dotc/core/Types.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ object Types extends TypeUtils {
468468
/** Does this application expand to a match type? */
469469
def isMatchAlias(using Context): Boolean = underlyingMatchType.exists
470470

471-
def underlyingMatchType(using Context): Type = stripped match
471+
def underlyingMatchType(using Context): Type = this.safeDealias match
472472
case tp: MatchType => tp
473473
case tp: AppliedType => tp.underlyingMatchType
474474
case _ => NoType

tests/neg/i14834.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
type F[_] = A
2-
type A = F[?] // error: cyclic
1+
type F[_] = A // error: cyclic
2+
type A = F[?] // error: no wildcard type allowed here

tests/neg/i4368.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,8 @@ object i4369 {
154154
class Foo extends X { type R = Foo; type Z = Foo }
155155
}
156156
object i4370 {
157-
class Foo { type R = A }
158-
type A = List[Foo#R] // error: cyclic
157+
class Foo { type R = A } // error: cyclic
158+
type A = List[Foo#R]
159159
}
160160
object i4371 {
161161
class Foo { type A = Boo#B } // error: cyclic

tests/neg/i4370.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
object App {
2-
class Foo { type R = A }
3-
type A = List[Foo#R] // error
2+
class Foo { type R = A } // error
3+
type A = List[Foo#R]
44
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
type A = B
1+
type A = B // error: cyclic
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
type B = A // error: recursion limit exceeded
1+
type B = A

0 commit comments

Comments
 (0)