Reputation: 838
I have a class defined like this:
abstract class QuestionPageBaseState<T extends Question<dynamic, dynamic>> {...
The class Question
is defined like this:
abstract class Question<T, U> {...
is it possible to replace the dynamic
with a generic type like this?:
abstract class QuestionPageBaseState<T extends Question<U, V>> {...
When I try I get this error:
The name 'U' isn't a type so it can't be used as a type argument.
Upvotes: 1
Views: 1516
Reputation: 5638
You see the error because the compiler doesn't know where the generic type comes from and thinks it's a concrete class (such as int, double, String...); however, it's not.
You can achieve it specifying U
and V
as type parameters to QuestionPageBaseState
which will pass them to Question
:
abstract class QuestionPageBaseState<T extends Question<U, V>, U, V> {}
Upvotes: 3