extension_type_representation_depends_on_itself
The extension type representation can't depend on itself.
Description
#The analyzer produces this diagnostic when an extension type has a representation type that depends on the extension type itself, either directly or indirectly.
Example
#The following code produces this diagnostic because the representation type of the extension type A
depends on A
directly:
extension type A(A a) {}
The following two code examples produce this diagnostic because the representation type of the extension type A
depends on A
indirectly through the extension type B
:
extension type A(B b) {}
extension type B(A a) {}
extension type A(List<B> b) {}
extension type B(List<A> a) {}
Common fixes
#Remove the dependency by choosing a different representation type for at least one of the types in the cycle:
extension type A(String s) {}
Unless stated otherwise, the documentation on this site reflects Dart 3.7.3. Page last updated on 2025-05-08. View source or report an issue.