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

Unified Diff: compiler/java/com/google/dart/compiler/resolver/Resolver.java

Issue 10540010: Issue 3264. Use field type is formal initializer has to declared type (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 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: compiler/java/com/google/dart/compiler/resolver/Resolver.java
diff --git a/compiler/java/com/google/dart/compiler/resolver/Resolver.java b/compiler/java/com/google/dart/compiler/resolver/Resolver.java
index 927fe99f103a19d6726b0f25f2f631fcace6b1f2..d02c69f88d06a122edc56bd5cb77ccc613e3f7ac 100644
--- a/compiler/java/com/google/dart/compiler/resolver/Resolver.java
+++ b/compiler/java/com/google/dart/compiler/resolver/Resolver.java
@@ -597,9 +597,7 @@ public class Resolver {
// scope of the default expressions so we can report better errors.
for (DartParameter parameter : parameters) {
assert parameter.getElement() != null;
- if (parameter.getQualifier() instanceof DartThisExpression) {
- checkParameterInitializer(node, parameter);
- } else {
+ if (!(parameter.getQualifier() instanceof DartThisExpression)) {
getContext().declare(
parameter.getElement(),
ResolverErrorCode.DUPLICATE_PARAMETER,
@@ -1786,43 +1784,6 @@ public class Resolver {
}
}
- private void checkParameterInitializer(DartMethodDefinition method, DartParameter parameter) {
- if (Elements.isNonFactoryConstructor(method.getElement())) {
- if (method.getModifiers().isRedirectedConstructor()) {
- onError(parameter.getName(),
- ResolverErrorCode.PARAMETER_INIT_WITH_REDIR_CONSTRUCTOR);
- }
-
- FieldElement element =
- Elements.lookupLocalField((ClassElement) currentHolder, parameter.getParameterName());
- if (element == null) {
- onError(parameter, ResolverErrorCode.PARAMETER_NOT_MATCH_FIELD,
- parameter.getName());
- } else if (element.isStatic()) {
- onError(parameter,
- ResolverErrorCode.PARAMETER_INIT_STATIC_FIELD,
- parameter.getName());
- }
-
- // Field parameters are not visible as parameters, so we do not declare them
- // in the context. Instead we record the resolved field element.
- Elements.setParameterInitializerElement(parameter.getElement(), element);
-
- // The editor expects the referenced elements to be non-null
- DartPropertyAccess prop = (DartPropertyAccess)parameter.getName();
- prop.setElement(element);
- prop.getName().setElement(element);
-
- // If no type specified, use type of field.
- if (parameter.getTypeNode() == null && element != null) {
- Elements.setType(parameter.getElement(), element.getType());
- }
- } else {
- onError(parameter.getName(),
- ResolverErrorCode.PARAMETER_INIT_OUTSIDE_CONSTRUCTOR);
- }
- }
-
private void resolveInitializers(DartMethodDefinition node, Set<FieldElement> intializedFields) {
Iterator<DartInitializer> initializers = node.getInitializers().iterator();
ConstructorElement constructorElement = null;

Powered by Google App Engine
This is Rietveld 408576698