| Index: compiler/javatests/com/google/dart/compiler/resolver/ResolverTest.java
|
| diff --git a/compiler/javatests/com/google/dart/compiler/resolver/ResolverTest.java b/compiler/javatests/com/google/dart/compiler/resolver/ResolverTest.java
|
| index d95f17532a850f5721c9cabc040bcbfd4a9ba4a9..2c12a2bb65d0437769229c7018370343db3c1c5a 100644
|
| --- a/compiler/javatests/com/google/dart/compiler/resolver/ResolverTest.java
|
| +++ b/compiler/javatests/com/google/dart/compiler/resolver/ResolverTest.java
|
| @@ -1150,17 +1150,26 @@ public class ResolverTest extends ResolverTestCase {
|
| ResolverErrorCode.CANNOT_USE_TYPE);
|
| }
|
|
|
| + public void test_classUsedAsExpression() {
|
| + resolveAndTest(Joiner.on("\n").join(
|
| + "class Object {}",
|
| + "main() {",
|
| + " 0.25 - Object;",
|
| + "}"),
|
| + ResolverErrorCode.IS_A_CLASS);
|
| + }
|
| +
|
| public void test_typeVariableUsedAsExpression() {
|
| resolveAndTest(Joiner.on("\n").join(
|
| "class Object {}",
|
| "class A<B> {",
|
| + " var field = B;",
|
| " f() {",
|
| - " try {",
|
| - " 0.25 - B;",
|
| - " } catch(var e) {}",
|
| + " 0.25 - B;",
|
| " }",
|
| "}"),
|
| - ResolverErrorCode.TYPE_VARIABLE_NOT_ALLOWED_IN_IDENTIFIER);
|
| + ResolverErrorCode.TYPE_VARIABLE_NOT_ALLOWED_IN_IDENTIFIER,
|
| + ResolverErrorCode.TYPE_VARIABLE_NOT_ALLOWED_IN_IDENTIFIER);
|
| }
|
|
|
| public void test_shadowType_withVariable() throws Exception {
|
| @@ -1524,4 +1533,66 @@ public class ResolverTest extends ResolverTestCase {
|
| "}"),
|
| errEx(ResolverErrorCode.INSTANCE_METHOD_FROM_REDIRECT, 10, 21, 8));
|
| }
|
| +
|
| + public void test_unresolvedRedirectConstructor() throws Exception {
|
| + resolveAndTest(Joiner.on("\n").join(
|
| + "class Object {}",
|
| + "class A {",
|
| + " A() : this.named();",
|
| + "}"),
|
| + errEx(ResolverErrorCode.CANNOT_RESOLVE_CONSTRUCTOR, 3, 9, 12));
|
| + }
|
| +
|
| + public void test_unresolvedSuperConstructor() throws Exception {
|
| + resolveAndTest(Joiner.on("\n").join(
|
| + "class Object {}",
|
| + "class A {",
|
| + " A() : super.named() {}",
|
| + "}"),
|
| + errEx(ResolverErrorCode.CANNOT_RESOLVE_SUPER_CONSTRUCTOR, 3, 9, 13));
|
| + }
|
| +
|
| + public void test_unresolvedFieldInInitializer() throws Exception {
|
| + resolveAndTest(Joiner.on("\n").join(
|
| + "class Object {}",
|
| + "class A {",
|
| + " const A() : this.field = 1;",
|
| + "}"),
|
| + errEx(ResolverErrorCode.CANNOT_RESOLVE_FIELD, 3, 20, 5));
|
| + }
|
| +
|
| + public void test_illegalConstructorModifiers() throws Exception {
|
| + resolveAndTest(Joiner.on("\n").join(
|
| + "class Object {}",
|
| + "class A {",
|
| + " abstract A();",
|
| + " abstract A.named();",
|
| + "}",
|
| + "class B {",
|
| + " static B() {}",
|
| + " static B.named() {}",
|
| + "}"),
|
| + errEx(ResolverErrorCode.CONSTRUCTOR_CANNOT_BE_ABSTRACT, 3, 12, 1),
|
| + errEx(ResolverErrorCode.CONSTRUCTOR_CANNOT_BE_ABSTRACT, 4, 12, 7),
|
| + errEx(ResolverErrorCode.CONSTRUCTOR_CANNOT_BE_STATIC, 7, 10, 1),
|
| + errEx(ResolverErrorCode.CONSTRUCTOR_CANNOT_BE_STATIC, 8, 10, 7));
|
| + }
|
| +
|
| + public void test_illegalConstructorReturnType() throws Exception {
|
| + resolveAndTest(Joiner.on("\n").join(
|
| + "class Object {}",
|
| + "interface int {}",
|
| + "class A {",
|
| + " void A();",
|
| + " void A.named();",
|
| + "}",
|
| + "class B {",
|
| + " int B();",
|
| + " int B.named();",
|
| + "}"),
|
| + errEx(ResolverErrorCode.CONSTRUCTOR_CANNOT_HAVE_RETURN_TYPE, 4, 3, 4),
|
| + errEx(ResolverErrorCode.CONSTRUCTOR_CANNOT_HAVE_RETURN_TYPE, 5, 3, 4),
|
| + errEx(ResolverErrorCode.CONSTRUCTOR_CANNOT_HAVE_RETURN_TYPE, 8, 3, 3),
|
| + errEx(ResolverErrorCode.CONSTRUCTOR_CANNOT_HAVE_RETURN_TYPE, 9, 3, 3));
|
| + }
|
| }
|
|
|