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

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

Issue 2306223002: Move more error detection out of Scope (Closed)
Patch Set: clean-up Created 4 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 e11afca750969b9983ae28cbe22a334f633d1347..3ac1139db145fd32158307da7d3924ab496d392e 100644
--- a/pkg/analyzer/lib/src/generated/resolver.dart
+++ b/pkg/analyzer/lib/src/generated/resolver.dart
@@ -6608,7 +6608,7 @@ class ResolverVisitor extends ScopedVisitor {
var typeParamS =
futureThenType.returnType.flattenFutures(typeSystem);
returnType =
- FutureUnionType.from(typeParamS, typeProvider, typeSystem);
+ FutureUnionType.from(typeParamS, typeProvider, typeSystem);
} else {
returnType = _computeReturnOrYieldType(functionType.returnType);
}
@@ -7782,8 +7782,7 @@ abstract class ScopedVisitor extends UnifyingAstVisitor<Object> {
Object visitBlock(Block node) {
Scope outerScope = nameScope;
try {
- EnclosedScope enclosedScope = new EnclosedScope(nameScope);
- _hideNamesDefinedInBlock(enclosedScope, node);
+ EnclosedScope enclosedScope = new BlockScope(nameScope, node);
nameScope = enclosedScope;
super.visitBlock(node);
} finally {
@@ -8307,28 +8306,6 @@ abstract class ScopedVisitor extends UnifyingAstVisitor<Object> {
}
return outerScope;
}
-
- /**
- * Marks the local declarations of the given [Block] hidden in the enclosing scope.
- * According to the scoping rules name is hidden if block defines it, but name is defined after
- * its declaration statement.
- */
- void _hideNamesDefinedInBlock(EnclosedScope scope, Block block) {
- NodeList<Statement> statements = block.statements;
- int statementCount = statements.length;
- for (int i = 0; i < statementCount; i++) {
- Statement statement = statements[i];
- if (statement is VariableDeclarationStatement) {
- NodeList<VariableDeclaration> variables = statement.variables.variables;
- int variableCount = variables.length;
- for (int j = 0; j < variableCount; j++) {
- scope.hide(variables[j].element);
- }
- } else if (statement is FunctionDeclarationStatement) {
- scope.hide(statement.functionDeclaration.element);
- }
- }
- }
}
/**
@@ -8829,6 +8806,11 @@ class TypeNameResolver {
parent is WithClause ||
parent is ClassTypeAlias) {
// Ignored. The error will be reported elsewhere.
+ } else if (element is LocalVariableElement ||
+ (element is FunctionElement &&
+ element.enclosingElement is ExecutableElement)) {
+ reportErrorForNode(CompileTimeErrorCode.REFERENCED_BEFORE_DECLARATION,
+ typeName, [typeName.name]);
} else {
reportErrorForNode(
StaticWarningCode.NOT_A_TYPE, typeName, [typeName.name]);

Powered by Google App Engine
This is Rietveld 408576698