Chromium Code Reviews| Index: pkg/analyzer/test/generated/compile_time_error_code_test.dart |
| diff --git a/pkg/analyzer/test/generated/compile_time_error_code_test.dart b/pkg/analyzer/test/generated/compile_time_error_code_test.dart |
| index e336325fa7c8582191a9040af0f3bd36a7f317d2..494145ae04929b256a3aa7e69cbad8b5b0f0ac5d 100644 |
| --- a/pkg/analyzer/test/generated/compile_time_error_code_test.dart |
| +++ b/pkg/analyzer/test/generated/compile_time_error_code_test.dart |
| @@ -1399,7 +1399,8 @@ class C = a.A with M;'''], <ErrorCode> [ParserErrorCode.DEFERRED_IMPORTS_NOT_SUP |
| class M {} |
| class C = bool with M;'''); |
| resolve(source); |
| - assertErrors(source, [CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS]); |
| + assertErrors(source, [CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS, |
| + CompileTimeErrorCode.MIXIN_HAS_NO_CONSTRUCTORS]); |
|
Brian Wilkerson
2014/11/07 16:59:32
It would be good to disable the second error if th
Paul Berry
2014/11/07 17:31:01
Good point. I'll do this in a follow-up CL, as we
|
| verify([source]); |
| } |
| @@ -1417,7 +1418,8 @@ class C = double with M;'''); |
| class M {} |
| class C = int with M;'''); |
| resolve(source); |
| - assertErrors(source, [CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS]); |
| + assertErrors(source, [CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS, |
| + CompileTimeErrorCode.MIXIN_HAS_NO_CONSTRUCTORS]); |
| verify([source]); |
| } |
| @@ -1444,7 +1446,8 @@ class C = num with M;'''); |
| class M {} |
| class C = String with M;'''); |
| resolve(source); |
| - assertErrors(source, [CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS]); |
| + assertErrors(source, [CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS, |
| + CompileTimeErrorCode.MIXIN_HAS_NO_CONSTRUCTORS]); |
| verify([source]); |
| } |
| @@ -2908,6 +2911,32 @@ class B {} |
| class C = B with a.A;'''], <ErrorCode> [ParserErrorCode.DEFERRED_IMPORTS_NOT_SUPPORTED], <ErrorCode> [CompileTimeErrorCode.MIXIN_DEFERRED_CLASS]); |
| } |
| + void test_mixinHasNoConstructors_mixinApp() { |
| + Source source = addSource(r''' |
| +class B { |
| + B({x}); |
| +} |
| +class M {} |
| +class C = B with M; |
| +'''); |
| + resolve(source); |
| + assertErrors(source, [CompileTimeErrorCode.MIXIN_HAS_NO_CONSTRUCTORS]); |
| + verify([source]); |
| + } |
| + |
| + void test_mixinHasNoConstructors_mixinClass() { |
| + Source source = addSource(r''' |
| +class B { |
| + B({x}); |
| +} |
| +class M {} |
| +class C extends B with M {} |
| +'''); |
| + resolve(source); |
| + assertErrors(source, [CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT]); |
| + verify([source]); |
| + } |
| + |
| void test_mixinInheritsFromNotObject_classDeclaration_extends() { |
| Source source = addSource(r''' |
| class A {} |
| @@ -3196,6 +3225,202 @@ class B extends A { |
| verify([source]); |
| } |
| + void test_noDefaultSuperConstructorExplicit_MixinAppWithDirectSuperCall() { |
| + Source source = addSource(r''' |
| +class M {} |
| +class B { |
| + B({x}); |
| + B.named(); // To avoid MIXIN_HAS_NO_CONSTRUCTORS |
| +} |
| +class Mixed = B with M; |
| +class C extends Mixed { |
| + C(x) : super(); |
| +} |
| +'''); |
| + resolve(source); |
| + assertErrors(source, [ |
| + CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INITIALIZER_DEFAULT]); |
| + verify([source]); |
| + } |
| + |
| + void test_noDefaultSuperConstructorExplicit_MixinAppWithNamedSuperCall() { |
| + Source source = addSource(r''' |
| +class M {} |
| +class B { |
| + B.named({x}); |
| + B.named2(); // To avoid MIXIN_HAS_NO_CONSTRUCTORS |
| +} |
| +class Mixed = B with M; |
| +class C extends Mixed { |
| + C(x) : super.named(); |
| +} |
| +'''); |
| + resolve(source); |
| + assertErrors(source, [ |
| + CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INITIALIZER]); |
| + // Don't verify since call to super.named() can't be resolved. |
| + } |
| + |
| + void test_noDefaultSuperConstructorExplicit_mixinAppWithNamedParam() { |
| + Source source = addSource(r''' |
| +class M {} |
| +class B { |
| + B({x}); |
| + B.named(); // To avoid MIXIN_HAS_NO_CONSTRUCTORS |
| +} |
| +class Mixed = B with M; |
| +class C extends Mixed { |
| + C(); |
| +} |
| +'''); |
| + resolve(source); |
| + assertErrors(source, [ |
| + CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INITIALIZER_DEFAULT]); |
| + verify([source]); |
| + } |
| + |
| + void test_noDefaultSuperConstructorExplicit_mixinAppWithOptionalParam() { |
| + Source source = addSource(r''' |
| +class M {} |
| +class B { |
| + B([x]); |
| + B.named(); // To avoid MIXIN_HAS_NO_CONSTRUCTORS |
| +} |
| +class Mixed = B with M; |
| +class C extends Mixed { |
| + C(); |
| +} |
| +'''); |
| + resolve(source); |
| + assertErrors(source, [ |
| + CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INITIALIZER_DEFAULT]); |
| + verify([source]); |
| + } |
| + |
| + void test_noDefaultSuperConstructorExplicit_MixinWithDirectSuperCall() { |
| + Source source = addSource(r''' |
| +class M {} |
| +class B { |
| + B({x}); |
| +} |
| +class C extends B with M { |
| + C(x) : super(); |
| +} |
| +'''); |
| + resolve(source); |
| + assertErrors(source, [ |
| + CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INITIALIZER_DEFAULT]); |
| + verify([source]); |
| + } |
| + |
| + void test_noDefaultSuperConstructorExplicit_MixinWithNamedSuperCall() { |
| + Source source = addSource(r''' |
| +class M {} |
| +class B { |
| + B.named({x}); |
| +} |
| +class C extends B with M { |
| + C(x) : super.named(); |
| +} |
| +'''); |
| + resolve(source); |
| + assertErrors(source, [ |
| + CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INITIALIZER]); |
| + // Don't verify since call to super.named() can't be resolved. |
| + } |
| + |
| + void test_noDefaultSuperConstructorExplicit_mixinWithNamedParam() { |
| + Source source = addSource(r''' |
| +class M {} |
| +class B { |
| + B({x}); |
| +} |
| +class C extends B with M { |
| + C(); |
| +} |
| +'''); |
| + resolve(source); |
| + assertErrors(source, [ |
| + CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_EXPLICIT]); |
| + verify([source]); |
| + } |
| + |
| + void test_noDefaultSuperConstructorExplicit_mixinWithOptionalParam() { |
| + Source source = addSource(r''' |
| +class M {} |
| +class B { |
| + B([x]); |
| +} |
| +class C extends B with M { |
| + C(); |
| +} |
| +'''); |
| + resolve(source); |
| + assertErrors(source, [ |
| + CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_EXPLICIT]); |
| + verify([source]); |
| + } |
| + |
| + void test_noDefaultSuperConstructorImplicit_mixinAppWithNamedParam() { |
| + Source source = addSource(r''' |
| +class M {} |
| +class B { |
| + B({x}); |
| + B.named(); // To avoid MIXIN_HAS_NO_CONSTRUCTORS |
| +} |
| +class Mixed = B with M; |
| +class C extends Mixed {} |
| +'''); |
| + resolve(source); |
| + assertErrors(source, [ |
| + CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT]); |
| + verify([source]); |
| + } |
| + |
| + void test_noDefaultSuperConstructorImplicit_mixinAppWithOptionalParam() { |
| + Source source = addSource(r''' |
| +class M {} |
| +class B { |
| + B([x]); |
| + B.named(); // To avoid MIXIN_HAS_NO_CONSTRUCTORS |
| +} |
| +class Mixed = B with M; |
| +class C extends Mixed {} |
| +'''); |
| + resolve(source); |
| + assertErrors(source, [ |
| + CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT]); |
| + verify([source]); |
| + } |
| + |
| + void test_noDefaultSuperConstructorImplicit_mixinWithNamedParam() { |
| + Source source = addSource(r''' |
| +class M {} |
| +class B { |
| + B({x}); |
| +} |
| +class C extends B with M {} |
| +'''); |
| + resolve(source); |
| + assertErrors(source, [ |
| + CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT]); |
| + verify([source]); |
| + } |
| + |
| + void test_noDefaultSuperConstructorImplicit_mixinWithOptionalParam() { |
| + Source source = addSource(r''' |
| +class M {} |
| +class B { |
| + B([x]); |
| +} |
| +class C extends B with M {} |
| +'''); |
| + resolve(source); |
| + assertErrors(source, [ |
| + CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT]); |
| + verify([source]); |
| + } |
| + |
| void test_noDefaultSuperConstructorImplicit_superHasParameters() { |
| Source source = addSource(r''' |
| class A { |