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

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

Issue 10970024: Issue 5240. Using a non-type in a const object expression is an error, not a warning (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 3 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 c08537efd47942c06dc294dcf81db3dbd7ca6121..184fa9dffaad8e7d5de8746274835e6388cf4070 100644
--- a/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
+++ b/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
@@ -1383,6 +1383,44 @@ public class TypeAnalyzerCompilerTest extends CompilerTestCase {
errEx(ResolverErrorCode.NOT_A_TYPE, 3, 17, 1));
}
+ public void test_constInstanceCreation_noSuchType() throws Exception {
+ AnalyzeLibraryResult libraryResult = analyzeLibrary(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "main() {",
+ " const NoSuchType();",
+ "}",
+ "");
+ assertErrors(
+ libraryResult.getErrors(),
+ errEx(ResolverErrorCode.NO_SUCH_TYPE_CONST, 3, 9, 10));
+ }
+
+ public void test_constInstanceCreation_noSuchConstructor() throws Exception {
+ AnalyzeLibraryResult libraryResult = analyzeLibrary(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "class A {}",
+ "main() {",
+ " const A.noSuchName();",
+ "}",
+ "");
+ assertErrors(
+ libraryResult.getErrors(),
+ errEx(ResolverErrorCode.NEW_EXPRESSION_NOT_CONST_CONSTRUCTOR, 4, 11, 10));
+ }
+
+ public void test_constInstanceCreation_notType() throws Exception {
+ AnalyzeLibraryResult libraryResult = analyzeLibrary(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "var notType;",
+ "main() {",
+ " const notType();",
+ "}",
+ "");
+ assertErrors(
+ libraryResult.getErrors(),
+ errEx(ResolverErrorCode.NOT_A_TYPE, 4, 9, 7));
+ }
+
/**
* Test for variants of {@link DartMethodDefinition} return types.
*/
@@ -4417,10 +4455,10 @@ public class TypeAnalyzerCompilerTest extends CompilerTestCase {
"}"));
assertErrors(
libraryResult.getErrors(),
- errEx(ResolverErrorCode.NEW_EXPRESSION_NOT_CONSTRUCTOR, 5, 7, 19),
+ errEx(ResolverErrorCode.NEW_EXPRESSION_NOT_CONSTRUCTOR, 5, 9, 17),
errEx(TypeErrorCode.NO_SUCH_TYPE, 6, 7, 1),
errEx(TypeErrorCode.NO_SUCH_TYPE, 7, 7, 1),
- errEx(ResolverErrorCode.NEW_EXPRESSION_NOT_CONSTRUCTOR, 7, 7, 19));
+ errEx(ResolverErrorCode.NEW_EXPRESSION_NOT_CONSTRUCTOR, 7, 9, 17));
}
/**
« no previous file with comments | « compiler/javatests/com/google/dart/compiler/resolver/ResolverTest.java ('k') | tests/co19/co19-compiler.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698