Issue 7469. Report error if type appears in for extends and implements clauses

http://code.google.com/p/dart/issues/detail?id=7469

R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org//11612027

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@16282 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
scheglov@google.com
2012-12-18 19:49:12 +00:00
parent 338335ae1c
commit a3dcd4e8f8
4 changed files with 20 additions and 1 deletions
@@ -197,6 +197,7 @@ public enum ResolverErrorCode implements ErrorCode {
RETHROW_NOT_IN_CATCH("Re-throw not in a catch block"),
STATIC_FINAL_REQUIRES_VALUE("Static final fields must have an initial value"),
STATIC_METHOD_MUST_HAVE_BODY("Static method must have a body"),
SUPER_CLASS_IN_IMPLEMENTS("Superclass in implements clause"),
SUPER_IN_FACTORY_CONSTRUCTOR("Cannot use 'super' in a factory constructor"),
SUPER_IN_STATIC_METHOD("Cannot use 'super' in a static method"),
SUPER_OUTSIDE_OF_METHOD("Cannot use 'super' outside of a method"),
@@ -4,6 +4,7 @@
package com.google.dart.compiler.resolver;
import com.google.common.base.Objects;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets;
import com.google.dart.compiler.DartCompilerContext;
@@ -111,6 +112,10 @@ public class SupertypeResolver {
topLevelContext.onError(intNode, ResolverErrorCode.DUPLICATE_IMPLEMENTS_TYPE);
continue;
}
if (Objects.equal(intType, supertype)) {
topLevelContext.onError(intNode, ResolverErrorCode.SUPER_CLASS_IN_IMPLEMENTS);
continue;
}
seenImplement.add(intType);
}
// OK, add
@@ -5332,6 +5332,20 @@ public class TypeAnalyzerCompilerTest extends CompilerTestCase {
assertErrors(result.getErrors(), errEx(ResolverErrorCode.DUPLICATE_IMPLEMENTS_TYPE, 3, 23, 1));
}
/**
* It is a compile-time error if the superclass of a class C appears in the implements clause of C.
* <p>
* http://code.google.com/p/dart/issues/detail?id=7469
*/
public void test_superClass_imImplementsClause() throws Exception {
AnalyzeLibraryResult result = analyzeLibrary(
"// filler filler filler filler filler filler filler filler filler filler",
"class A {}",
"class B extends A implements A {}",
"");
assertErrors(result.getErrors(), errEx(ResolverErrorCode.SUPER_CLASS_IN_IMPLEMENTS, 3, 30, 1));
}
/**
* We should report only "no such type", but not duplicate.
* <p>
-1
View File
@@ -87,7 +87,6 @@ compile_time_constant_checked3_test/06: Fail, OK
default_factory2_test/01: Fail # Issue 7075.
[ $compiler == dartc ]
class_cycle_test/03: Fail # Issue 7469.
library_juxtaposition_test: Fail # Issue 6881
new_expression_type_args_test/0*: Fail # Wrongly reports compile-time error.
redirecting_factory_infinite_steps_test/01: Fail # http://dartbug.com/6560