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

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

Issue 1179343004: Refactor least upper bound computation; support bottom correctly. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 6 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
Index: pkg/analyzer/lib/src/generated/constant.dart
diff --git a/pkg/analyzer/lib/src/generated/constant.dart b/pkg/analyzer/lib/src/generated/constant.dart
index 15491e37d63bfdbb7b9ba61377aa7fcb30b203de..572caab8e0fff2200e8ff794b35ed9de9155d7d0 100644
--- a/pkg/analyzer/lib/src/generated/constant.dart
+++ b/pkg/analyzer/lib/src/generated/constant.dart
@@ -18,7 +18,7 @@ import 'element.dart';
import 'engine.dart' show AnalysisEngine, RecordingErrorListener;
import 'error.dart';
import 'java_core.dart';
-import 'resolver.dart' show TypeProvider;
+import 'resolver.dart' show TypeProvider, TypeSystem, TypeSystemImpl;
import 'scanner.dart' show Token, TokenType;
import 'source.dart' show Source;
import 'utilities_collection.dart';
@@ -217,9 +217,10 @@ class ConstantEvaluationEngine {
"^(?:${ConstantValueComputer._OPERATOR_RE}\$|$_PUBLIC_IDENTIFIER_RE(?:=?\$|[.](?!\$)))+?\$");
/**
- * The type provider used to access the known types.
+ * The type system. This is used to gues the types of constants when their
Brian Wilkerson 2015/06/16 21:35:19 "gues" --> "guess"
+ * exact value is unknown.
*/
- final TypeProvider typeProvider;
+ final TypeSystem typeSystem;
/**
* The set of variables declared on the command line using '-D'.
@@ -239,11 +240,17 @@ class ConstantEvaluationEngine {
* given, is used to verify correct dependency analysis when running unit
* tests.
*/
- ConstantEvaluationEngine(this.typeProvider, this._declaredVariables,
+ ConstantEvaluationEngine(TypeProvider typeProvider, this._declaredVariables,
{ConstantEvaluationValidator validator})
: validator = validator != null
? validator
- : new ConstantEvaluationValidator_ForProduction();
+ : new ConstantEvaluationValidator_ForProduction(),
+ typeSystem = new TypeSystemImpl(typeProvider);
+
+ /**
+ * The type provider used to access the known types.
+ */
+ TypeProvider get typeProvider => typeSystem.typeProvider;
/**
* Check that the arguments to a call to fromEnvironment() are correct. The
@@ -1431,6 +1438,11 @@ class ConstantVisitor extends UnifyingAstVisitor<DartObjectImpl> {
*/
TypeProvider get _typeProvider => evaluationEngine.typeProvider;
+ /**
+ * Convenience getter to gain access to the [evaluationEngine]'s type system.
+ */
+ TypeSystem get _typeSystem => evaluationEngine.typeSystem;
+
@override
DartObjectImpl visitAdjacentStrings(AdjacentStrings node) {
DartObjectImpl result = null;
@@ -1543,7 +1555,7 @@ class ConstantVisitor extends UnifyingAstVisitor<DartObjectImpl> {
ParameterizedType thenType = thenResult.type;
ParameterizedType elseType = elseResult.type;
return new DartObjectImpl.validWithUnknownValue(
- thenType.getLeastUpperBound(elseType) as InterfaceType);
+ _typeSystem.getLeastUpperBound(thenType, elseType) as InterfaceType);
}
@override
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/generated/element.dart » ('j') | pkg/analyzer/lib/src/generated/resolver.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698