38752cafd2
Adds a helper to use for lints and fixes for finding whether the AST node contains a dot shorthand that relies on a declared type (in the parent of that node). The algorithm of `hasDependentDotShorthand` looks at the following: 0. If the node is a dot shorthand, return true. 1. Check that the node is a generic function, a list/map/set literal or a generic function expression -- with no explicit type arguments provided. For method invocations: 2. Note which type parameters are used in the return type -- these are the type parameters that depend on type inference. 3. Check the parameters that have type parameters in the above set. 4. If the arguments to those parameters have dot shorthands (recursively checked), then return true. For list/set/maps: 2. Recurse with each key and value, checking if there's a dependent dot shorthand. For function expressions: 2. Check each return statement to see if there's a dependent dot shorthand. For constructor invocations: 2. Make sure there are no explicit type arguments given. 3. Check each argument with type parameters in its parameter to see if there's a dependent dot shorthand. Bug: https://github.com/dart-lang/sdk/issues/59835 Change-Id: Iaed5fbb2dc60ee7498c1bb995272da288e306b5e Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/440080 Commit-Queue: Kallen Tu <kallentu@google.com> Reviewed-by: Chloe Stefantsova <cstefantsova@google.com> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>