mixin_class_declaration_with_clause 진단: mixin class에 with 절을 쓸 수 없어요

mixin_class_declaration_with_clause 진단: mixin class에 with 절을 쓸 수 없어요

분석기가 내보내는 진단에는 이름이 있어요. mixin_class_declaration_with_clausemixin 한정자를 가진 클래스에 with 절이 있을 때 Dart 분석기가 알려주는 컴파일 타임 진단이에요. mixin class 선언은 with 절을 가질 수 없어요. with 절이 있으면 Object가 아닌 클래스를 extends 한다는 뜻이 되기 때문이에요.

출처: mixin_class_declaration_with_clause

본문

설명

분석기는 mixin 한정자를 가진 클래스에 with 절이 있으면 이 진단을 만들어요. mixin class 선언은 with 절을 가질 수 없는데, 그 이유는 with 절이 Object가 아닌 클래스를 extends 한다는 것을 의미하기 때문이에요.

예시

다음 코드는 mixin class Bwith 절이 있어서 이 진단이 나와요.

mixin M {}

mixin class B with M {}

흔한 해결 방법

클래스를 mixin으로 사용하고 싶다면, with 절을 제거해 줘요.

mixin M {}

mixin class B {}

클래스에 with 절이 꼭 필요하다면, mixin 한정자를 제거해 줘요.

mixin M {}

class B with M {}

더 알아보기