Skip to content

Commit 10e4494

Browse files
oderskyallanrenucci
authored andcommitted
Normalize match types when computing members
Normalizing via simplification is not enough since sometimes we need to "reach into" a pre-simplified type via the `isMatchedBy` method of a SelectionProto.
1 parent ea29eaf commit 10e4494

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

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

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -551,8 +551,12 @@ object Types {
551551
}
552552
case tp: AppliedType =>
553553
tp.tycon match {
554-
case tc: TypeRef if tc.symbol.isClass =>
555-
go(tc)
554+
case tc: TypeRef =>
555+
if (tc.symbol.isClass) go(tc)
556+
else {
557+
val normed = tp.tryNormalize
558+
go(if (normed.exists) normed else tp.superType)
559+
}
556560
case tc: HKTypeLambda =>
557561
goApplied(tp, tc)
558562
case _ =>
@@ -568,6 +572,9 @@ object Types {
568572
goParam(tp)
569573
case tp: SuperType =>
570574
goSuper(tp)
575+
case tp: MatchType =>
576+
val normed = tp.tryNormalize
577+
go(if (normed.exists) normed else tp.underlying)
571578
case tp: TypeProxy =>
572579
go(tp.underlying)
573580
case tp: ClassInfo =>
@@ -3283,14 +3290,14 @@ object Types {
32833290
case tycon: TypeRef =>
32843291
def tryMatchAlias = tycon.info match {
32853292
case MatchAlias(alias) =>
3286-
trace("normalize $this", typr, show = true) {
3293+
trace(i"normalize $this", typr, show = true) {
32873294
alias.applyIfParameterized(args).tryNormalize
32883295
}
32893296
case _ =>
32903297
NoType
32913298
}
32923299
if (defn.isTypelevel_S(tycon.symbol) && args.length == 1) {
3293-
trace("normalize S $this", typr, show = true) {
3300+
trace(i"normalize S $this", typr, show = true) {
32943301
args.head.normalized match {
32953302
case ConstantType(Constant(n: Int)) => ConstantType(Constant(n + 1))
32963303
case none => tryMatchAlias

0 commit comments

Comments
 (0)