Warning: I’m cross-posting from #scala
The book Programming in Scala states that path-dependent types are different depending on the exact instance of the path in question. If so, I don’t understand why all the following predicates return true:
class Outer {
val in = new Inner
class Inner
}
val o1 = new Outer
val o2 = new Outer
o1.in.isInstanceOf[Outer#Inner] //makes perfect sense
o1.in.isInstanceOf[o1.Inner] //still makes sense, the path-dependent type is o1's own
o1.in.isInstanceOf[o2.Inner] //why is this true? PiS p.423 says the path-dependent types are different, they only share a common supertype Outer#Inner
o1.Innerando2.Innerare different types, but their erasures are the same:and
o1.in.isInstanceOf[o2.Inner]can only check thato1.inis an instance of the erasure ofo2.Inner.