Reputation: 1786
The following definition doesn't trigger any warning on scala 2.10.4:
class NoWarning[T] {
def f: PartialFunction[Any, T] = { case x: List[T] => x.head }
}
However this one does (as expected) on scala 2.10.4, but not on 2.11.1:
class WithWarning {
def f[T]: PartialFunction[Any, T] = { case x: List[T] => x.head }
}
Upvotes: 4
Views: 166
Reputation: 39577
Odersky explains a difference in pattern matching depending on whether the type param is on the method or class.
I assume that's because of subclassing.
Upvotes: 0