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

Side by Side Diff: pkg/analyzer/lib/src/summary/link.dart

Issue 2777783003: Record variable names in type inference cycles. (Closed)
Patch Set: Created 3 years, 8 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 unified diff | Download patch
« no previous file with comments | « pkg/analyzer/lib/src/summary/idl.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /** 5 /**
6 * This library is capable of producing linked summaries from unlinked 6 * This library is capable of producing linked summaries from unlinked
7 * ones (or prelinked ones). It functions by building a miniature 7 * ones (or prelinked ones). It functions by building a miniature
8 * element model to represent the contents of the summaries, and then 8 * element model to represent the contents of the summaries, and then
9 * scanning the element model to gather linked information and adding 9 * scanning the element model to gather linked information and adding
10 * it to the summary data structures. 10 * it to the summary data structures.
(...skipping 4779 matching lines...) Expand 10 before | Expand all | Expand 10 after
4790 } 4790 }
4791 4791
4792 /** 4792 /**
4793 * Specialization of [DependencyWalker] for performing type inferrence 4793 * Specialization of [DependencyWalker] for performing type inferrence
4794 * on static and top level variables. 4794 * on static and top level variables.
4795 */ 4795 */
4796 class TypeInferenceDependencyWalker 4796 class TypeInferenceDependencyWalker
4797 extends DependencyWalker<TypeInferenceNode> { 4797 extends DependencyWalker<TypeInferenceNode> {
4798 @override 4798 @override
4799 void evaluate(TypeInferenceNode v) { 4799 void evaluate(TypeInferenceNode v) {
4800 v.evaluate(false); 4800 v.evaluate(null);
4801 } 4801 }
4802 4802
4803 @override 4803 @override
4804 void evaluateScc(List<TypeInferenceNode> scc) { 4804 void evaluateScc(List<TypeInferenceNode> scc) {
4805 for (TypeInferenceNode v in scc) { 4805 for (TypeInferenceNode v in scc) {
4806 v.evaluate(true); 4806 v.evaluate(scc);
4807 } 4807 }
4808 } 4808 }
4809 } 4809 }
4810 4810
4811 /** 4811 /**
4812 * Specialization of [Node] used to construct the type inference dependency 4812 * Specialization of [Node] used to construct the type inference dependency
4813 * graph. 4813 * graph.
4814 */ 4814 */
4815 class TypeInferenceNode extends Node<TypeInferenceNode> { 4815 class TypeInferenceNode extends Node<TypeInferenceNode> {
4816 /** 4816 /**
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
4915 } 4915 }
4916 4916
4917 @override 4917 @override
4918 List<TypeInferenceNode> computeDependencies() { 4918 List<TypeInferenceNode> computeDependencies() {
4919 List<TypeInferenceNode> dependencies = <TypeInferenceNode>[]; 4919 List<TypeInferenceNode> dependencies = <TypeInferenceNode>[];
4920 collectDependencies(dependencies, functionElement._unlinkedExecutable, 4920 collectDependencies(dependencies, functionElement._unlinkedExecutable,
4921 functionElement.compilationUnit); 4921 functionElement.compilationUnit);
4922 return dependencies; 4922 return dependencies;
4923 } 4923 }
4924 4924
4925 void evaluate(bool inCycle) { 4925 void evaluate(List<TypeInferenceNode> cycle) {
4926 if (inCycle) { 4926 if (cycle != null) {
4927 List<String> cycleNames = cycle
4928 .map((node) {
4929 Element e = node.functionElement;
4930 while (e != null) {
4931 if (e is VariableElement) {
4932 return e.name;
4933 }
4934 e = e.enclosingElement;
4935 }
4936 return '<unknown>';
4937 })
4938 .toSet()
4939 .toList();
4927 functionElement._setInferenceError(new TopLevelInferenceErrorBuilder( 4940 functionElement._setInferenceError(new TopLevelInferenceErrorBuilder(
4928 kind: TopLevelInferenceErrorKind.dependencyCycle)); 4941 kind: TopLevelInferenceErrorKind.dependencyCycle,
4942 arguments: cycleNames));
4929 functionElement._setInferredType(DynamicTypeImpl.instance); 4943 functionElement._setInferredType(DynamicTypeImpl.instance);
4930 } else { 4944 } else {
4931 var computer = new ExprTypeComputer(functionElement); 4945 var computer = new ExprTypeComputer(functionElement);
4932 DartType bodyType = computer.compute(); 4946 DartType bodyType = computer.compute();
4933 if (computer.errorKind != null) { 4947 if (computer.errorKind != null) {
4934 functionElement._setInferenceError( 4948 functionElement._setInferenceError(
4935 new TopLevelInferenceErrorBuilder(kind: computer.errorKind)); 4949 new TopLevelInferenceErrorBuilder(kind: computer.errorKind));
4936 functionElement._setInferredType(DynamicTypeImpl.instance); 4950 functionElement._setInferredType(DynamicTypeImpl.instance);
4937 } else { 4951 } else {
4938 if (functionElement.isAsynchronous) { 4952 if (functionElement.isAsynchronous) {
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
5280 } 5294 }
5281 5295
5282 /** 5296 /**
5283 * This exception is thrown when [ExprTypeComputer] cannot inference the type. 5297 * This exception is thrown when [ExprTypeComputer] cannot inference the type.
5284 */ 5298 */
5285 class _InferenceFailedError { 5299 class _InferenceFailedError {
5286 final String message; 5300 final String message;
5287 5301
5288 _InferenceFailedError(this.message); 5302 _InferenceFailedError(this.message);
5289 } 5303 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/summary/idl.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698