-
Notifications
You must be signed in to change notification settings - Fork 1.7k
ParameterElementImpls returned from GenericFunctionTypeElement's parameters method always return as equal to each other #30146
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
Tested with analyzer package 0.30.0. |
Similarly, this problem crops up in cases like: /// This class has a complicated type situation.
abstract class TypedFunctionsWithoutTypedefs {
void Function(T1, T2) getAFunctionReturningVoid<T1, T2>(
void callback(T1 argument1, T2 argument2));
} The return type winds up being documented as Function(T1, T1) due to dartdoc's object cache being subverted. These patterns are starting to be used in the SDK and elsewhere now so the impact of this bug is increasing. |
I believe this happens because they have no name. The I think TypeParameterElements have a similar problem when we make synthetic ones (for synthetic function types). In that case, they've got their name but they don't have an enclosing scope, so every synthetic type parameter with the same name will compare equal to every other one (two unrelated variables |
I think I've convinced myself that dropping caching for Parameter ModelElements is safe in dartdoc, so I will do that to work around this problem. |
I'm having to work around this in another way for dart-lang/dartdoc#1835. |
In the case where GenericFunctionTypeElement is being used in a new style generic function type declaration, e.g.:
the corresponding GenericFunctionTypeElement correctly generates three different parameter objects, one each for T, int, and bool.
However, each of them have the same hashCode and compare as equal to each other, which can confuse dartdoc's internal object cache. This results in all three looking like 'T'.
The text was updated successfully, but these errors were encountered: