Skip to content

Commit

Permalink
Normalize for underlyingClassRef
Browse files Browse the repository at this point in the history
Related to #20258
Here too, I would be fine with not normalizing,
but in that case pos/i15827 should become a neg test.
  • Loading branch information
EugeneFlesselle committed Apr 24, 2024
1 parent 05114dd commit ae3b271
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion compiler/src/dotty/tools/dotc/core/Types.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1584,7 +1584,8 @@ object Types extends TypeUtils {
else if (tp.symbol.isAliasType) tp.underlying.underlyingClassRef(refinementOK)
else NoType
case tp: AppliedType =>
if (tp.tycon.isLambdaSub) NoType
if tp.isMatchAlias then tp.tryNormalize.underlyingClassRef(refinementOK)
else if (tp.tycon.isLambdaSub) NoType
else tp.superType.underlyingClassRef(refinementOK)
case tp: AnnotatedType =>
tp.parent.underlyingClassRef(refinementOK)
Expand Down
8 changes: 8 additions & 0 deletions tests/pos/i15827b/A_1.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

case class Foo()

type T = Tuple.Elem[(Foo, Any), 0]
type U = Tuple.Elem[(Any, T), 1]

val _ = new T() // ok
val _ = new U() // ok
3 changes: 3 additions & 0 deletions tests/pos/i15827b/B_2.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

val _ = new T() // was error
val _ = new U() // was error

0 comments on commit ae3b271

Please sign in to comment.