File tree Expand file tree Collapse file tree 4 files changed +20
-30
lines changed
compiler/src/dotty/tools/dotc/core Expand file tree Collapse file tree 4 files changed +20
-30
lines changed Original file line number Diff line number Diff line change @@ -550,10 +550,15 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
550550 || ! ctx.mode.is(Mode .CheckBoundsOrSelfType ) && tp1.isAlwaysPure
551551 || parent1.isSingleton && refs1.elems.forall(parent1 eq _)
552552 then
553+ def remainsBoxed1 = parent1.isBoxedCapturing || parent1.dealias.match
554+ case parent1 : TypeRef =>
555+ parent1.superType.isBoxedCapturing
556+ // When comparing a type parameter with boxed upper bound on the left
557+ // we should not strip the box on the right. See i24543.scala.
558+ case _ =>
559+ false
553560 val tp2a =
554- if tp1.isBoxedCapturing && ! parent1.isBoxedCapturing
555- then tp2.unboxed
556- else tp2
561+ if tp1.isBoxedCapturing && ! remainsBoxed1 then tp2.unboxed else tp2
557562 recur(parent1, tp2a)
558563 else thirdTry
559564 compareCapturing
@@ -2916,7 +2921,7 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
29162921 subc
29172922 && (tp1.isBoxedCapturing == tp2.isBoxedCapturing
29182923 || refs1.subCaptures(CaptureSet .EmptyOfBoxed (tp1, tp2), makeVarState()))
2919-
2924+
29202925 protected def logUndoAction (action : () => Unit ) =
29212926 undoLog += action
29222927
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -4,9 +4,9 @@ class Ref
44case class Box [T ](elem : T )
55
66def h1 [T <: Ref ^ ](x : Box [T ]): Unit =
7- val y : (Ref ^ , Int ) = (x.elem, 1 ) // error
7+ val y : (Ref ^ , Int ) = (x.elem, 1 ) // was error
88
9- def h2 [T <: Ref ^ ](x : List [T ]): (Ref ^ , Int ) = (x.head, 1 ) // error
9+ def h2 [T <: Ref ^ ](x : List [T ]): (Ref ^ , Int ) = (x.head, 1 ) // was error
1010
1111
1212
Original file line number Diff line number Diff line change 1+ import scala .language .experimental .captureChecking
2+ class Ref
3+ case class Box [+ T ](elem : T )
4+
5+ def test1 (a : Ref ^ ): Unit =
6+ def hh [T <: Ref ^ {a}](x : Box [T ]): Unit =
7+ val y : (Ref ^ {a}, Int ) = (x.elem, 1 )
8+ val z = (x.elem, 1 )
9+ val _: (Ref ^ {a}, Int ) = z
You can’t perform that action at this time.
0 commit comments