File tree Expand file tree Collapse file tree 4 files changed +43
-5
lines changed
compiler/src/dotty/tools/dotc/core Expand file tree Collapse file tree 4 files changed +43
-5
lines changed Original file line number Diff line number Diff line change @@ -405,7 +405,7 @@ class TypeApplications(val self: Type) extends AnyVal {
405405 case dealiased : LazyRef =>
406406 LazyRef (c => dealiased.ref(c).appliedTo(args))
407407 case dealiased : WildcardType =>
408- WildcardType (dealiased.optBounds.appliedTo(args).bounds)
408+ WildcardType (dealiased.optBounds.orElse( TypeBounds .empty). appliedTo(args).bounds)
409409 case dealiased : TypeRef if dealiased.symbol == defn.NothingClass =>
410410 dealiased
411411 case dealiased =>
Original file line number Diff line number Diff line change @@ -2162,6 +2162,15 @@ class TrackingTypeComparer(initctx: Context) extends TypeComparer(initctx) {
21622162 case _ =>
21632163 cas
21642164 }
2165+ def widenAbstractTypes (tp : Type ) = new TypeMap {
2166+ def apply (tp : Type ) = tp match {
2167+ case tp : TypeRef if tp.symbol.isAbstractOrParamType | tp.symbol.isOpaqueAlias => WildcardType
2168+ case tp : TypeVar if ! tp.isInstantiated => WildcardType
2169+ case _ : SkolemType | _ : TypeParamRef => WildcardType
2170+ case _ => mapOver(tp)
2171+ }
2172+ }.apply(tp)
2173+
21652174 val defn .MatchCase (pat, body) = cas1
21662175 if (isSubType(scrut, pat))
21672176 // `scrut` is a subtype of `pat`: *It's a Match!*
@@ -2174,12 +2183,14 @@ class TrackingTypeComparer(initctx: Context) extends TypeComparer(initctx) {
21742183 body
21752184 }
21762185 }
2177- else if (intersecting( scrut, pat))
2186+ else if (isSubType(widenAbstractTypes( scrut), widenAbstractTypes( pat) ))
21782187 Some (NoType )
2179- else
2188+ else if ( ! intersecting(scrut, pat))
21802189 // We found a proof that `scrut` and `pat` are incompatible.
21812190 // The search continues.
21822191 None
2192+ else
2193+ Some (NoType )
21832194 }
21842195
21852196 def recur (cases : List [Type ]): Type = cases match {
Original file line number Diff line number Diff line change 1+ object G {
2+ final class X
3+ final class Y
4+
5+ trait FooSig {
6+ type Type
7+ def apply [F [_]](fa : F [X & Y ]): F [Y & Type ]
8+ }
9+ val Foo : FooSig = new FooSig {
10+ type Type = X & Y
11+ def apply [F [_]](fa : F [X & Y ]): F [Y & Type ] = fa
12+ }
13+ type Foo = Foo .Type
14+
15+ type Bar [A ] = A match {
16+ case X & Y => String
17+ case Y => Int
18+ }
19+
20+ def main (args : Array [String ]): Unit = {
21+ val a : Bar [X & Y ] = " hello"
22+ val i : Bar [Y & Foo ] = Foo .apply[Bar ](a)
23+ val b : Int = i // error
24+ println(b + 1 )
25+ }
26+ }
Original file line number Diff line number Diff line change @@ -305,8 +305,9 @@ object Pickler {
305305 }
306306
307307 inline def unpickleProduct [T ](g : Generic .Product [T ])(buf : mutable.ListBuffer [Int ]): T = {
308- inline val size = constValue[Tuple .Size [g.ElemTypes ]]
309- val elems = new Array [Object ](size)
308+ // inline val size = constValue[Tuple.Size[g.ElemTypes]]
309+ // val elems = new Array[Object](size)
310+ val elems = new Array [Object ](buf.size)
310311 unpickleElems[g.ElemTypes ](0 )(buf, elems)
311312 g.fromProduct(ArrayProduct (elems))
312313 }
You can’t perform that action at this time.
0 commit comments