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
{{ message }}
This repository was archived by the owner on Jun 20, 2019. It is now read-only.
then the type parameters will be unresolved. In this case, we get the error that type T has no getter 'getter'.
It doesn't seem to result in many errors, because T knows its own bounds, but T is a private type to GenericComp and should not be used in an external template.
When we put the variable genericComp in scope with a type, we need to call something to the effect of typeSystem.instantiateToBounds(classElement.type) to get the proper type to use for that scoped variable.
The text was updated successfully, but these errors were encountered:
Not sure exactly what you mean. Do you mean you can't instantiate them with explicit parameters like #genericComp<int> or something like that?
I've see a few generic components in some internal shared libraries, and when they are used they act like so:
// best comparison to <generic-comp #genericComp></generic-comp>
GenericComp /* no specification */ genericComp = new GenericComp /* no specification */ ();
// best comparison to {{genericComp.getter.length}}
genericComp.getter.length;
In dart this would not report an error because gc.getter is resolved to be of type dynamic. In fact, T is a private type to GenericComp, it has no definition anywhere but inside the class definition of GenericComp.
We just need to match that behavior, of T never leaking outside the class definition, and instead using a sane type instead (like dynamic in this case and using bounds otherwise #91). instantiateToBounds is what the analyzer server uses for this kind of no-specification initialization.
We already match the dart typechecker's behavior when doing things like <generic-comp [genericInput]="x"></generic-comp>#84, but this case of using #ref got missed.
If you create a generic component
and you use it in a template, capturing it as a variable
then the type parameters will be unresolved. In this case, we get the error that
type T has no getter 'getter'
.It doesn't seem to result in many errors, because
T
knows its own bounds, butT
is a private type toGenericComp
and should not be used in an external template.When we put the variable
genericComp
in scope with a type, we need to call something to the effect oftypeSystem.instantiateToBounds(classElement.type)
to get the proper type to use for that scoped variable.The text was updated successfully, but these errors were encountered: