Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Unified Diff: pkg/analyzer/lib/src/generated/static_type_analyzer.dart

Issue 1644403005: fix #25619 - downward inference on generic function tear-offs (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/generated/type_system.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
*/
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/generated/type_system.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698