Skip to content

Fix #6033: avoid capture conversion if member absent #6162

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions compiler/src/dotty/tools/dotc/core/TypeComparer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions tests/pos/i6033.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class Test {
def f(a: Array[_]|Null): Unit = a match {
case x: Array[Int] =>
}
}