File tree 3 files changed +28
-5
lines changed
compiler/src/dotty/tools/dotc
3 files changed +28
-5
lines changed Original file line number Diff line number Diff line change @@ -1441,9 +1441,12 @@ object Types extends TypeUtils {
1441
1441
private def dealias1 (keep : AnnotatedType => Context ?=> Boolean , keepOpaques : Boolean )(using Context ): Type = this match {
1442
1442
case tp : TypeRef =>
1443
1443
if (tp.symbol.isClass) tp
1444
+ else if keepOpaques && tp.symbol.is(Opaque ) then tp
1444
1445
else tp.info match {
1445
- case TypeAlias (alias) if ! (keepOpaques && tp.symbol.is( Opaque )) =>
1446
+ case TypeAlias (alias) =>
1446
1447
alias.dealias1(keep, keepOpaques)
1448
+ case MatchAlias (alias : AppliedType ) =>
1449
+ (alias : Type ).dealias1(keep, keepOpaques)
1447
1450
case _ => tp
1448
1451
}
1449
1452
case app @ AppliedType (tycon, _) =>
Original file line number Diff line number Diff line change @@ -446,16 +446,13 @@ object Inlines:
446
446
evidence
447
447
}
448
448
449
- def unrollTupleTypes (tpe : Type ): Option [List [Type ]] = tpe.dealias match
449
+ def unrollTupleTypes (tpe : Type ): Option [List [Type ]] = tpe.dealias.normalized match
450
450
case AppliedType (tycon, args) if defn.isTupleClass(tycon.typeSymbol) =>
451
451
Some (args)
452
452
case AppliedType (tycon, head :: tail :: Nil ) if tycon.isRef(defn.PairClass ) =>
453
453
unrollTupleTypes(tail).map(head :: _)
454
454
case tpe : TermRef if tpe.symbol == defn.EmptyTupleModule =>
455
455
Some (Nil )
456
- case tpRef : TypeRef => tpRef.info match
457
- case MatchAlias (alias) => unrollTupleTypes(alias.tryNormalize)
458
- case _ => None
459
456
case _ =>
460
457
None
461
458
Original file line number Diff line number Diff line change
1
+ type F [X ] = X match { case String => Option [Int ] }
2
+ type G [X ] = X match { case Option [x] => Int }
3
+
4
+ trait T :
5
+ type S
6
+ val opt1 : F [S ]
7
+ val opt2 : O1
8
+ type O1 = F [S ]
9
+
10
+ class Test :
11
+ def test : Unit =
12
+ val t : T { type S = String } = ???
13
+
14
+ val i1 : G [t.opt1.type ] = ???
15
+ val j1 : Int = i1
16
+
17
+ val i2 : G [t.opt2.type ] = ???
18
+ val j2 : Int = i2 // was:
19
+ // [E007] Type Mismatch Error: tests/pos/i19821.scala:17:18 --------------------
20
+ // val j2: Int = i2
21
+ // ^^
22
+ // Found: (i2 : G[(t.bar : t.O)])
23
+ // Required: Int
You can’t perform that action at this time.
0 commit comments