File tree 4 files changed +43
-5
lines changed
compiler/src/dotty/tools/dotc/core
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 {
405
405
case dealiased : LazyRef =>
406
406
LazyRef (c => dealiased.ref(c).appliedTo(args))
407
407
case dealiased : WildcardType =>
408
- WildcardType (dealiased.optBounds.appliedTo(args).bounds)
408
+ WildcardType (dealiased.optBounds.orElse( TypeBounds .empty). appliedTo(args).bounds)
409
409
case dealiased : TypeRef if dealiased.symbol == defn.NothingClass =>
410
410
dealiased
411
411
case dealiased =>
Original file line number Diff line number Diff line change @@ -2152,6 +2152,15 @@ class TrackingTypeComparer(initctx: Context) extends TypeComparer(initctx) {
2152
2152
case _ =>
2153
2153
cas
2154
2154
}
2155
+ def widenAbstractTypes (tp : Type ) = new TypeMap {
2156
+ def apply (tp : Type ) = tp match {
2157
+ case tp : TypeRef if tp.symbol.isAbstractOrParamType | tp.symbol.isOpaqueAlias => WildcardType
2158
+ case tp : TypeVar if ! tp.isInstantiated => WildcardType
2159
+ case _ : SkolemType | _ : TypeParamRef => WildcardType
2160
+ case _ => mapOver(tp)
2161
+ }
2162
+ }.apply(tp)
2163
+
2155
2164
val defn .MatchCase (pat, body) = cas1
2156
2165
if (isSubType(scrut, pat))
2157
2166
// `scrut` is a subtype of `pat`: *It's a Match!*
@@ -2164,12 +2173,14 @@ class TrackingTypeComparer(initctx: Context) extends TypeComparer(initctx) {
2164
2173
body
2165
2174
}
2166
2175
}
2167
- else if (intersecting( scrut, pat))
2176
+ else if (isSubType(widenAbstractTypes( scrut), widenAbstractTypes( pat) ))
2168
2177
Some (NoType )
2169
- else
2178
+ else if ( ! intersecting(scrut, pat))
2170
2179
// We found a proof that `scrut` and `pat` are incompatible.
2171
2180
// The search continues.
2172
2181
None
2182
+ else
2183
+ Some (NoType )
2173
2184
}
2174
2185
2175
2186
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 {
305
305
}
306
306
307
307
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)
310
311
unpickleElems[g.ElemTypes ](0 )(buf, elems)
311
312
g.fromProduct(ArrayProduct (elems))
312
313
}
You can’t perform that action at this time.
0 commit comments