E224: Override Class — 클래스·트레이트에 override를 쓰는 건 이제 deprecated 예요
E224: Override Class — 클래스·트레이트에 override를 쓰는 건 이제 deprecated 예요
클래스나 트레이트 정의에 override 수식어를 쓰면 이 deprecation 경고가 발생해요. 클래스나 트레이트에 override를 직접 써서 타입 멤버를 오버라이드하는 방식은 이제 권장되지 않아요. 대신 클래스를 따로 정의하고, 타입 멤버를 그 새 클래스를 가리키는 타입 별칭으로 오버라이드해야 합니다.
본문
Example
trait Base:
type T
object Impl extends Base:
override class T
Warning
-- [E224] Syntax Deprecation Warning: example.scala:5:17 -----------------------
5 | override class T
| ^
| `override` modifier is deprecated for classes and traits
|-----------------------------------------------------------------------------
| Explanation (enabled by `-explain`)
|- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| Instead of overriding a type alias with a class type, use an alias of the class.
| For example, instead of `override class C`, use `override type C = CImpl; class CImpl`.
-----------------------------------------------------------------------------
Solution
클래스를 따로 정의하고 타입 별칭으로 오버라이드하세요.
trait Base:
type T
object Impl extends Base:
class TImpl
override type T = TImpl