Skip to content

Commit 83a409d

Browse files
committed
Ignore capturing from parents when computing base type
1 parent 09b7f16 commit 83a409d

File tree

2 files changed

+3
-10
lines changed

2 files changed

+3
-10
lines changed

compiler/src/dotty/tools/dotc/core/SymDenotations.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import scala.util.control.NonFatal
2323
import config.Config
2424
import reporting.*
2525
import collection.mutable
26-
import cc.{CapturingType, derivedCapturingType}
26+
import cc.{CapturingType, derivedCapturingType, stripCapturing}
2727

2828
import scala.annotation.internal.sharable
2929
import scala.compiletime.uninitialized
@@ -2232,7 +2232,7 @@ object SymDenotations {
22322232
tp match {
22332233
case tp @ TypeRef(prefix, _) =>
22342234
def foldGlb(bt: Type, ps: List[Type]): Type = ps match {
2235-
case p :: ps1 => foldGlb(bt & recur(p), ps1)
2235+
case p :: ps1 => foldGlb(bt & recur(p.stripCapturing), ps1)
22362236
case _ => bt
22372237
}
22382238

compiler/src/dotty/tools/dotc/core/TypeComparer.scala

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -895,20 +895,13 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
895895
canWidenAbstract && acc(true, tp)
896896

897897
def tryBaseType(cls2: Symbol) =
898-
var base = nonExprBaseType(tp1, cls2)
898+
val base = nonExprBaseType(tp1, cls2)
899899
if base.exists && (base ne tp1)
900900
&& (!caseLambda.exists
901901
|| widenAbstractOKFor(tp2)
902902
|| tp1.widen.underlyingClassRef(refinementOK = true).exists)
903903
then
904904
def checkBase =
905-
// Strip existing capturing set from base type
906-
base = base.stripCapturing
907-
// Pass capture set of tp1 to base type
908-
tp1 match
909-
case tp1 @ CapturingType(_, refs1) =>
910-
base = CapturingType(base, refs1, tp1.isBoxed)
911-
case _ =>
912905
isSubType(base, tp2, if tp1.isRef(cls2) then approx else approx.addLow)
913906
&& recordGadtUsageIf { MatchType.thatReducesUsingGadt(tp1) }
914907
if tp1.widenDealias.isInstanceOf[AndType] || base.isInstanceOf[OrType] then

0 commit comments

Comments
 (0)