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

Unified Diff: pkg/analyzer/lib/src/summary/link.dart

Issue 2015833004: Fix circularity detection for AST-based type inference in the presence of closures. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 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/test/src/summary/resynthesize_ast_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/summary/link.dart
diff --git a/pkg/analyzer/lib/src/summary/link.dart b/pkg/analyzer/lib/src/summary/link.dart
index 77c86f2ea8ffd383a94aad9ecd8ca2852eac736f..3ce9ce8cb01a8e32c88b782d6854e7ce678fe7fd 100644
--- a/pkg/analyzer/lib/src/summary/link.dart
+++ b/pkg/analyzer/lib/src/summary/link.dart
@@ -4330,21 +4330,33 @@ class TypeInferenceNode extends Node<TypeInferenceNode> {
bool get isEvaluated => variableElement._inferredType != null;
/**
- * Collect the type inference dependencies in [unlinkedConst] (which should be
- * interpreted relative to [compilationUnit]) and store them in
+ * Collect the type inference dependencies in [unlinkedExecutable] (which
+ * should be interpreted relative to [compilationUnit]) and store them in
* [dependencies].
*/
void collectDependencies(
List<TypeInferenceNode> dependencies,
- UnlinkedConst unlinkedConst,
+ UnlinkedExecutable unlinkedExecutable,
CompilationUnitElementForLink compilationUnit) {
+ UnlinkedConst unlinkedConst = unlinkedExecutable?.bodyExpr;
if (unlinkedConst == null) {
return;
}
int refPtr = 0;
+ int intPtr = 0;
for (UnlinkedConstOperation operation in unlinkedConst.operations) {
switch (operation) {
+ case UnlinkedConstOperation.pushInt:
+ intPtr++;
+ break;
+ case UnlinkedConstOperation.pushLongInt:
+ int numInts = unlinkedConst.ints[intPtr++];
+ intPtr += numInts;
+ break;
+ case UnlinkedConstOperation.concatenate:
+ intPtr++;
+ break;
case UnlinkedConstOperation.pushReference:
EntityRef ref = unlinkedConst.references[refPtr++];
// TODO(paulberry): cache these resolved references for
@@ -4355,12 +4367,21 @@ class TypeInferenceNode extends Node<TypeInferenceNode> {
dependencies.add(dependency);
}
break;
- case UnlinkedConstOperation.makeTypedList:
case UnlinkedConstOperation.invokeConstructor:
refPtr++;
+ intPtr += 2;
+ break;
+ case UnlinkedConstOperation.makeUntypedList:
+ case UnlinkedConstOperation.makeUntypedMap:
+ intPtr++;
+ break;
+ case UnlinkedConstOperation.makeTypedList:
+ refPtr++;
+ intPtr++;
break;
case UnlinkedConstOperation.makeTypedMap:
refPtr += 2;
+ intPtr++;
break;
case UnlinkedConstOperation.assignToRef:
// TODO(paulberry): if this reference refers to a variable, should it
@@ -4371,16 +4392,29 @@ class TypeInferenceNode extends Node<TypeInferenceNode> {
// TODO(paulberry): if this reference refers to a variable, should it
// be considered a type inference dependency?
refPtr++;
+ intPtr += 2;
+ break;
+ case UnlinkedConstOperation.invokeMethod:
+ intPtr += 2;
break;
case UnlinkedConstOperation.typeCast:
case UnlinkedConstOperation.typeCheck:
refPtr++;
break;
+ case UnlinkedConstOperation.pushLocalFunctionReference:
+ int popCount = unlinkedConst.ints[intPtr++];
+ assert(popCount == 0); // TODO(paulberry): handle the nonzero case.
+ collectDependencies(
+ dependencies,
+ unlinkedExecutable.localFunctions[unlinkedConst.ints[intPtr++]],
+ compilationUnit);
+ break;
default:
break;
}
}
assert(refPtr == unlinkedConst.references.length);
+ assert(intPtr == unlinkedConst.ints.length);
}
@override
@@ -4388,7 +4422,7 @@ class TypeInferenceNode extends Node<TypeInferenceNode> {
List<TypeInferenceNode> dependencies = <TypeInferenceNode>[];
collectDependencies(
dependencies,
- variableElement.unlinkedVariable.initializer?.bodyExpr,
+ variableElement.unlinkedVariable.initializer,
variableElement.compilationUnit);
return dependencies;
}
« no previous file with comments | « no previous file | pkg/analyzer/test/src/summary/resynthesize_ast_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698