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

Unified Diff: compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java

Issue 10873088: Issue 3989. Show warning if constructor name is same as member name (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 4 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/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
diff --git a/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java b/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
index 1d912bbc2c73895df1498952bbde23bf0fba5950..41ae84be4da62875adb5d4bdab1aadf676c29054 100644
--- a/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
+++ b/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
@@ -4088,6 +4088,25 @@ public class TypeAnalyzerCompilerTest extends CompilerTestCase {
}.doTest(unit);
}
+ /**
+ * A constructor name always begins with the name of its immediately enclosing class, and may
+ * optionally be followed by a dot and an identifier id. It is a compile-time error if id is the
+ * name of a member declared in the immediately enclosing class.
+ * <p>
+ * http://code.google.com/p/dart/issues/detail?id=3989
+ */
+ public void test_constructorName_sameAsMemberName() throws Exception {
+ AnalyzeLibraryResult libraryResult = analyzeLibrary(makeCode(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "class A {",
+ " A.foo() {}",
+ " foo() {}",
+ "}"));
+ assertErrors(
+ libraryResult.getErrors(),
+ errEx(ResolverErrorCode.CONSTRUCTOR_WITH_NAME_OF_MEMBER, 3, 3, 5));
+ }
+
private static <T extends DartNode> T findNode(
AnalyzeLibraryResult libraryResult,
final Class<T> clazz,

Powered by Google App Engine
This is Rietveld 408576698