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

Unified Diff: editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/verifier/ErrorVerifier.java

Issue 18110007: Report CTEC.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS for 'const' instance creation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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: editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/verifier/ErrorVerifier.java
diff --git a/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/verifier/ErrorVerifier.java b/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/verifier/ErrorVerifier.java
index a9e6de9b79957a2c59d2bc0aadb2ad131506d582..8c42f45ba792bdd5a8467de0a012eb927488400f 100644
--- a/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/verifier/ErrorVerifier.java
+++ b/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/verifier/ErrorVerifier.java
@@ -4018,11 +4018,17 @@ public class ErrorVerifier extends RecursiveASTVisitor<Void> {
Type boundType = boundingElts[i].getBound();
if (argType != null && boundType != null) {
if (!argType.isSubtypeOf(boundType)) {
+ ErrorCode errorCode;
+ if (isInConstConstructorInvocation(node)) {
+ errorCode = CompileTimeErrorCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS;
+ } else {
+ errorCode = StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS;
+ }
errorReporter.reportError(
- StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS,
+ errorCode,
argTypeName,
argTypeName.getName(),
- boundingElts[i].getBound().getDisplayName());
+ boundType.getDisplayName());
foundError = true;
}
}
@@ -4295,6 +4301,18 @@ public class ErrorVerifier extends RecursiveASTVisitor<Void> {
}
/**
+ * @return {@code true} if the given {@link ASTNode} is the part of constant constructor
+ * invocation.
+ */
+ private boolean isInConstConstructorInvocation(ASTNode node) {
+ InstanceCreationExpression creation = node.getAncestor(InstanceCreationExpression.class);
+ if (creation == null) {
+ return false;
+ }
+ return creation.isConst();
+ }
+
+ /**
* @param node the 'this' expression to analyze
* @return {@code true} if the given 'this' expression is in the valid context
*/

Powered by Google App Engine
This is Rietveld 408576698