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

Unified Diff: compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java

Issue 10543016: Issue 3183. Warning when overriding method with different default value (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/type/TypeAnalyzer.java
diff --git a/compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java b/compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java
index 719a9b20808cc5f957f8dbd84b0c1854d81e7b12..cbb566e5302129734ad2a1084405cebafcea786a 100644
--- a/compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java
+++ b/compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java
@@ -99,6 +99,7 @@ import com.google.dart.compiler.ast.DartVariableStatement;
import com.google.dart.compiler.ast.DartWhileStatement;
import com.google.dart.compiler.ast.Modifiers;
import com.google.dart.compiler.common.HasSourceInfo;
+import com.google.dart.compiler.common.SourceInfo;
import com.google.dart.compiler.parser.Token;
import com.google.dart.compiler.resolver.ClassElement;
import com.google.dart.compiler.resolver.ClassNodeElement;
@@ -117,6 +118,7 @@ import com.google.dart.compiler.resolver.ResolverErrorCode;
import com.google.dart.compiler.resolver.TypeErrorCode;
import com.google.dart.compiler.resolver.VariableElement;
import com.google.dart.compiler.type.InterfaceType.Member;
+import com.google.dart.compiler.util.apache.ObjectUtils;
import java.util.Arrays;
import java.util.Collection;
@@ -220,13 +222,17 @@ public class TypeAnalyzer implements DartCompilationPhase {
}
private void onError(HasSourceInfo node, ErrorCode errorCode, Object... arguments) {
- Source source = node.getSourceInfo().getSource();
+ onError(node.getSourceInfo(), errorCode, arguments);
+ }
+
+ private void onError(SourceInfo errorTarget, ErrorCode errorCode, Object... arguments) {
+ Source source = errorTarget.getSource();
if (suppressSdkWarnings && errorCode.getErrorSeverity() == ErrorSeverity.WARNING) {
if (source != null && SystemLibraryManager.isDartUri(source.getUri())) {
return;
}
}
- context.onError(new DartCompilationError(node, errorCode, arguments));
+ context.onError(new DartCompilationError(errorTarget, errorCode, arguments));
}
AssertionError internalError(HasSourceInfo node, String message, Object... arguments) {
@@ -2483,6 +2489,12 @@ public class TypeAnalyzer implements DartCompilationPhase {
if (namedIterator.hasNext()) {
VariableElement parameter = namedIterator.next();
if (Objects.equal(parameter.getName(), superParameter.getName())) {
+ if (!Objects.equal(ObjectUtils.toString(parameter.getDefaultValue()),
+ ObjectUtils.toString(superParameter.getDefaultValue()))) {
+ onError(parameter.getSourceInfo(),
+ TypeErrorCode.CANNOT_OVERRIDE_METHOD_DEFAULT_VALUE, method.getName(),
+ superParameter.getDefaultValue());
+ }
continue;
}
}

Powered by Google App Engine
This is Rietveld 408576698