4
사례 클래스가 지원되지 않을 경우 해당 객체는 그렇지 않다는 것을 알게되었습니다.사례 클래스의 동반 객체를 사용 중지하는 방법은 무엇입니까?
scala> @deprecated case class A(x: Int)
warning: there was one deprecation warning; re-run with -deprecation for details
defined class A
scala> A(0)
res0: A = A(0)
scala> new A(0)
warning: there was one deprecation warning; re-run with -deprecation for details
res1: A = A(0)
내가 new A(0)
을 위해 그것을 얻을 그대로 A(0)
에 대한 경고를하고 싶습니다. 나는 companion 객체를 명시 적으로 정의하고 그것을 deprecate해야 하는가? 더 좋은 방법이 있습니까?
나는 이것을 시도했다 :'@deprecated ("foo", "") case class A (x : Int); @deprecated ("bar", "") 객체 A'이지만,'A (0)'을 호출해도 여전히 비추천 경고가 나오지 않습니다. – Kolmar