| Index: pkg/analyzer/lib/src/generated/static_type_analyzer.dart
|
| diff --git a/pkg/analyzer/lib/src/generated/static_type_analyzer.dart b/pkg/analyzer/lib/src/generated/static_type_analyzer.dart
|
| index aacdabeb17e27fa726dd9f2fb795b7089e44a727..fa2bf1c4027e2e106f94caff586670f73d5e0ead 100644
|
| --- a/pkg/analyzer/lib/src/generated/static_type_analyzer.dart
|
| +++ b/pkg/analyzer/lib/src/generated/static_type_analyzer.dart
|
| @@ -1015,6 +1015,10 @@ class StaticTypeAnalyzer extends SimpleAstVisitor<Object> {
|
| } else if (staticElement is VariableElement) {
|
| staticType = staticElement.type;
|
| }
|
| + if (_strongMode) {
|
| + staticType = _inferGenericInstantiationFromContext(
|
| + InferenceContext.getType(node), staticType);
|
| + }
|
| if (!(_strongMode &&
|
| _inferObjectAccess(node, staticType, prefixedIdentifier))) {
|
| _recordStaticType(prefixedIdentifier, staticType);
|
| @@ -1144,6 +1148,10 @@ class StaticTypeAnalyzer extends SimpleAstVisitor<Object> {
|
| } else {
|
| // TODO(brianwilkerson) Report this internal error.
|
| }
|
| + if (_strongMode) {
|
| + staticType = _inferGenericInstantiationFromContext(
|
| + InferenceContext.getType(node), staticType);
|
| + }
|
| if (!(_strongMode && _inferObjectAccess(node, staticType, propertyName))) {
|
| _recordStaticType(propertyName, staticType);
|
| _recordStaticType(node, staticType);
|
| @@ -1244,6 +1252,10 @@ class StaticTypeAnalyzer extends SimpleAstVisitor<Object> {
|
| } else {
|
| staticType = _dynamicType;
|
| }
|
| + if (_strongMode) {
|
| + staticType = _inferGenericInstantiationFromContext(
|
| + InferenceContext.getType(node), staticType);
|
| + }
|
| _recordStaticType(node, staticType);
|
| // TODO(brianwilkerson) I think we want to repeat the logic above using the
|
| // propagated element to get another candidate for the propagated type.
|
| @@ -1883,6 +1895,21 @@ class StaticTypeAnalyzer extends SimpleAstVisitor<Object> {
|
| }
|
|
|
| /**
|
| + * Given an uninstantiated generic type, try to infer the instantiated generic
|
| + * type from the surrounding context.
|
| + */
|
| + DartType _inferGenericInstantiationFromContext(
|
| + DartType context, DartType type) {
|
| + TypeSystem ts = _typeSystem;
|
| + if (context is FunctionType &&
|
| + type is FunctionType &&
|
| + ts is StrongTypeSystemImpl) {
|
| + return ts.inferFunctionTypeInstantiation(_typeProvider, context, type);
|
| + }
|
| + return type;
|
| + }
|
| +
|
| + /**
|
| * Given a method invocation [node], attempt to infer a better
|
| * type for the result if it is an inline JS invocation
|
| */
|
|
|