You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
valmatched2= (for (l <- li) yield {
l match {
case_: TwithTAwithTB=>"tab"case_: TwithTA=>"ta"case_: TwithTB=>"tb"
}
})
println(matched2)
// prints// Vector(ta, tb, tab)// For comparison: This works correctly
println((newA).isInstanceOf[TAwithTB]) // prints false
println((newB).isInstanceOf[TAwithTB]) // prints false
println((newAB).isInstanceOf[TAwithTB]) // prints true
Running with -Xprint:typer, both match statements are identical (and the isInstanceOf clause is inferred to be [T with TA with TB] in both cases)
Rike-Benjamin Schuppner (debilski) said (edited on Apr 29, 2012 11:03:08 PM UTC):
The problem seems to be that in the broken case a nested RefinedType is generated (OOO being an outer class):
On erasure when generating the isInstanceOf[TA] && isInstanceOf[TB] cascades, an inner RefinedType is not handled and thus the [TA with TB] type stays there until TB is eventually erased.
If I have the following inheritance structure
Matching on
_: TA with TB
Matching on
_: T with TA with TB
Running with -Xprint:typer, both match statements are identical (and the isInstanceOf clause is inferred to be [T with TA with TB] in both cases)
-Xprint:erasure however shows the difference:
matched:
matched2:
So, the check against TB is somehow missing when one writes
\_: TA with TB
but is included if it is written as\_: T with TA with TB
.The text was updated successfully, but these errors were encountered: