File tree Expand file tree Collapse file tree 3 files changed +28
-5
lines changed
compiler/src/dotty/tools/dotc Expand file tree Collapse file tree 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 {
14411441 private def dealias1 (keep : AnnotatedType => Context ?=> Boolean , keepOpaques : Boolean )(using Context ): Type = this match {
14421442 case tp : TypeRef =>
14431443 if (tp.symbol.isClass) tp
1444+ else if keepOpaques && tp.symbol.is(Opaque ) then tp
14441445 else tp.info match {
1445- case TypeAlias (alias) if ! (keepOpaques && tp.symbol.is( Opaque )) =>
1446+ case TypeAlias (alias) =>
14461447 alias.dealias1(keep, keepOpaques)
1448+ case MatchAlias (alias : AppliedType ) =>
1449+ (alias : Type ).dealias1(keep, keepOpaques)
14471450 case _ => tp
14481451 }
14491452 case app @ AppliedType (tycon, _) =>
Original file line number Diff line number Diff line change @@ -446,16 +446,13 @@ object Inlines:
446446 evidence
447447 }
448448
449- def unrollTupleTypes (tpe : Type ): Option [List [Type ]] = tpe.dealias match
449+ def unrollTupleTypes (tpe : Type ): Option [List [Type ]] = tpe.dealias.normalized match
450450 case AppliedType (tycon, args) if defn.isTupleClass(tycon.typeSymbol) =>
451451 Some (args)
452452 case AppliedType (tycon, head :: tail :: Nil ) if tycon.isRef(defn.PairClass ) =>
453453 unrollTupleTypes(tail).map(head :: _)
454454 case tpe : TermRef if tpe.symbol == defn.EmptyTupleModule =>
455455 Some (Nil )
456- case tpRef : TypeRef => tpRef.info match
457- case MatchAlias (alias) => unrollTupleTypes(alias.tryNormalize)
458- case _ => None
459456 case _ =>
460457 None
461458
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