-
Notifications
You must be signed in to change notification settings - Fork 228
Description
I was trying the new dot-shorthands feature.
My idea was to create an annotation and accept different types in a list (see dart-lang/test#2558 (comment) for more details). My final idea to avoid having to add typedefs everywhere I wanted a nullable type or structural type was to create a placeholder class that would accept one type parameter.
@annotation(types: [TypeHolder<int?>(), TypeHolder<void Function()>()])But this is a really big name, and I thought of using .new (or even creating a .t constructor for it). But that would not work for my case. Since then, I can't pass the type arguments; they must be added before the ..
This problem is also somewhat related to:
I'm proposing that for constructors in dot-shorthand access, since they can't have their own arguments, we allow passing the type arguments before the ( as all other invocations.
So the code above could become:
@annotation(types: [.t<int?>(), .t<void Function()>()])And yes, having the constraints on the list of types is good because this way we ensure the passed value can always have one (and only one) type argument.