-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Kernel representation of function types regresses angular code generation and analysis server quick fixes/refactorings #30961
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@jcollins-g is experiencing a similar issue with dartdoc. |
For dartdoc, this change makes all typedefs using the new syntax into anonymous typedefs. This breaks linkage in a way that's similar to the consequences described for Angular code generation -- dartdoc now no longer refers to the typedef by name but expands it out into its definition wherever it is referenced. |
Attempts to work around this for dartdoc via the analyzer are currently stymied by missing type information when reading references to typedefs. It's simply gone in |
Clarification, which I thought everybody knew already, but apparently not. There is |
|
@sjindel-google typedef void F<T>();
void foo(F<int> x) {
bar(x);
} Under the current implementation, the type of @scheglov do you think this is ok, or do you think we need to be able to generate |
Ah, I didn't know about |
It does indeed work:
I believe you are using it wrong. You need to remove the type parameter |
I don't know that generating |
@sjindel-google I don't see why I'm using it wrong. typedef T F<T>();
F<int> f; ...the type of No type parameters. |
Thank you, you're right, |
In the representation of function types used by the analyzer, it was possible to get information from a
FunctionType
about the typedef that created it. This is not possible with the current implementation of kernel.We are in the process of reworking the analyzer API to be more compatible with kernel, and we've noticed two consequences of this difference:
It makes code generated by the Angular package less readable. Sometimes Angular needs to create a class field with the same type as a constructor argument; if this type refers to a typedef, Angular creates a field whose type also refers to the typedef. Under the current kernel design, this will need to be changed so that Angular either (a) inserts its own typedef, (b) uses the new generalized function type syntax (e.g.
int Function(bool)
), or (c) uses heuristics to try to locate the original typedef at code generation time.It decreases the quality of code generated by the analysis server under the user's direction. For example, the following source code has a compile error due to the fact that
bar
is not defined. If the user asks the analysis server to fix the error by generating abar
function, it generates it with the signaturevoid bar(F x)
. It behaves similarly with refactorings such as extract method and extract variable. Under the current kernel design, this will need to be changed so that it either (a) generates a more verbose function signature likevoid bar(int x(int value))
, or (b) uses heuristics to try to locate the original typedef at code generation time.Note that a similar situation applies to the generic parameters of typedefs, e.g. in the following code, the analysis server currently can generate a
bar
function with the signaturevoid bar(F<int> x)
; under the current kernel design, it would have no way of preserving the type argumentint
, even with heuristics:The text was updated successfully, but these errors were encountered: