diff --git a/compiler/src/dotty/tools/dotc/core/TypeComparer.scala b/compiler/src/dotty/tools/dotc/core/TypeComparer.scala index 3e7fce488a6a..902b099ccf20 100644 --- a/compiler/src/dotty/tools/dotc/core/TypeComparer.scala +++ b/compiler/src/dotty/tools/dotc/core/TypeComparer.scala @@ -1081,9 +1081,8 @@ class TypeComparer(initctx: Context) extends ConstraintHandling[AbsentContext] { */ def compareCaptured(arg1: TypeBounds, arg2: Type) = tparam match { case tparam: Symbol - if leftRoot.isStable || ctx.isAfterTyper || ctx.mode.is(Mode.TypevarsMissContext) => + if leftRoot.isStable || (ctx.isAfterTyper || ctx.mode.is(Mode.TypevarsMissContext)) && leftRoot.member(tparam.name).exists => val captured = TypeRef(leftRoot, tparam) - assert(captured.exists, i"$leftRoot has no member $tparam in isSubArgs($args1, $args2, $tp1, $tparams2)") isSubArg(captured, arg2) case _ => false diff --git a/tests/pos/i6033.scala b/tests/pos/i6033.scala new file mode 100644 index 000000000000..40e8ca557dc8 --- /dev/null +++ b/tests/pos/i6033.scala @@ -0,0 +1,5 @@ +class Test { + def f(a: Array[_]|Null): Unit = a match { + case x: Array[Int] => + } +}