Skip to content

Commit cc3ff0b

Browse files
authored
Merge pull request #6162 from dotty-staging/fix-6033b
Fix #6033: avoid capture conversion if member absent
2 parents 7e24c14 + f05e595 commit cc3ff0b

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,9 +1081,8 @@ class TypeComparer(initctx: Context) extends ConstraintHandling[AbsentContext] {
10811081
*/
10821082
def compareCaptured(arg1: TypeBounds, arg2: Type) = tparam match {
10831083
case tparam: Symbol
1084-
if leftRoot.isStable || ctx.isAfterTyper || ctx.mode.is(Mode.TypevarsMissContext) =>
1084+
if leftRoot.isStable || (ctx.isAfterTyper || ctx.mode.is(Mode.TypevarsMissContext)) && leftRoot.member(tparam.name).exists =>
10851085
val captured = TypeRef(leftRoot, tparam)
1086-
assert(captured.exists, i"$leftRoot has no member $tparam in isSubArgs($args1, $args2, $tp1, $tparams2)")
10871086
isSubArg(captured, arg2)
10881087
case _ =>
10891088
false

tests/pos/i6033.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class Test {
2+
def f(a: Array[_]|Null): Unit = a match {
3+
case x: Array[Int] =>
4+
}
5+
}

0 commit comments

Comments
 (0)