Skip to content
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

Type test of polymorphic inner class does not check outer reference #13418

Closed
Jasper-M opened this issue Aug 30, 2021 · 0 comments · Fixed by #13420
Closed

Type test of polymorphic inner class does not check outer reference #13418

Jasper-M opened this issue Aug 30, 2021 · 0 comments · Fixed by #13420
Milestone

Comments

@Jasper-M
Copy link
Member

Compiler version

3.0.1

Minimized code

class A { class B }
val a1 = new A
val a2 = new A
val b: Any = new a1.B
b match {
  case _: a2.B => println("match")
  case _ => println("no match")
}

class X { class Y[Q] }
val x1 = new X
val x2 = new X
val y: Any = new x1.Y[Int]
y match {
  case _: x2.Y[_] => println("match")
  case _ => println("no match")
}

Output

no match
match

Expectation

no match
no match

Whether or not an inner class is polymorphic shouldn't make a difference here. This behavior also differs from Scala 2. As far as I can see in the commit history this change doesn't seem to be a conscious decision.

odersky added a commit that referenced this issue Oct 2, 2021
Fix #13418: support AppliedType in outerTestNeeded
@Kordyjan Kordyjan added this to the 3.1.1 milestone Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants