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 @@ -2162,6 +2162,15 @@ class TrackingTypeComparer(initctx: Context) extends TypeComparer(initctx) {
2162
2162
case _ =>
2163
2163
cas
2164
2164
}
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
+
2165
2174
val defn .MatchCase (pat, body) = cas1
2166
2175
if (isSubType(scrut, pat))
2167
2176
// `scrut` is a subtype of `pat`: *It's a Match!*
@@ -2174,12 +2183,14 @@ class TrackingTypeComparer(initctx: Context) extends TypeComparer(initctx) {
2174
2183
body
2175
2184
}
2176
2185
}
2177
- else if (intersecting( scrut, pat))
2186
+ else if (isSubType(widenAbstractTypes( scrut), widenAbstractTypes( pat) ))
2178
2187
Some (NoType )
2179
- else
2188
+ else if ( ! intersecting(scrut, pat))
2180
2189
// We found a proof that `scrut` and `pat` are incompatible.
2181
2190
// The search continues.
2182
2191
None
2192
+ else
2193
+ Some (NoType )
2183
2194
}
2184
2195
2185
2196
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