| Index: editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/resolver/CompileTimeErrorCodeTest.java
|
| diff --git a/editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/resolver/CompileTimeErrorCodeTest.java b/editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/resolver/CompileTimeErrorCodeTest.java
|
| index df9f062bab61a64cf624bb7fd3c53fd4706b9834..1f6984e5dd546c6d57485b660621155757528b57 100644
|
| --- a/editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/resolver/CompileTimeErrorCodeTest.java
|
| +++ b/editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/resolver/CompileTimeErrorCodeTest.java
|
| @@ -30,450 +30,35 @@ public class CompileTimeErrorCodeTest extends ResolverTestCase {
|
| verify(source);
|
| }
|
|
|
| - public void fail_constDeferredClass() throws Exception {
|
| - addNamedSource("/lib1.dart", createSource(//
|
| - "library lib1;",
|
| - "class A {",
|
| - " const A();",
|
| - "}"));
|
| - Source source = addSource(createSource(//
|
| - "library root;",
|
| - "import 'lib1.dart' deferred as a;",
|
| - "main() {",
|
| - " const a.A();",
|
| - "}"));
|
| - resolve(source);
|
| - assertErrors(source, CompileTimeErrorCode.CONST_DEFERRED_CLASS);
|
| - verify(source);
|
| - }
|
| -
|
| - public void fail_constDeferredClass_namedConstructor() throws Exception {
|
| - addNamedSource("/lib1.dart", createSource(//
|
| - "library lib1;",
|
| - "class A {",
|
| - " const A.b();",
|
| - "}"));
|
| - Source source = addSource(createSource(//
|
| - "library root;",
|
| - "import 'lib1.dart' deferred as a;",
|
| - "main() {",
|
| - " const a.A.b();",
|
| - "}"));
|
| - resolve(source);
|
| - assertErrors(source, CompileTimeErrorCode.CONST_DEFERRED_CLASS);
|
| - verify(source);
|
| - }
|
| -
|
| - public void fail_constEvalThrowsException() throws Exception { // Not compile-time constant
|
| - Source source = addSource(createSource(//
|
| - "class C {",
|
| - " const C();",
|
| - "}",
|
| - "f() { return const C(); }"));
|
| - resolve(source);
|
| - assertErrors(source, CompileTimeErrorCode.CONST_CONSTRUCTOR_THROWS_EXCEPTION);
|
| - verify(source);
|
| - }
|
| -
|
| - public void fail_constInitializedWithNonConstValueFromDeferredClass() throws Exception {
|
| - addNamedSource("/lib1.dart", createSource(//
|
| - "library lib1;",
|
| - "const V = 1;"));
|
| - Source source = addSource(createSource(//
|
| - "library root;",
|
| - "import 'lib1.dart' deferred as a;",
|
| - "const B = a.V;"));
|
| - resolve(source);
|
| - assertErrors(
|
| - source,
|
| - CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE_FROM_DEFERRED_LIBRARY);
|
| - verify(source);
|
| - }
|
| -
|
| - public void fail_constInitializedWithNonConstValueFromDeferredClass_nested() throws Exception {
|
| - addNamedSource("/lib1.dart", createSource(//
|
| - "library lib1;",
|
| - "const V = 1;"));
|
| - Source source = addSource(createSource(//
|
| - "library root;",
|
| - "import 'lib1.dart' deferred as a;",
|
| - "const B = a.V + 1;"));
|
| - resolve(source);
|
| - assertErrors(
|
| - source,
|
| - CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE_FROM_DEFERRED_LIBRARY);
|
| - verify(source);
|
| - }
|
| -
|
| - public void fail_extendsDeferredClass() throws Exception {
|
| - addNamedSource("/lib1.dart", createSource(//
|
| - "library lib1;",
|
| - "class A {}"));
|
| - Source source = addSource(createSource(//
|
| - "library root;",
|
| - "import 'lib1.dart' deferred as a;",
|
| - "class B extends a.A {}"));
|
| - resolve(source);
|
| - assertErrors(source, CompileTimeErrorCode.EXTENDS_DEFERRED_CLASS);
|
| - verify(source);
|
| - }
|
| -
|
| - public void fail_extendsDeferredClass_classTypeAlias() throws Exception {
|
| - addNamedSource("/lib1.dart", createSource(//
|
| - "library lib1;",
|
| - "class A {}"));
|
| - Source source = addSource(createSource(//
|
| - "library root;",
|
| - "import 'lib1.dart' deferred as a;",
|
| - "class M {}",
|
| - "class C = a.A with M;"));
|
| - resolve(source);
|
| - assertErrors(source, CompileTimeErrorCode.EXTENDS_DEFERRED_CLASS);
|
| - verify(source);
|
| - }
|
| -
|
| - public void fail_implementsDeferredClass() throws Exception {
|
| - addNamedSource("/lib1.dart", createSource(//
|
| - "library lib1;",
|
| - "class A {}"));
|
| - Source source = addSource(createSource(//
|
| - "library root;",
|
| - "import 'lib1.dart' deferred as a;",
|
| - "class B implements a.A {}"));
|
| - resolve(source);
|
| - assertErrors(source, CompileTimeErrorCode.IMPLEMENTS_DEFERRED_CLASS);
|
| - verify(source);
|
| - }
|
| -
|
| - public void fail_implementsDeferredClass_classTypeAlias() throws Exception {
|
| - addNamedSource("/lib1.dart", createSource(//
|
| - "library lib1;",
|
| - "class A {}"));
|
| - Source source = addSource(createSource(//
|
| - "library root;",
|
| - "import 'lib1.dart' deferred as a;",
|
| - "class B {}",
|
| - "class M {}",
|
| - "class C = B with M implements a.A;"));
|
| - resolve(source);
|
| - assertErrors(source, CompileTimeErrorCode.IMPLEMENTS_DEFERRED_CLASS);
|
| - verify(source);
|
| - }
|
| -
|
| - public void fail_invalidAnnotationFromDeferredLibrary() throws Exception {
|
| - // See test_invalidAnnotation_notConstantVariable
|
| - addNamedSource("/lib1.dart", createSource(//
|
| - "library lib1;",
|
| - "class V { const V(); }",
|
| - "const v = const V();"));
|
| - Source source = addSource(createSource(//
|
| - "library root;",
|
| - "import 'lib1.dart' deferred as a;",
|
| - "@a.v main () {}"));
|
| - resolve(source);
|
| - assertErrors(source, CompileTimeErrorCode.INVALID_ANNOTATION_FROM_DEFERRED_LIBRARY);
|
| - verify(source);
|
| - }
|
| -
|
| - public void fail_invalidAnnotationFromDeferredLibrary_constructor() throws Exception {
|
| - // See test_invalidAnnotation_notConstantVariable
|
| - addNamedSource("/lib1.dart", createSource(//
|
| - "library lib1;",
|
| - "class C { const C(); }"));
|
| - Source source = addSource(createSource(//
|
| - "library root;",
|
| - "import 'lib1.dart' deferred as a;",
|
| - "@a.C() main () {}"));
|
| - resolve(source);
|
| - assertErrors(source, CompileTimeErrorCode.INVALID_ANNOTATION_FROM_DEFERRED_LIBRARY);
|
| - verify(source);
|
| - }
|
| -
|
| - public void fail_invalidAnnotationFromDeferredLibrary_namedConstructor() throws Exception {
|
| - // See test_invalidAnnotation_notConstantVariable
|
| - addNamedSource("/lib1.dart", createSource(//
|
| - "library lib1;",
|
| - "class C { const C.name(); }"));
|
| - Source source = addSource(createSource(//
|
| - "library root;",
|
| - "import 'lib1.dart' deferred as a;",
|
| - "@a.C.name() main () {}"));
|
| - resolve(source);
|
| - assertErrors(source, CompileTimeErrorCode.INVALID_ANNOTATION_FROM_DEFERRED_LIBRARY);
|
| - verify(source);
|
| - }
|
| -
|
| - public void fail_mixinDeclaresConstructor() throws Exception {
|
| - Source source = addSource(createSource(//
|
| - "class A {",
|
| - " A() {}",
|
| - "}",
|
| - "class B extends Object mixin A {}"));
|
| - resolve(source);
|
| - assertErrors(source, CompileTimeErrorCode.MIXIN_DECLARES_CONSTRUCTOR);
|
| - verify(source);
|
| - }
|
| -
|
| - public void fail_mixinDeferredClass() throws Exception {
|
| - addNamedSource("/lib1.dart", createSource(//
|
| - "library lib1;",
|
| - "class A {}"));
|
| - Source source = addSource(createSource(//
|
| - "library root;",
|
| - "import 'lib1.dart' deferred as a;",
|
| - "class B extends Object with a.A {}"));
|
| - resolve(source);
|
| - assertErrors(source, CompileTimeErrorCode.MIXIN_DEFERRED_CLASS);
|
| - verify(source);
|
| - }
|
| -
|
| - public void fail_mixinDeferredClass_classTypeAlias() throws Exception {
|
| - addNamedSource("/lib1.dart", createSource(//
|
| - "library lib1;",
|
| - "class A {}"));
|
| - Source source = addSource(createSource(//
|
| - "library root;",
|
| - "import 'lib1.dart' deferred as a;",
|
| - "class B {}",
|
| - "class C = B with a.A;"));
|
| - resolve(source);
|
| - assertErrors(source, CompileTimeErrorCode.MIXIN_DEFERRED_CLASS);
|
| - verify(source);
|
| - }
|
| -
|
| - public void fail_mixinOfNonClass() throws Exception {
|
| - // TODO(brianwilkerson) Compare with MIXIN_WITH_NON_CLASS_SUPERCLASS.
|
| - Source source = addSource(createSource(//
|
| - "var A;",
|
| - "class B extends Object mixin A {}"));
|
| - resolve(source);
|
| - assertErrors(source, CompileTimeErrorCode.MIXIN_OF_NON_CLASS);
|
| - verify(source);
|
| - }
|
| -
|
| - public void fail_nonConstantDefaultValueFromDeferredLibrary() throws Exception {
|
| - addNamedSource("/lib1.dart", createSource(//
|
| - "library lib1;",
|
| - "const V = 1;"));
|
| - Source source = addSource(createSource(//
|
| - "library root;",
|
| - "import 'lib1.dart' deferred as a;",
|
| - "f({x : a.V}) {}"));
|
| - resolve(source);
|
| - assertErrors(source, CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE_FROM_DEFERRED_LIBRARY);
|
| - verify(source);
|
| - }
|
| -
|
| - public void fail_nonConstantDefaultValueFromDeferredLibrary_nested() throws Exception {
|
| - addNamedSource("/lib1.dart", createSource(//
|
| - "library lib1;",
|
| - "const V = 1;"));
|
| - Source source = addSource(createSource(//
|
| - "library root;",
|
| - "import 'lib1.dart' deferred as a;",
|
| - "f({x : a.V + 1}) {}"));
|
| - resolve(source);
|
| - assertErrors(source, CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE_FROM_DEFERRED_LIBRARY);
|
| - verify(source);
|
| - }
|
| -
|
| - public void fail_nonConstCaseExpressionFromDeferredLibrary() throws Exception {
|
| - addNamedSource("/lib1.dart", createSource(//
|
| - "library lib1;",
|
| - "const int c = 1;"));
|
| - Source source = addSource(createSource(//
|
| - "library root;",
|
| - "import 'lib1.dart' deferred as a;",
|
| - "main (int p) {",
|
| - " switch (p) {",
|
| - " case a.c:",
|
| - " break;",
|
| - " }",
|
| - "}"));
|
| - resolve(source);
|
| - assertErrors(source, CompileTimeErrorCode.NON_CONSTANT_CASE_EXPRESSION_FROM_DEFERRED_LIBRARY);
|
| - verify(source);
|
| - }
|
| -
|
| - public void fail_nonConstCaseExpressionFromDeferredLibrary_nested() throws Exception {
|
| - addNamedSource("/lib1.dart", createSource(//
|
| - "library lib1;",
|
| - "const int c = 1;"));
|
| - Source source = addSource(createSource(//
|
| - "library root;",
|
| - "import 'lib1.dart' deferred as a;",
|
| - "main (int p) {",
|
| - " switch (p) {",
|
| - " case a.c + 1:",
|
| - " break;",
|
| - " }",
|
| - "}"));
|
| - resolve(source);
|
| - assertErrors(source, CompileTimeErrorCode.NON_CONSTANT_CASE_EXPRESSION_FROM_DEFERRED_LIBRARY);
|
| - verify(source);
|
| - }
|
| -
|
| - public void fail_nonConstListElementFromDeferredLibrary() throws Exception {
|
| - addNamedSource("/lib1.dart", createSource(//
|
| - "library lib1;",
|
| - "const int c = 1;"));
|
| - Source source = addSource(createSource(//
|
| - "library root;",
|
| - "import 'lib1.dart' deferred as a;",
|
| - "f() {",
|
| - " return const [a.c];",
|
| - "}"));
|
| - resolve(source);
|
| - assertErrors(source, CompileTimeErrorCode.NON_CONSTANT_LIST_ELEMENT_FROM_DEFERRED_LIBRARY);
|
| - verify(source);
|
| - }
|
| -
|
| - public void fail_nonConstListElementFromDeferredLibrary_nested() throws Exception {
|
| - addNamedSource("/lib1.dart", createSource(//
|
| - "library lib1;",
|
| - "const int c = 1;"));
|
| - Source source = addSource(createSource(//
|
| - "library root;",
|
| - "import 'lib1.dart' deferred as a;",
|
| - "f() {",
|
| - " return const [a.c + 1];",
|
| - "}"));
|
| - resolve(source);
|
| - assertErrors(source, CompileTimeErrorCode.NON_CONSTANT_LIST_ELEMENT_FROM_DEFERRED_LIBRARY);
|
| - verify(source);
|
| - }
|
| -
|
| - public void fail_nonConstMapKeyFromDeferredLibrary() throws Exception {
|
| - addNamedSource("/lib1.dart", createSource(//
|
| - "library lib1;",
|
| - "const int c = 1;"));
|
| - Source source = addSource(createSource(//
|
| - "library root;",
|
| - "import 'lib1.dart' deferred as a;",
|
| - "f() {",
|
| - " return const {a.c : 0};",
|
| - "}"));
|
| - resolve(source);
|
| - assertErrors(source, CompileTimeErrorCode.NON_CONSTANT_MAP_KEY_FROM_DEFERRED_LIBRARY);
|
| - verify(source);
|
| - }
|
| -
|
| - public void fail_nonConstMapKeyFromDeferredLibrary_nested() throws Exception {
|
| - addNamedSource("/lib1.dart", createSource(//
|
| - "library lib1;",
|
| - "const int c = 1;"));
|
| - Source source = addSource(createSource(//
|
| - "library root;",
|
| - "import 'lib1.dart' deferred as a;",
|
| - "f() {",
|
| - " return const {a.c + 1 : 0};",
|
| - "}"));
|
| - resolve(source);
|
| - assertErrors(source, CompileTimeErrorCode.NON_CONSTANT_MAP_KEY_FROM_DEFERRED_LIBRARY);
|
| - verify(source);
|
| - }
|
| -
|
| - public void fail_nonConstMapValueFromDeferredLibrary() throws Exception {
|
| - addNamedSource("/lib1.dart", createSource(//
|
| - "library lib1;",
|
| - "const int c = 1;"));
|
| - Source source = addSource(createSource(//
|
| - "library root;",
|
| - "import 'lib1.dart' deferred as a;",
|
| - "f() {",
|
| - " return const {'a' : a.c};",
|
| - "}"));
|
| - resolve(source);
|
| - assertErrors(source, CompileTimeErrorCode.NON_CONSTANT_MAP_VALUE_FROM_DEFERRED_LIBRARY);
|
| - verify(source);
|
| - }
|
| -
|
| - public void fail_nonConstMapValueFromDeferredLibrary_nested() throws Exception {
|
| - addNamedSource("/lib1.dart", createSource(//
|
| - "library lib1;",
|
| - "const int c = 1;"));
|
| - Source source = addSource(createSource(//
|
| - "library root;",
|
| - "import 'lib1.dart' deferred as a;",
|
| - "f() {",
|
| - " return const {'a' : a.c + 1};",
|
| - "}"));
|
| - resolve(source);
|
| - assertErrors(source, CompileTimeErrorCode.NON_CONSTANT_MAP_VALUE_FROM_DEFERRED_LIBRARY);
|
| - verify(source);
|
| - }
|
| -
|
| - public void fail_nonConstValueInInitializerFromDeferredLibrary_field() throws Exception {
|
| - addNamedSource("/lib1.dart", createSource(//
|
| - "library lib1;",
|
| - "const int C = 1;"));
|
| - Source source = addSource(createSource(//
|
| - "library root;",
|
| - "import 'lib1.dart' deferred as a;",
|
| - "class A {",
|
| - " final int x;",
|
| - " const A() : x = a.C;",
|
| - "}"));
|
| - resolve(source);
|
| - assertErrors(
|
| - source,
|
| - CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER_FROM_DEFERRED_LIBRARY);
|
| - verify(source);
|
| - }
|
| -
|
| - public void fail_nonConstValueInInitializerFromDeferredLibrary_field_nested() throws Exception {
|
| - addNamedSource("/lib1.dart", createSource(//
|
| - "library lib1;",
|
| - "const int C = 1;"));
|
| + public void fail_constEvalThrowsException() throws Exception { // Not compile-time constant
|
| Source source = addSource(createSource(//
|
| - "library root;",
|
| - "import 'lib1.dart' deferred as a;",
|
| - "class A {",
|
| - " final int x;",
|
| - " const A() : x = a.C + 1;",
|
| - "}"));
|
| + "class C {",
|
| + " const C();",
|
| + "}",
|
| + "f() { return const C(); }"));
|
| resolve(source);
|
| - assertErrors(
|
| - source,
|
| - CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER_FROM_DEFERRED_LIBRARY);
|
| + assertErrors(source, CompileTimeErrorCode.CONST_CONSTRUCTOR_THROWS_EXCEPTION);
|
| verify(source);
|
| }
|
|
|
| - public void fail_nonConstValueInInitializerFromDeferredLibrary_redirecting() throws Exception {
|
| - addNamedSource("/lib1.dart", createSource(//
|
| - "library lib1;",
|
| - "const int C = 1;"));
|
| + public void fail_mixinDeclaresConstructor() throws Exception {
|
| Source source = addSource(createSource(//
|
| - "library root;",
|
| - "import 'lib1.dart' deferred as a;",
|
| "class A {",
|
| - " const A.named(p);",
|
| - " const A() : this.named(a.C);",
|
| - "}"));
|
| + " A() {}",
|
| + "}",
|
| + "class B extends Object mixin A {}"));
|
| resolve(source);
|
| - assertErrors(
|
| - source,
|
| - CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER_FROM_DEFERRED_LIBRARY);
|
| + assertErrors(source, CompileTimeErrorCode.MIXIN_DECLARES_CONSTRUCTOR);
|
| verify(source);
|
| }
|
|
|
| - public void fail_nonConstValueInInitializerFromDeferredLibrary_super() throws Exception {
|
| - addNamedSource("/lib1.dart", createSource(//
|
| - "library lib1;",
|
| - "const int C = 1;"));
|
| + public void fail_mixinOfNonClass() throws Exception {
|
| + // TODO(brianwilkerson) Compare with MIXIN_WITH_NON_CLASS_SUPERCLASS.
|
| Source source = addSource(createSource(//
|
| - "library root;",
|
| - "import 'lib1.dart' deferred as a;",
|
| - "class A {",
|
| - " const A(p);",
|
| - "}",
|
| - "class B extends A {",
|
| - " const B() : super(a.C);",
|
| - "}"));
|
| + "var A;",
|
| + "class B extends Object mixin A {}"));
|
| resolve(source);
|
| - assertErrors(
|
| - source,
|
| - CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER_FROM_DEFERRED_LIBRARY);
|
| + assertErrors(source, CompileTimeErrorCode.MIXIN_OF_NON_CLASS);
|
| verify(source);
|
| }
|
|
|
| @@ -506,23 +91,6 @@ public class CompileTimeErrorCodeTest extends ResolverTestCase {
|
| verify(source);
|
| }
|
|
|
| - public void fail_sharedDeferredPrefix() throws Exception {
|
| - addNamedSource("/lib1.dart", createSource(//
|
| - "library lib1;",
|
| - "f1() {}"));
|
| - addNamedSource("/lib2.dart", createSource(//
|
| - "library lib2;",
|
| - "f2() {}"));
|
| - Source source = addSource(createSource(//
|
| - "library root;",
|
| - "import 'lib1.dart' deferred as lib;",
|
| - "import 'lib2.dart' as lib;",
|
| - "main() { lib.f1(); lib.f2(); }"));
|
| - resolve(source);
|
| - assertErrors(source, CompileTimeErrorCode.SHARED_DEFERRED_PREFIX);
|
| - verify(source);
|
| - }
|
| -
|
| public void fail_superInitializerInObject() throws Exception {
|
| Source source = addSource(createSource(//
|
| // TODO(brianwilkerson) Figure out how to mock Object
|
| @@ -858,6 +426,40 @@ public class CompileTimeErrorCodeTest extends ResolverTestCase {
|
| verify(source);
|
| }
|
|
|
| + public void test_constDeferredClass() throws Exception {
|
| + addNamedSource("/lib1.dart", createSource(//
|
| + "library lib1;",
|
| + "class A {",
|
| + " const A();",
|
| + "}"));
|
| + Source source = addSource(createSource(//
|
| + "library root;",
|
| + "import 'lib1.dart' deferred as a;",
|
| + "main() {",
|
| + " const a.A();",
|
| + "}"));
|
| + resolve(source);
|
| + assertErrors(source, CompileTimeErrorCode.CONST_DEFERRED_CLASS);
|
| + verify(source);
|
| + }
|
| +
|
| + public void test_constDeferredClass_namedConstructor() throws Exception {
|
| + addNamedSource("/lib1.dart", createSource(//
|
| + "library lib1;",
|
| + "class A {",
|
| + " const A.b();",
|
| + "}"));
|
| + Source source = addSource(createSource(//
|
| + "library root;",
|
| + "import 'lib1.dart' deferred as a;",
|
| + "main() {",
|
| + " const a.A.b();",
|
| + "}"));
|
| + resolve(source);
|
| + assertErrors(source, CompileTimeErrorCode.CONST_DEFERRED_CLASS);
|
| + verify(source);
|
| + }
|
| +
|
| public void test_constEval_newInstance_constConstructor() throws Exception {
|
| Source source = addSource(createSource(//
|
| "class A {",
|
| @@ -1024,6 +626,36 @@ public class CompileTimeErrorCodeTest extends ResolverTestCase {
|
| verify(source);
|
| }
|
|
|
| + public void test_constInitializedWithNonConstValueFromDeferredClass() throws Exception {
|
| + addNamedSource("/lib1.dart", createSource(//
|
| + "library lib1;",
|
| + "const V = 1;"));
|
| + Source source = addSource(createSource(//
|
| + "library root;",
|
| + "import 'lib1.dart' deferred as a;",
|
| + "const B = a.V;"));
|
| + resolve(source);
|
| + assertErrors(
|
| + source,
|
| + CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE_FROM_DEFERRED_LIBRARY);
|
| + verify(source);
|
| + }
|
| +
|
| + public void test_constInitializedWithNonConstValueFromDeferredClass_nested() throws Exception {
|
| + addNamedSource("/lib1.dart", createSource(//
|
| + "library lib1;",
|
| + "const V = 1;"));
|
| + Source source = addSource(createSource(//
|
| + "library root;",
|
| + "import 'lib1.dart' deferred as a;",
|
| + "const B = a.V + 1;"));
|
| + resolve(source);
|
| + assertErrors(
|
| + source,
|
| + CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE_FROM_DEFERRED_LIBRARY);
|
| + verify(source);
|
| + }
|
| +
|
| public void test_constInstanceField() throws Exception {
|
| Source source = addSource(createSource(//
|
| "class C {",
|
| @@ -1529,6 +1161,33 @@ public class CompileTimeErrorCodeTest extends ResolverTestCase {
|
| verify(source);
|
| }
|
|
|
| + public void test_extendsDeferredClass() throws Exception {
|
| + addNamedSource("/lib1.dart", createSource(//
|
| + "library lib1;",
|
| + "class A {}"));
|
| + Source source = addSource(createSource(//
|
| + "library root;",
|
| + "import 'lib1.dart' deferred as a;",
|
| + "class B extends a.A {}"));
|
| + resolve(source);
|
| + assertErrors(source, CompileTimeErrorCode.EXTENDS_DEFERRED_CLASS);
|
| + verify(source);
|
| + }
|
| +
|
| + public void test_extendsDeferredClass_classTypeAlias() throws Exception {
|
| + addNamedSource("/lib1.dart", createSource(//
|
| + "library lib1;",
|
| + "class A {}"));
|
| + Source source = addSource(createSource(//
|
| + "library root;",
|
| + "import 'lib1.dart' deferred as a;",
|
| + "class M {}",
|
| + "class C = a.A with M;"));
|
| + resolve(source);
|
| + assertErrors(source, CompileTimeErrorCode.EXTENDS_DEFERRED_CLASS);
|
| + verify(source);
|
| + }
|
| +
|
| public void test_extendsDisallowedClass_class_bool() throws Exception {
|
| Source source = addSource(createSource(//
|
| "class A extends bool {}"));
|
| @@ -1907,6 +1566,34 @@ public class CompileTimeErrorCodeTest extends ResolverTestCase {
|
| verify(source);
|
| }
|
|
|
| + public void test_implementsDeferredClass() throws Exception {
|
| + addNamedSource("/lib1.dart", createSource(//
|
| + "library lib1;",
|
| + "class A {}"));
|
| + Source source = addSource(createSource(//
|
| + "library root;",
|
| + "import 'lib1.dart' deferred as a;",
|
| + "class B implements a.A {}"));
|
| + resolve(source);
|
| + assertErrors(source, CompileTimeErrorCode.IMPLEMENTS_DEFERRED_CLASS);
|
| + verify(source);
|
| + }
|
| +
|
| + public void test_implementsDeferredClass_classTypeAlias() throws Exception {
|
| + addNamedSource("/lib1.dart", createSource(//
|
| + "library lib1;",
|
| + "class A {}"));
|
| + Source source = addSource(createSource(//
|
| + "library root;",
|
| + "import 'lib1.dart' deferred as a;",
|
| + "class B {}",
|
| + "class M {}",
|
| + "class C = B with M implements a.A;"));
|
| + resolve(source);
|
| + assertErrors(source, CompileTimeErrorCode.IMPLEMENTS_DEFERRED_CLASS);
|
| + verify(source);
|
| + }
|
| +
|
| public void test_implementsDisallowedClass_class_bool() throws Exception {
|
| Source source = addSource(createSource(//
|
| "class A implements bool {}"));
|
| @@ -2507,7 +2194,50 @@ public class CompileTimeErrorCodeTest extends ResolverTestCase {
|
| "main() {",
|
| "}"));
|
| resolve(source);
|
| - assertErrors(source, CompileTimeErrorCode.INVALID_ANNOTATION);
|
| + assertErrors(source, CompileTimeErrorCode.INVALID_ANNOTATION);
|
| + }
|
| +
|
| + public void test_invalidAnnotationFromDeferredLibrary() throws Exception {
|
| + // See test_invalidAnnotation_notConstantVariable
|
| + addNamedSource("/lib1.dart", createSource(//
|
| + "library lib1;",
|
| + "class V { const V(); }",
|
| + "const v = const V();"));
|
| + Source source = addSource(createSource(//
|
| + "library root;",
|
| + "import 'lib1.dart' deferred as a;",
|
| + "@a.v main () {}"));
|
| + resolve(source);
|
| + assertErrors(source, CompileTimeErrorCode.INVALID_ANNOTATION_FROM_DEFERRED_LIBRARY);
|
| + verify(source);
|
| + }
|
| +
|
| + public void test_invalidAnnotationFromDeferredLibrary_constructor() throws Exception {
|
| + // See test_invalidAnnotation_notConstantVariable
|
| + addNamedSource("/lib1.dart", createSource(//
|
| + "library lib1;",
|
| + "class C { const C(); }"));
|
| + Source source = addSource(createSource(//
|
| + "library root;",
|
| + "import 'lib1.dart' deferred as a;",
|
| + "@a.C() main () {}"));
|
| + resolve(source);
|
| + assertErrors(source, CompileTimeErrorCode.INVALID_ANNOTATION_FROM_DEFERRED_LIBRARY);
|
| + verify(source);
|
| + }
|
| +
|
| + public void test_invalidAnnotationFromDeferredLibrary_namedConstructor() throws Exception {
|
| + // See test_invalidAnnotation_notConstantVariable
|
| + addNamedSource("/lib1.dart", createSource(//
|
| + "library lib1;",
|
| + "class C { const C.name(); }"));
|
| + Source source = addSource(createSource(//
|
| + "library root;",
|
| + "import 'lib1.dart' deferred as a;",
|
| + "@a.C.name() main () {}"));
|
| + resolve(source);
|
| + assertErrors(source, CompileTimeErrorCode.INVALID_ANNOTATION_FROM_DEFERRED_LIBRARY);
|
| + verify(source);
|
| }
|
|
|
| public void test_invalidConstructorName_notEnclosingClassName_defined() throws Exception {
|
| @@ -2808,6 +2538,33 @@ public class CompileTimeErrorCodeTest extends ResolverTestCase {
|
| verify(source);
|
| }
|
|
|
| + public void test_mixinDeferredClass() throws Exception {
|
| + addNamedSource("/lib1.dart", createSource(//
|
| + "library lib1;",
|
| + "class A {}"));
|
| + Source source = addSource(createSource(//
|
| + "library root;",
|
| + "import 'lib1.dart' deferred as a;",
|
| + "class B extends Object with a.A {}"));
|
| + resolve(source);
|
| + assertErrors(source, CompileTimeErrorCode.MIXIN_DEFERRED_CLASS);
|
| + verify(source);
|
| + }
|
| +
|
| + public void test_mixinDeferredClass_classTypeAlias() throws Exception {
|
| + addNamedSource("/lib1.dart", createSource(//
|
| + "library lib1;",
|
| + "class A {}"));
|
| + Source source = addSource(createSource(//
|
| + "library root;",
|
| + "import 'lib1.dart' deferred as a;",
|
| + "class B {}",
|
| + "class C = B with a.A;"));
|
| + resolve(source);
|
| + assertErrors(source, CompileTimeErrorCode.MIXIN_DEFERRED_CLASS);
|
| + verify(source);
|
| + }
|
| +
|
| public void test_mixinInheritsFromNotObject_classDeclaration_extends() throws Exception {
|
| Source source = addSource(createSource(//
|
| "class A {}",
|
| @@ -3202,6 +2959,32 @@ public class CompileTimeErrorCodeTest extends ResolverTestCase {
|
| verify(source);
|
| }
|
|
|
| + public void test_nonConstantDefaultValueFromDeferredLibrary() throws Exception {
|
| + addNamedSource("/lib1.dart", createSource(//
|
| + "library lib1;",
|
| + "const V = 1;"));
|
| + Source source = addSource(createSource(//
|
| + "library root;",
|
| + "import 'lib1.dart' deferred as a;",
|
| + "f({x : a.V}) {}"));
|
| + resolve(source);
|
| + assertErrors(source, CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE_FROM_DEFERRED_LIBRARY);
|
| + verify(source);
|
| + }
|
| +
|
| + public void test_nonConstantDefaultValueFromDeferredLibrary_nested() throws Exception {
|
| + addNamedSource("/lib1.dart", createSource(//
|
| + "library lib1;",
|
| + "const V = 1;"));
|
| + Source source = addSource(createSource(//
|
| + "library root;",
|
| + "import 'lib1.dart' deferred as a;",
|
| + "f({x : a.V + 1}) {}"));
|
| + resolve(source);
|
| + assertErrors(source, CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE_FROM_DEFERRED_LIBRARY);
|
| + verify(source);
|
| + }
|
| +
|
| public void test_nonConstCaseExpression() throws Exception {
|
| Source source = addSource(createSource(//
|
| "f(int p, int q) {",
|
| @@ -3215,6 +2998,42 @@ public class CompileTimeErrorCodeTest extends ResolverTestCase {
|
| verify(source);
|
| }
|
|
|
| + public void test_nonConstCaseExpressionFromDeferredLibrary() throws Exception {
|
| + addNamedSource("/lib1.dart", createSource(//
|
| + "library lib1;",
|
| + "const int c = 1;"));
|
| + Source source = addSource(createSource(//
|
| + "library root;",
|
| + "import 'lib1.dart' deferred as a;",
|
| + "main (int p) {",
|
| + " switch (p) {",
|
| + " case a.c:",
|
| + " break;",
|
| + " }",
|
| + "}"));
|
| + resolve(source);
|
| + assertErrors(source, CompileTimeErrorCode.NON_CONSTANT_CASE_EXPRESSION_FROM_DEFERRED_LIBRARY);
|
| + verify(source);
|
| + }
|
| +
|
| + public void test_nonConstCaseExpressionFromDeferredLibrary_nested() throws Exception {
|
| + addNamedSource("/lib1.dart", createSource(//
|
| + "library lib1;",
|
| + "const int c = 1;"));
|
| + Source source = addSource(createSource(//
|
| + "library root;",
|
| + "import 'lib1.dart' deferred as a;",
|
| + "main (int p) {",
|
| + " switch (p) {",
|
| + " case a.c + 1:",
|
| + " break;",
|
| + " }",
|
| + "}"));
|
| + resolve(source);
|
| + assertErrors(source, CompileTimeErrorCode.NON_CONSTANT_CASE_EXPRESSION_FROM_DEFERRED_LIBRARY);
|
| + verify(source);
|
| + }
|
| +
|
| public void test_nonConstListElement() throws Exception {
|
| Source source = addSource(createSource(//
|
| "f(a) {",
|
| @@ -3225,6 +3044,36 @@ public class CompileTimeErrorCodeTest extends ResolverTestCase {
|
| verify(source);
|
| }
|
|
|
| + public void test_nonConstListElementFromDeferredLibrary() throws Exception {
|
| + addNamedSource("/lib1.dart", createSource(//
|
| + "library lib1;",
|
| + "const int c = 1;"));
|
| + Source source = addSource(createSource(//
|
| + "library root;",
|
| + "import 'lib1.dart' deferred as a;",
|
| + "f() {",
|
| + " return const [a.c];",
|
| + "}"));
|
| + resolve(source);
|
| + assertErrors(source, CompileTimeErrorCode.NON_CONSTANT_LIST_ELEMENT_FROM_DEFERRED_LIBRARY);
|
| + verify(source);
|
| + }
|
| +
|
| + public void test_nonConstListElementFromDeferredLibrary_nested() throws Exception {
|
| + addNamedSource("/lib1.dart", createSource(//
|
| + "library lib1;",
|
| + "const int c = 1;"));
|
| + Source source = addSource(createSource(//
|
| + "library root;",
|
| + "import 'lib1.dart' deferred as a;",
|
| + "f() {",
|
| + " return const [a.c + 1];",
|
| + "}"));
|
| + resolve(source);
|
| + assertErrors(source, CompileTimeErrorCode.NON_CONSTANT_LIST_ELEMENT_FROM_DEFERRED_LIBRARY);
|
| + verify(source);
|
| + }
|
| +
|
| public void test_nonConstMapAsExpressionStatement_begin() throws Exception {
|
| Source source = addSource(createSource(//
|
| "f() {",
|
| @@ -3255,6 +3104,36 @@ public class CompileTimeErrorCodeTest extends ResolverTestCase {
|
| verify(source);
|
| }
|
|
|
| + public void test_nonConstMapKeyFromDeferredLibrary() throws Exception {
|
| + addNamedSource("/lib1.dart", createSource(//
|
| + "library lib1;",
|
| + "const int c = 1;"));
|
| + Source source = addSource(createSource(//
|
| + "library root;",
|
| + "import 'lib1.dart' deferred as a;",
|
| + "f() {",
|
| + " return const {a.c : 0};",
|
| + "}"));
|
| + resolve(source);
|
| + assertErrors(source, CompileTimeErrorCode.NON_CONSTANT_MAP_KEY_FROM_DEFERRED_LIBRARY);
|
| + verify(source);
|
| + }
|
| +
|
| + public void test_nonConstMapKeyFromDeferredLibrary_nested() throws Exception {
|
| + addNamedSource("/lib1.dart", createSource(//
|
| + "library lib1;",
|
| + "const int c = 1;"));
|
| + Source source = addSource(createSource(//
|
| + "library root;",
|
| + "import 'lib1.dart' deferred as a;",
|
| + "f() {",
|
| + " return const {a.c + 1 : 0};",
|
| + "}"));
|
| + resolve(source);
|
| + assertErrors(source, CompileTimeErrorCode.NON_CONSTANT_MAP_KEY_FROM_DEFERRED_LIBRARY);
|
| + verify(source);
|
| + }
|
| +
|
| public void test_nonConstMapValue() throws Exception {
|
| Source source = addSource(createSource(//
|
| "f(a) {",
|
| @@ -3265,6 +3144,36 @@ public class CompileTimeErrorCodeTest extends ResolverTestCase {
|
| verify(source);
|
| }
|
|
|
| + public void test_nonConstMapValueFromDeferredLibrary() throws Exception {
|
| + addNamedSource("/lib1.dart", createSource(//
|
| + "library lib1;",
|
| + "const int c = 1;"));
|
| + Source source = addSource(createSource(//
|
| + "library root;",
|
| + "import 'lib1.dart' deferred as a;",
|
| + "f() {",
|
| + " return const {'a' : a.c};",
|
| + "}"));
|
| + resolve(source);
|
| + assertErrors(source, CompileTimeErrorCode.NON_CONSTANT_MAP_VALUE_FROM_DEFERRED_LIBRARY);
|
| + verify(source);
|
| + }
|
| +
|
| + public void test_nonConstMapValueFromDeferredLibrary_nested() throws Exception {
|
| + addNamedSource("/lib1.dart", createSource(//
|
| + "library lib1;",
|
| + "const int c = 1;"));
|
| + Source source = addSource(createSource(//
|
| + "library root;",
|
| + "import 'lib1.dart' deferred as a;",
|
| + "f() {",
|
| + " return const {'a' : a.c + 1};",
|
| + "}"));
|
| + resolve(source);
|
| + assertErrors(source, CompileTimeErrorCode.NON_CONSTANT_MAP_VALUE_FROM_DEFERRED_LIBRARY);
|
| + verify(source);
|
| + }
|
| +
|
| public void test_nonConstValueInInitializer_binary_notBool_left() throws Exception {
|
| Source source = addSource(createSource(//
|
| "class A {",
|
| @@ -3353,6 +3262,80 @@ public class CompileTimeErrorCodeTest extends ResolverTestCase {
|
| verify(source);
|
| }
|
|
|
| + public void test_nonConstValueInInitializerFromDeferredLibrary_field() throws Exception {
|
| + addNamedSource("/lib1.dart", createSource(//
|
| + "library lib1;",
|
| + "const int C = 1;"));
|
| + Source source = addSource(createSource(//
|
| + "library root;",
|
| + "import 'lib1.dart' deferred as a;",
|
| + "class A {",
|
| + " final int x;",
|
| + " const A() : x = a.C;",
|
| + "}"));
|
| + resolve(source);
|
| + assertErrors(
|
| + source,
|
| + CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER_FROM_DEFERRED_LIBRARY);
|
| + verify(source);
|
| + }
|
| +
|
| + public void test_nonConstValueInInitializerFromDeferredLibrary_field_nested() throws Exception {
|
| + addNamedSource("/lib1.dart", createSource(//
|
| + "library lib1;",
|
| + "const int C = 1;"));
|
| + Source source = addSource(createSource(//
|
| + "library root;",
|
| + "import 'lib1.dart' deferred as a;",
|
| + "class A {",
|
| + " final int x;",
|
| + " const A() : x = a.C + 1;",
|
| + "}"));
|
| + resolve(source);
|
| + assertErrors(
|
| + source,
|
| + CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER_FROM_DEFERRED_LIBRARY);
|
| + verify(source);
|
| + }
|
| +
|
| + public void test_nonConstValueInInitializerFromDeferredLibrary_redirecting() throws Exception {
|
| + addNamedSource("/lib1.dart", createSource(//
|
| + "library lib1;",
|
| + "const int C = 1;"));
|
| + Source source = addSource(createSource(//
|
| + "library root;",
|
| + "import 'lib1.dart' deferred as a;",
|
| + "class A {",
|
| + " const A.named(p);",
|
| + " const A() : this.named(a.C);",
|
| + "}"));
|
| + resolve(source);
|
| + assertErrors(
|
| + source,
|
| + CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER_FROM_DEFERRED_LIBRARY);
|
| + verify(source);
|
| + }
|
| +
|
| + public void test_nonConstValueInInitializerFromDeferredLibrary_super() throws Exception {
|
| + addNamedSource("/lib1.dart", createSource(//
|
| + "library lib1;",
|
| + "const int C = 1;"));
|
| + Source source = addSource(createSource(//
|
| + "library root;",
|
| + "import 'lib1.dart' deferred as a;",
|
| + "class A {",
|
| + " const A(p);",
|
| + "}",
|
| + "class B extends A {",
|
| + " const B() : super(a.C);",
|
| + "}"));
|
| + resolve(source);
|
| + assertErrors(
|
| + source,
|
| + CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER_FROM_DEFERRED_LIBRARY);
|
| + verify(source);
|
| + }
|
| +
|
| public void test_nonGenerativeConstructor_explicit() throws Exception {
|
| Source source = addSource(createSource(//
|
| "class A {",
|
| @@ -3916,6 +3899,23 @@ public class CompileTimeErrorCodeTest extends ResolverTestCase {
|
| verify(source);
|
| }
|
|
|
| + public void test_sharedDeferredPrefix() throws Exception {
|
| + addNamedSource("/lib1.dart", createSource(//
|
| + "library lib1;",
|
| + "f1() {}"));
|
| + addNamedSource("/lib2.dart", createSource(//
|
| + "library lib2;",
|
| + "f2() {}"));
|
| + Source source = addSource(createSource(//
|
| + "library root;",
|
| + "import 'lib1.dart' deferred as lib;",
|
| + "import 'lib2.dart' as lib;",
|
| + "main() { lib.f1(); lib.f2(); }"));
|
| + resolve(source);
|
| + assertErrors(source, CompileTimeErrorCode.SHARED_DEFERRED_PREFIX);
|
| + verify(source);
|
| + }
|
| +
|
| public void test_superInInvalidContext_binaryExpression() throws Exception {
|
| Source source = addSource(createSource(//
|
| "var v = super + 0;"));
|
|
|