extension_type_implements_representation_not_supertype
'{0}', the representation type of '{1}', is not a supertype of '{2}', the representation type of '{3}'.
Description
#The analyzer produces this diagnostic when an extension type implements another extension type, and the representation type of the implemented extension type isn't a subtype of the representation type of the implementing extension type.
Example
#The following code produces this diagnostic because the extension type B
implements A
, but the representation type of A
(num
) isn't a
subtype of the representation type of B
(String
):
extension type A(num i) {}
extension type B(String s) implements A {}
Common fixes
#Either change the representation types of the two extension types so that the representation type of the implemented type is a supertype of the representation type of the implementing type:
extension type A(num i) {}
extension type B(int n) implements A {}
Or remove the implemented type from the implements clause:
extension type A(num i) {}
extension type B(String s) {}
除非另有说明,文档之所提及适用于 Dart 3.7.3 版本,本页面最后更新时间: 2025-05-08。 查看文档源码 或者 报告页面问题。