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 @@ -451,7 +451,11 @@ class TypeComparer(initctx: Context) extends ConstraintHandling[AbsentContext] {
451
451
// widening in `fourthTry` before adding to the constraint.
452
452
if (frozenConstraint) isSubType(tp1, bounds(tp2).lo)
453
453
else isSubTypeWhenFrozen(tp1, tp2)
454
- alwaysTrue || {
454
+ alwaysTrue ||
455
+ frozenConstraint && (tp1 match {
456
+ case tp1 : TypeParamRef => constraint.isLess(tp1, tp2)
457
+ case _ => false
458
+ }) || {
455
459
if (canConstrain(tp2) && ! approx.low)
456
460
addConstraint(tp2, tp1.widenExpr, fromBelow = true )
457
461
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