supertype_expands_to_type_parameter
A type alias that expands to a type parameter can't be implemented.
A type alias that expands to a type parameter can't be mixed in.
A type alias that expands to a type parameter can't be used as a superclass constraint.
A type alias that expands to a type parameter can't be used as a superclass.
Description
#The analyzer produces this diagnostic when a type alias that expands to a type parameter is used in an extends
, implements
, with
, or on
clause.
Example
#The following code produces this diagnostic because the type alias T
, which expands to the type parameter S
, is used in the extends
clause of the class C
:
typedef T<S> = S;
class C extends T<Object> {}
Common fixes
#Use the value of the type argument directly:
typedef T<S> = S;
class C extends Object {}
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.