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

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

Issue 1355773002: Make type system changes backwards compatible (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 3 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/resolver.dart
diff --git a/pkg/analyzer/lib/src/generated/resolver.dart b/pkg/analyzer/lib/src/generated/resolver.dart
index 294a409b594e8dae74cdb68ab6970a367c16882c..f442583e3387228c6dc6f3886873eae7ccf079bf 100644
--- a/pkg/analyzer/lib/src/generated/resolver.dart
+++ b/pkg/analyzer/lib/src/generated/resolver.dart
@@ -82,9 +82,10 @@ class BestPracticesVerifier extends RecursiveAstVisitor<Object> {
*
* @param errorReporter the error reporter
*/
- BestPracticesVerifier(
- this._errorReporter, TypeProvider typeProvider, this._typeSystem)
- : _futureNullType = typeProvider.futureNullType;
+ BestPracticesVerifier(this._errorReporter, TypeProvider typeProvider,
+ {TypeSystem typeSystem})
+ : _futureNullType = typeProvider.futureNullType,
+ _typeSystem = (typeSystem != null) ? typeSystem : new TypeSystemImpl();
@override
Object visitArgumentList(ArgumentList node) {
@@ -848,7 +849,7 @@ class ConstantVerifier extends RecursiveAstVisitor<Object> {
/**
* The type system in use.
*/
- final TypeSystem _typeSystem;
+ TypeSystem _typeSystem;
/**
* The set of variables declared using '-D' on the command line.
@@ -886,11 +887,12 @@ class ConstantVerifier extends RecursiveAstVisitor<Object> {
* @param errorReporter the error reporter by which errors will be reported
*/
ConstantVerifier(this._errorReporter, this._currentLibrary,
- this._typeProvider, this._typeSystem, this.declaredVariables) {
+ this._typeProvider, this.declaredVariables) {
Paul Berry 2015/09/18 05:19:25 Nit: how about this instead: ConstantVerifier(thi
Leaf 2015/09/18 16:59:04 Done.
this._boolType = _typeProvider.boolType;
this._intType = _typeProvider.intType;
this._numType = _typeProvider.numType;
this._stringType = _typeProvider.stringType;
+ this._typeSystem = _currentLibrary.context.typeSystem;
}
@override
@@ -944,8 +946,8 @@ class ConstantVerifier extends RecursiveAstVisitor<Object> {
ConstructorElement constructor = node.staticElement;
if (constructor != null) {
ConstantEvaluationEngine evaluationEngine =
- new ConstantEvaluationEngine(
- _typeProvider, _typeSystem, declaredVariables);
+ new ConstantEvaluationEngine(_typeProvider, declaredVariables,
+ typeSystem: _typeSystem);
ConstantVisitor constantVisitor =
new ConstantVisitor(evaluationEngine, _errorReporter);
evaluationEngine.evaluateConstructorCall(
@@ -1019,8 +1021,8 @@ class ConstantVerifier extends RecursiveAstVisitor<Object> {
ErrorReporter subErrorReporter =
new ErrorReporter(errorListener, _errorReporter.source);
DartObjectImpl result = key.accept(new ConstantVisitor(
- new ConstantEvaluationEngine(
- _typeProvider, _typeSystem, declaredVariables),
+ new ConstantEvaluationEngine(_typeProvider, declaredVariables,
+ typeSystem: _typeSystem),
subErrorReporter));
if (result != null) {
if (keys.contains(result)) {
@@ -1226,8 +1228,8 @@ class ConstantVerifier extends RecursiveAstVisitor<Object> {
ErrorReporter subErrorReporter =
new ErrorReporter(errorListener, _errorReporter.source);
DartObjectImpl result = expression.accept(new ConstantVisitor(
- new ConstantEvaluationEngine(
- _typeProvider, _typeSystem, declaredVariables),
+ new ConstantEvaluationEngine(_typeProvider, declaredVariables,
+ typeSystem: _typeSystem),
subErrorReporter));
_reportErrors(errorListener.errors, errorCode);
return result;
@@ -1335,8 +1337,8 @@ class ConstantVerifier extends RecursiveAstVisitor<Object> {
ErrorReporter subErrorReporter =
new ErrorReporter(errorListener, _errorReporter.source);
DartObjectImpl result = initializer.accept(new ConstantVisitor(
- new ConstantEvaluationEngine(
- _typeProvider, _typeSystem, declaredVariables),
+ new ConstantEvaluationEngine(_typeProvider, declaredVariables,
+ typeSystem: _typeSystem),
subErrorReporter));
if (result == null) {
_errorReporter.reportErrorForNode(
@@ -1364,13 +1366,9 @@ class ConstantVerifier extends RecursiveAstVisitor<Object> {
ErrorReporter subErrorReporter =
new ErrorReporter(errorListener, _errorReporter.source);
DartObjectImpl result = expression.accept(
- new _ConstantVerifier_validateInitializerExpression(
- _typeProvider,
- _typeSystem,
- subErrorReporter,
- this,
- parameterElements,
- declaredVariables));
+ new _ConstantVerifier_validateInitializerExpression(_typeProvider,
+ subErrorReporter, this, parameterElements, declaredVariables,
+ typeSystem: _typeSystem));
_reportErrors(errorListener.errors,
CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER);
if (result != null) {
@@ -1504,7 +1502,9 @@ class DeadCodeVerifier extends RecursiveAstVisitor<Object> {
*
* @param errorReporter the error reporter
*/
- DeadCodeVerifier(this._errorReporter, this._typeSystem);
+ DeadCodeVerifier(this._errorReporter, {TypeSystem typeSystem})
+ : this._typeSystem =
+ (typeSystem != null) ? typeSystem : new TypeSystemImpl();
@override
Object visitBinaryExpression(BinaryExpression node) {
@@ -4824,15 +4824,16 @@ class HintGenerator {
ErrorReporter errorReporter = new ErrorReporter(_errorListener, source);
unit.accept(_usedImportedElementsVisitor);
// dead code analysis
- unit.accept(new DeadCodeVerifier(errorReporter, _context.typeSystem));
+ unit.accept(
+ new DeadCodeVerifier(errorReporter, typeSystem: _context.typeSystem));
unit.accept(_usedLocalElementsVisitor);
// dart2js analysis
if (_enableDart2JSHints) {
unit.accept(new Dart2JSVerifier(errorReporter));
}
// Dart best practices
- unit.accept(new BestPracticesVerifier(
- errorReporter, _context.typeProvider, _context.typeSystem));
+ unit.accept(new BestPracticesVerifier(errorReporter, _context.typeProvider,
+ typeSystem: _context.typeSystem));
unit.accept(new OverrideVerifier(errorReporter, _manager));
// Find to-do comments
new ToDoFinder(errorReporter).findIn(unit);
@@ -8327,8 +8328,9 @@ class LibraryResolver {
ConstantValueComputer computer = new ConstantValueComputer(
analysisContext,
_typeProvider,
- _typeSystem,
- analysisContext.declaredVariables);
+ analysisContext.declaredVariables,
+ null,
+ _typeSystem);
for (Library library in _librariesInCycles) {
for (Source source in library.compilationUnitSources) {
try {
@@ -8356,7 +8358,6 @@ class LibraryResolver {
errorReporter,
library.libraryElement,
_typeProvider,
- _typeSystem,
analysisContext.declaredVariables);
unit.accept(constantVerifier);
} on AnalysisException catch (exception, stackTrace) {
@@ -8389,7 +8390,7 @@ class LibraryResolver {
ResolverVisitor visitor = visitorFactory != null
? visitorFactory(library, source, _typeProvider)
: new ResolverVisitor(library.libraryElement, source, _typeProvider,
- _typeSystem, library.errorListener,
+ library.errorListener,
nameScope: library.libraryScope,
inheritanceManager: library.inheritanceManager);
ast.accept(visitor);
@@ -8832,8 +8833,9 @@ class LibraryResolver2 {
ConstantValueComputer computer = new ConstantValueComputer(
analysisContext,
_typeProvider,
- _typeSystem,
- analysisContext.declaredVariables);
+ analysisContext.declaredVariables,
+ null,
+ _typeSystem);
for (ResolvableLibrary library in _librariesInCycle) {
for (ResolvableCompilationUnit unit
in library.resolvableCompilationUnits) {
@@ -8856,7 +8858,6 @@ class LibraryResolver2 {
errorReporter,
library.libraryElement,
_typeProvider,
- _typeSystem,
analysisContext.declaredVariables);
ast.accept(constantVerifier);
}
@@ -8892,12 +8893,8 @@ class LibraryResolver2 {
ast.accept(new VariableResolverVisitor(library.libraryElement, source,
_typeProvider, library.libraryScope.errorListener,
nameScope: library.libraryScope));
- ResolverVisitor visitor = new ResolverVisitor(
- library.libraryElement,
- source,
- _typeProvider,
- _typeSystem,
- library._libraryScope.errorListener,
+ ResolverVisitor visitor = new ResolverVisitor(library.libraryElement,
+ source, _typeProvider, library._libraryScope.errorListener,
nameScope: library._libraryScope,
inheritanceManager: library.inheritanceManager);
ast.accept(visitor);
@@ -9646,17 +9643,13 @@ class PartialResolverVisitor extends ResolverVisitor {
* create the type analyzer. If `null` or unspecified, a type analyzer of
* type [StaticTypeAnalyzer] will be created.
*/
- PartialResolverVisitor(
- LibraryElement definingLibrary,
- Source source,
- TypeProvider typeProvider,
- TypeSystem typeSystem,
- AnalysisErrorListener errorListener,
+ PartialResolverVisitor(LibraryElement definingLibrary, Source source,
+ TypeProvider typeProvider, AnalysisErrorListener errorListener,
{Scope nameScope,
InheritanceManager inheritanceManager,
StaticTypeAnalyzerFactory typeAnalyzerFactory})
: strongMode = definingLibrary.context.analysisOptions.strongMode,
- super(definingLibrary, source, typeProvider, typeSystem,
+ super(definingLibrary, source, typeProvider,
new DisablableErrorListener(errorListener));
@override
@@ -10288,6 +10281,11 @@ class ResolverVisitor extends ScopedVisitor {
*/
StaticTypeAnalyzer typeAnalyzer;
+ /*
+ * The type system in use during resolution.
+ */
+ TypeSystem typeSystem;
+
/**
* The class element representing the class containing the current node,
* or `null` if the current node is not contained in a class.
@@ -10355,12 +10353,8 @@ class ResolverVisitor extends ScopedVisitor {
* create the type analyzer. If `null` or unspecified, a type analyzer of
* type [StaticTypeAnalyzer] will be created.
*/
- ResolverVisitor(
- LibraryElement definingLibrary,
- Source source,
- TypeProvider typeProvider,
- TypeSystem typeSystem,
- AnalysisErrorListener errorListener,
+ ResolverVisitor(LibraryElement definingLibrary, Source source,
+ TypeProvider typeProvider, AnalysisErrorListener errorListener,
{Scope nameScope,
InheritanceManager inheritanceManager,
StaticTypeAnalyzerFactory typeAnalyzerFactory})
@@ -10372,8 +10366,9 @@ class ResolverVisitor extends ScopedVisitor {
this._inheritanceManager = inheritanceManager;
}
this.elementResolver = new ElementResolver(this);
+ this.typeSystem = definingLibrary.context.typeSystem;
if (typeAnalyzerFactory == null) {
- this.typeAnalyzer = new StaticTypeAnalyzer(this, typeSystem);
+ this.typeAnalyzer = new StaticTypeAnalyzer(this);
} else {
this.typeAnalyzer = typeAnalyzerFactory(this);
}
@@ -10389,11 +10384,11 @@ class ResolverVisitor extends ScopedVisitor {
* Deprecated. Please use unnamed constructor instead.
*/
@deprecated
- ResolverVisitor.con1(Library library, Source source,
- TypeProvider typeProvider, TypeSystem typeSystem,
+ ResolverVisitor.con1(
+ Library library, Source source, TypeProvider typeProvider,
{StaticTypeAnalyzerFactory typeAnalyzerFactory})
- : this(library.libraryElement, source, typeProvider, typeSystem,
- library.errorListener,
+ : this(
+ library.libraryElement, source, typeProvider, library.errorListener,
nameScope: library.libraryScope,
inheritanceManager: library.inheritanceManager,
typeAnalyzerFactory: typeAnalyzerFactory);
@@ -15799,15 +15794,15 @@ class _ConstantVerifier_validateInitializerExpression extends ConstantVisitor {
_ConstantVerifier_validateInitializerExpression(
TypeProvider typeProvider,
- TypeSystem typeSystem,
ErrorReporter errorReporter,
this.verifier,
this.parameterElements,
- DeclaredVariables declaredVariables)
- : _typeSystem = typeSystem,
+ DeclaredVariables declaredVariables,
+ {TypeSystem typeSystem})
+ : _typeSystem = (typeSystem != null) ? typeSystem : new TypeSystemImpl(),
super(
- new ConstantEvaluationEngine(
- typeProvider, typeSystem, declaredVariables),
+ new ConstantEvaluationEngine(typeProvider, declaredVariables,
+ typeSystem: typeSystem),
errorReporter);
@override
« no previous file with comments | « pkg/analyzer/lib/src/generated/incremental_resolver.dart ('k') | pkg/analyzer/lib/src/generated/static_type_analyzer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698