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

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

Issue 2145273002: fix propagated type of lambdas in strong mode (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 5 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/static_type_analyzer.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/generated/resolver.dart
diff --git a/pkg/analyzer/lib/src/generated/resolver.dart b/pkg/analyzer/lib/src/generated/resolver.dart
index 6ecb610d825e1b4468018398649e6b2fee0b0189..debb318e03aa2331741a464c2b277bd6d4c05678 100644
--- a/pkg/analyzer/lib/src/generated/resolver.dart
+++ b/pkg/analyzer/lib/src/generated/resolver.dart
@@ -5658,6 +5658,11 @@ class ResolverVisitor extends ScopedVisitor {
FunctionBody _currentFunctionBody;
/**
+ * Are we running in strong mode or not.
+ */
+ bool strongMode;
+
+ /**
* Initialize a newly created visitor to resolve the nodes in an AST node.
*
* The [definingLibrary] is the element for the library containing the node
@@ -5679,10 +5684,11 @@ class ResolverVisitor extends ScopedVisitor {
{Scope nameScope})
: super(definingLibrary, source, typeProvider, errorListener,
nameScope: nameScope) {
+ AnalysisOptions options = definingLibrary.context.analysisOptions;
+ this.strongMode = options.strongMode;
this.elementResolver = new ElementResolver(this);
this.typeSystem = definingLibrary.context.typeSystem;
bool strongModeHints = false;
- AnalysisOptions options = definingLibrary.context.analysisOptions;
if (options is AnalysisOptionsImpl) {
strongModeHints = options.strongModeHints;
}
@@ -6621,7 +6627,6 @@ class ResolverVisitor extends ScopedVisitor {
Object visitFunctionExpressionInvocation(FunctionExpressionInvocation node) {
node.function?.accept(this);
node.accept(elementResolver);
- _inferFunctionExpressionsParametersTypes(node.argumentList);
_inferArgumentTypesFromContext(node);
node.argumentList?.accept(this);
node.accept(typeAnalyzer);
@@ -6848,7 +6853,6 @@ class ResolverVisitor extends ScopedVisitor {
node.target?.accept(this);
node.typeArguments?.accept(this);
node.accept(elementResolver);
- _inferFunctionExpressionsParametersTypes(node.argumentList);
_inferArgumentTypesFromContext(node);
node.argumentList?.accept(this);
node.accept(typeAnalyzer);
@@ -7211,6 +7215,12 @@ class ResolverVisitor extends ScopedVisitor {
}
void _inferArgumentTypesFromContext(InvocationExpression node) {
+ if (!strongMode) {
+ // Use propagated type inference for lambdas if not in strong mode.
+ _inferFunctionExpressionsParametersTypes(node.argumentList);
+ return;
+ }
+
DartType contextType = node.staticInvokeType;
if (contextType is FunctionType) {
DartType originalType = node.function.staticType;
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/generated/static_type_analyzer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698