File tree 3 files changed +22
-10
lines changed
src/dotty/tools/dotc/core 3 files changed +22
-10
lines changed Original file line number Diff line number Diff line change @@ -2313,19 +2313,30 @@ class TrackingTypeComparer(initctx: Context) extends TypeComparer(initctx) {
2313
2313
cas
2314
2314
}
2315
2315
def widenAbstractTypes (tp : Type ): Type = new TypeMap {
2316
+ var seen = Set [TypeParamRef ]()
2316
2317
def apply (tp : Type ) = tp match {
2317
2318
case tp : TypeRef =>
2318
- if (tp.symbol.isAbstractOrParamType | tp.symbol.isOpaqueAlias)
2319
- WildcardType
2320
- else tp.info match {
2321
- case TypeAlias (alias) =>
2322
- val alias1 = widenAbstractTypes(alias)
2323
- if (alias1 ne alias) alias1 else tp
2324
- case _ => mapOver(tp)
2319
+ tp.info match {
2320
+ case info : MatchAlias =>
2321
+ mapOver(tp)
2322
+ // TODO: We should follow the alias in this case, but doing so
2323
+ // risks infinite recursion
2324
+ case TypeBounds (lo, hi) =>
2325
+ if (hi frozen_<:< lo) {
2326
+ val alias = apply(lo)
2327
+ if (alias ne lo) alias else mapOver(tp)
2328
+ }
2329
+ else WildcardType
2330
+ case _ =>
2331
+ mapOver(tp)
2325
2332
}
2326
-
2333
+ case tp : TypeLambda =>
2334
+ val saved = seen
2335
+ seen ++= tp.paramRefs
2336
+ try mapOver(tp)
2337
+ finally seen = saved
2327
2338
case tp : TypeVar if ! tp.isInstantiated => WildcardType
2328
- case _ : TypeParamRef => WildcardType
2339
+ case tp : TypeParamRef if ! seen.contains(tp) => WildcardType
2329
2340
case _ => mapOver(tp)
2330
2341
}
2331
2342
}.apply(tp)
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ typeclass-derivation1.scala
8
8
typeclass-derivation2.scala
9
9
typeclass-derivation2a.scala
10
10
typeclass-derivation2c.scala
11
+ typeclass-derivation2d.scala
11
12
typeclass-derivation3.scala
12
13
derive-generic.scala
13
14
mixin-forwarder-overload
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ object Test {
2
2
type L [X ] = X match {
3
3
case Int => L [X ]
4
4
}
5
- type LL [X ] = X match {
5
+ type LL [X ] = X match { // error: recursion limit exceeded
6
6
case Int => LL [LL [X ]]
7
7
}
8
8
def a : L [Boolean ] = ???
You can’t perform that action at this time.
0 commit comments