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

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

Issue 2621433003: fixes #28236, generic methods should not cause warnings in Dart 1 (Closed)
Patch Set: test type annotation fix Created 3 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 | « pkg/analyzer/lib/src/dart/element/type.dart ('k') | pkg/analyzer/test/generated/resolver_test_case.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 63b7b54fe34602618633feaea85a58b5940a803c..2f1e1599d39d4612be6f1f3fed664e0c67927086 100644
--- a/pkg/analyzer/lib/src/generated/static_type_analyzer.dart
+++ b/pkg/analyzer/lib/src/generated/static_type_analyzer.dart
@@ -1073,10 +1073,8 @@ class StaticTypeAnalyzer extends SimpleAstVisitor<Object> {
} else if (staticElement is VariableElement) {
staticType = staticElement.type;
}
- if (_strongMode) {
- staticType = _inferGenericInstantiationFromContext(
- InferenceContext.getType(node), staticType);
- }
+ staticType = _inferGenericInstantiationFromContext(node, staticType);
+
if (!(_strongMode &&
_inferObjectAccess(node, staticType, prefixedIdentifier))) {
_recordStaticType(prefixedIdentifier, staticType);
@@ -1206,10 +1204,8 @@ class StaticTypeAnalyzer extends SimpleAstVisitor<Object> {
} else {
// TODO(brianwilkerson) Report this internal error.
}
- if (_strongMode) {
- staticType = _inferGenericInstantiationFromContext(
- InferenceContext.getType(node), staticType);
- }
+ staticType = _inferGenericInstantiationFromContext(node, staticType);
+
if (!(_strongMode && _inferObjectAccess(node, staticType, propertyName))) {
_recordStaticType(propertyName, staticType);
_recordStaticType(node, staticType);
@@ -1310,10 +1306,8 @@ class StaticTypeAnalyzer extends SimpleAstVisitor<Object> {
} else {
staticType = _dynamicType;
}
- if (_strongMode) {
- staticType = _inferGenericInstantiationFromContext(
- InferenceContext.getType(node), staticType);
- }
+ staticType = _inferGenericInstantiationFromContext(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.
@@ -1906,13 +1900,19 @@ class StaticTypeAnalyzer extends SimpleAstVisitor<Object> {
* Given an uninstantiated generic function type, try to infer the
* instantiated generic function 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(context, type);
+ DartType _inferGenericInstantiationFromContext(AstNode node, DartType type) {
+ if (_strongMode) {
+ TypeSystem ts = _typeSystem;
+ DartType context = InferenceContext.getType(node);
+ if (context is FunctionType &&
+ type is FunctionType &&
+ ts is StrongTypeSystemImpl) {
+ return ts.inferFunctionTypeInstantiation(context, type);
+ }
+ } else {
+ // In Dart 1 mode we want to implicitly instantiate generic functions to
+ // their bounds always, so we don't get a universal function type.
+ return _typeSystem.instantiateToBounds(type);
}
return type;
}
« no previous file with comments | « pkg/analyzer/lib/src/dart/element/type.dart ('k') | pkg/analyzer/test/generated/resolver_test_case.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698