Skip to content

Commit f8931ab

Browse files
committed
Fix #6033: avoid capture conversion if member absent
1 parent 8ecc927 commit f8931ab

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1081,7 +1081,7 @@ 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)
10861086
assert(captured.exists, i"$leftRoot has no member $tparam in isSubArgs($args1, $args2, $tp1, $tparams2)")
10871087
isSubArg(captured, arg2)

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)