File tree 2 files changed +27
-1
lines changed
src/dotty/tools/dotc/core
test/dotty/tools/dotc/typer
2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -482,7 +482,11 @@ class TypeComparer(initctx: Context) extends ConstraintHandling[AbsentContext] {
482
482
// widening in `fourthTry` before adding to the constraint.
483
483
if (frozenConstraint) recur(tp1, bounds(tp2).lo)
484
484
else isSubTypeWhenFrozen(tp1, tp2)
485
- alwaysTrue || {
485
+ alwaysTrue ||
486
+ frozenConstraint && (tp1 match {
487
+ case tp1 : TypeParamRef => constraint.isLess(tp1, tp2)
488
+ case _ => false
489
+ }) || {
486
490
if (canConstrain(tp2) && ! approx.low)
487
491
addConstraint(tp2, tp1.widenExpr, fromBelow = true )
488
492
else fourthTry
Original file line number Diff line number Diff line change
1
+ package dotty .tools .dotc .typer
2
+
3
+ import dotty .tools .DottyTest
4
+ import dotty .tools .dotc .core .Contexts .Context
5
+ import dotty .tools .dotc .core .Types .TypeBounds
6
+ import dotty .tools .dotc .typer .ProtoTypes .newTypeVar
7
+ import org .junit .Test
8
+
9
+ class SubtypingInvariantTests extends DottyTest {
10
+
11
+ @ Test
12
+ def typeVarInvariant (): Unit = {
13
+ checkCompile(" frontend" , " class A" ) { (_, ctx0) =>
14
+ implicit val ctx : Context = ctx0
15
+ val a = newTypeVar(TypeBounds .empty)
16
+ val b = newTypeVar(TypeBounds .empty)
17
+ assert(a <:< b)
18
+ assert(a frozen_<:< b)
19
+ }
20
+ }
21
+
22
+ }
You can’t perform that action at this time.
0 commit comments