File tree Expand file tree Collapse file tree 5 files changed +12
-9
lines changed
compiler/src/dotty/tools/dotc Expand file tree Collapse file tree 5 files changed +12
-9
lines changed Original file line number Diff line number Diff line change @@ -3327,6 +3327,10 @@ object Types {
3327
3327
def instantiate (fromBelow : Boolean )(implicit ctx : Context ): Type =
3328
3328
instantiateWith(ctx.typeComparer.instanceType(origin, fromBelow))
3329
3329
3330
+ /** For uninstantiated type variables: Is the lower bound different from Nothing? */
3331
+ def hasLowerBound (implicit ctx : Context ) =
3332
+ ! ctx.typerState.constraint.entry(origin).loBound.isBottomType
3333
+
3330
3334
/** Unwrap to instance (if instantiated) or origin (if not), until result
3331
3335
* is no longer a TypeVar
3332
3336
*/
Original file line number Diff line number Diff line change @@ -389,7 +389,7 @@ trait Inferencing { this: Typer =>
389
389
if (! (vs contains tvar) && qualifies(tvar)) {
390
390
typr.println(s " instantiating non-occurring ${tvar.show} in ${tp.show} / $tp" )
391
391
ensureConstrained()
392
- tvar.instantiate(fromBelow = true )
392
+ tvar.instantiate(fromBelow = tvar.hasLowerBound )
393
393
}
394
394
}
395
395
if (constraint.uninstVars exists qualifies) interpolate()
Original file line number Diff line number Diff line change @@ -113,7 +113,8 @@ trait TypeAssigner {
113
113
case tp : SkolemType if partsToAvoid(mutable.Set .empty, tp.info).nonEmpty =>
114
114
range(tp.info.bottomType, apply(tp.info))
115
115
case tp : TypeVar if ctx.typerState.constraint.contains(tp) =>
116
- val lo = ctx.typeComparer.instanceType(tp.origin, fromBelow = variance >= 0 )
116
+ val lo = ctx.typeComparer.instanceType(
117
+ tp.origin, fromBelow = variance > 0 || variance == 0 && tp.hasLowerBound)
117
118
val lo1 = apply(lo)
118
119
if (lo1 ne lo) lo1 else tp
119
120
case _ =>
Original file line number Diff line number Diff line change @@ -56,7 +56,7 @@ class Failures {
56
56
}
57
57
58
58
// unsafe
59
- @ tailrec final def fail3 [T ](x : Int ): Int = fail3(x - 1 )
59
+ @ tailrec final def fail3 [T ](x : Int ): Int = fail3(x - 1 ) // error // error: recursive application has different type arguments
60
60
61
61
// unsafe
62
62
class Tom [T ](x : Int ) {
Original file line number Diff line number Diff line change
1
+
1
2
object A {
2
- def fun [E >: B ](a : A [E ]): E => Unit = ???
3
- val x = fun(new A [C ])
3
+ def fun [E ](a : A [E ]): Unit = ()
4
+ fun(new A [Int ])
4
5
}
5
- class B extends C
6
- class C
7
-
8
- class A [- X >: B ]
6
+ class A [- X ]
You can’t perform that action at this time.
0 commit comments