-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
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.
typedef int F(int i);
void foo(F x) {
bar(x);
}
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 signature void bar(F<int> x)
; under the current kernel design, it would have no way of preserving the type argument int
, even with heuristics:
typedef void F<T>();
void foo(F<int> x) {
bar(x);
}