You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
classCimplementsA<int> { }
T.BsomeFunction<TextendsA<num>>() { ... }
// `T` doesn't actually appear in the signature so it cannot be inferred.final returnValue =someFunction<C>()
However currently one has to specify both type parameters, which makes calling the someFunction API a bit clumsy:
// `B` is used as the return type but otherwise redundant. BsomeFunction<TextendsA<B>, Bextendsnum>() { ... }
final returnValue =someFunction<C, int>();
// It gets worse when `A` has more than one type parameters, with long class names:final returnValue' = someFunction'<C, SophisticatedClassName1, SophisticatedClassName2>();
Proposal
Exposing the names of generic classes' type parameters, maybe as associated types:
I'd suggest using type patterns (#170), preferably with a more actual-pattern-like syntax, to extract the type parameter of a generic type.
R someFunction<TextendsA<final R>>() { ... }
It can use either the runtime type of the type T, and extract R on every runtime invocation, or use the static type of a single invocation point extracted (inferred) at compile-time (I'd prefer the former, that's what's currently impossible to do otherwise.)
I think this might just be a duplicate of #170, with slightly different syntax.
I have the following interface:
I would like to be able to write:
However currently one has to specify both type parameters, which makes calling the
someFunction
API a bit clumsy:Proposal
Exposing the names of generic classes' type parameters, maybe as associated types:
The text was updated successfully, but these errors were encountered: