3
누군가 삭제 경고를주는 이유를 설명 할 수 있습니까?스칼라 스트림 삭제 경고
warning: non variable type-argument A in type pattern scala.collection.immutable.Stream[A] is unchecked since it is eliminated by erasure
case head #:: _ => Some(head)
은 내가 경고를 얻을이 경우 if (x.isInstanceOf[Stream[_]]) ...
를 작성하고 수 없습니다 실현,하지만 내 경우에는 내가 실제로 패턴 매칭을 사용하려는 경고의 모두 내가 돈을 갖는
def optionStreamHead(x: Any) =
x match {
case head #:: _ => Some(head)
case _ => None
}
을 제공합니다 t 이해 '나쁜
보인다 그리고 여기에 동등하게 수수께끼 사건 :
type IsStream = Stream[_]
("test": Any) match {
case _: Stream[_] => 1 // no warning
case _: IsStream => 2 // type erasure warning
case _ => 3
}
두 번째 예제는 스칼라 버그입니까? – Heptic
@Heptic : 죄송합니다. 간과 했음에 틀림 없습니다. 나는 내 대답을 편집했다. – sschaef