invalid_deprecated_extend_annotation 진단: 확장 가능한 클래스에만 쓸 수 있는 애너테이션
invalid_deprecated_extend_annotation 진단: 확장 가능한 클래스에만 쓸 수 있는 애너테이션
Dart 분석기가 내보내는 진단에는 이름이 있어요. invalid_deprecated_extend_annotation은 @Deprecated.extend 애너테이션을 확장(extend)할 수 없는 클래스가 아닌 선언에 붙였을 때 분석기가 알려주는 컴파일 타임 진단이에요. 이 애너테이션은 확장 가능한 클래스에만 쓸 수 있어요.
본문
설명
분석기는 @Deprecated.extend 애너테이션이 확장 가능한 클래스가 아닌 선언에 적용됐을 때 이 진단을 만들어요. 여기서 확장 가능한 클래스란 interface, final, sealed 키워드로 선언되지 않았고 public generative 생성자를 하나 이상 가진 클래스를 말해요.
예시
아래 코드는 sealed 클래스에 애너테이션을 붙였기 때문에 이 진단이 나와요. sealed 클래스는 더 이상 확장할 수 없으니까요.
@Deprecated.extend()
sealed class C {}
흔한 해결 방법
애너테이션을 제거하면 돼요.
sealed class C {}