Skip to content

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

Closed
@Jasper-M

Description

@Jasper-M

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions