| // Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file |
| // for details. All rights reserved. Use of this source code is governed by a |
| // BSD-style license that can be found in the LICENSE file. |
| |
| /// Test the invalid uses of a base mixin class within the same library |
| |
| class SimpleClass {} |
| |
| base mixin BaseMixin {} |
| |
| mixin _MixinOnObject {} |
| |
| /// It is an error if BaseMixin is implemented by something which is not |
| /// base, final or sealed. |
| |
| // Simple implementation. |
| |
| class SimpleImplement implements BaseMixin {} |
| // ^^^^^^^^^^^^^^^ |
| // [analyzer] COMPILE_TIME_ERROR.SUBTYPE_OF_BASE_OR_FINAL_IS_NOT_BASE_FINAL_OR_SEALED |
| // [cfe] The type 'SimpleImplement' must be 'base', 'final' or 'sealed' because the supertype 'BaseMixin' is 'base'. |
| |
| interface class InterfaceImplement implements BaseMixin {} |
| // ^^^^^^^^^^^^^^^^^^ |
| // [analyzer] COMPILE_TIME_ERROR.SUBTYPE_OF_BASE_OR_FINAL_IS_NOT_BASE_FINAL_OR_SEALED |
| // [cfe] The type 'InterfaceImplement' must be 'base', 'final' or 'sealed' because the supertype 'BaseMixin' is 'base'. |
| |
| // Implementing with a sealed class (valid, used for tests below). |
| |
| sealed class SealedImplement implements BaseMixin {} |
| |
| // Extending through a sealed class. |
| |
| class SimpleSealedImplementExtend extends SealedImplement {} |
| // ^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| // [analyzer] COMPILE_TIME_ERROR.SUBTYPE_OF_BASE_OR_FINAL_IS_NOT_BASE_FINAL_OR_SEALED |
| // [cfe] The type 'SimpleSealedImplementExtend' must be 'base', 'final' or 'sealed' because the supertype 'BaseMixin' is 'base'. |
| |
| interface class InterfaceSealedImplementExtend extends SealedImplement {} |
| // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| // [analyzer] COMPILE_TIME_ERROR.SUBTYPE_OF_BASE_OR_FINAL_IS_NOT_BASE_FINAL_OR_SEALED |
| // [cfe] The type 'InterfaceSealedImplementExtend' must be 'base', 'final' or 'sealed' because the supertype 'BaseMixin' is 'base'. |
| |
| // Implementing through a sealed class. |
| |
| class SimpleSealedImplementImplement implements SealedImplement {} |
| // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| // [analyzer] COMPILE_TIME_ERROR.SUBTYPE_OF_BASE_OR_FINAL_IS_NOT_BASE_FINAL_OR_SEALED |
| // [cfe] The type 'SimpleSealedImplementImplement' must be 'base', 'final' or 'sealed' because the supertype 'BaseMixin' is 'base'. |
| |
| interface class InterfaceSealedImplementImplement implements SealedImplement {} |
| // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| // [analyzer] COMPILE_TIME_ERROR.SUBTYPE_OF_BASE_OR_FINAL_IS_NOT_BASE_FINAL_OR_SEALED |
| // [cfe] The type 'InterfaceSealedImplementImplement' must be 'base', 'final' or 'sealed' because the supertype 'BaseMixin' is 'base'. |
| |
| // Implementing with a mixin class. |
| |
| mixin class SimpleMixinClassImplement implements BaseMixin {} |
| // ^^^^^^^^^^^^^^^^^^^^^^^^^ |
| // [analyzer] COMPILE_TIME_ERROR.SUBTYPE_OF_BASE_OR_FINAL_IS_NOT_BASE_FINAL_OR_SEALED |
| // [cfe] The type 'SimpleMixinClassImplement' must be 'base', 'final' or 'sealed' because the supertype 'BaseMixin' is 'base'. |
| |
| // Implementing with a base mixin class (valid, used for tests below) |
| |
| base mixin class BaseMixinClassImplement implements BaseMixin {} |
| |
| // Implementing by applying a mixin class. |
| |
| class SimpleMixinClassImplementApplied extends Object |
| // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| // [analyzer] COMPILE_TIME_ERROR.SUBTYPE_OF_BASE_OR_FINAL_IS_NOT_BASE_FINAL_OR_SEALED |
| // [cfe] The type 'SimpleMixinClassImplementApplied' must be 'base', 'final' or 'sealed' because the supertype 'BaseMixinClassImplement' is 'base'. |
| with |
| BaseMixinClassImplement {} |
| |
| interface class InterfaceMixinClassImplementApplied extends Object |
| // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| // [analyzer] COMPILE_TIME_ERROR.SUBTYPE_OF_BASE_OR_FINAL_IS_NOT_BASE_FINAL_OR_SEALED |
| // [cfe] The type 'InterfaceMixinClassImplementApplied' must be 'base', 'final' or 'sealed' because the supertype 'BaseMixinClassImplement' is 'base'. |
| with |
| BaseMixinClassImplement {} |
| |
| // Implementing with a mixin application class. |
| |
| interface class InterfaceImplementApplication = Object |
| // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| // [analyzer] COMPILE_TIME_ERROR.SUBTYPE_OF_BASE_OR_FINAL_IS_NOT_BASE_FINAL_OR_SEALED |
| // [cfe] The type 'InterfaceImplementApplication' must be 'base', 'final' or 'sealed' because the supertype 'BaseMixin' is 'base'. |
| with |
| _MixinOnObject |
| implements |
| BaseMixin; |
| |
| class SimpleImplementApplication = Object |
| // ^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| // [analyzer] COMPILE_TIME_ERROR.SUBTYPE_OF_BASE_OR_FINAL_IS_NOT_BASE_FINAL_OR_SEALED |
| // [cfe] The type 'SimpleImplementApplication' must be 'base', 'final' or 'sealed' because the supertype 'BaseMixin' is 'base'. |
| with |
| _MixinOnObject |
| implements |
| BaseMixin; |
| |
| // Implementing with a mixin. |
| |
| mixin SimpleMixinImplement implements BaseMixin {} |
| // ^^^^^^^^^^^^^^^^^^^^ |
| // [analyzer] COMPILE_TIME_ERROR.SUBTYPE_OF_BASE_OR_FINAL_IS_NOT_BASE_FINAL_OR_SEALED |
| // [cfe] The mixin 'SimpleMixinImplement' must be 'base' because the supertype 'BaseMixin' is 'base'. |
| |
| // Implementing with a base mixin (valid, used for tests below) |
| |
| base mixin BaseMixinImplement implements BaseMixin {} |
| |
| // Implementing by applying a mixin. |
| |
| class SimpleMixinImplementApplied extends Object with BaseMixinImplement {} |
| // ^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| // [analyzer] COMPILE_TIME_ERROR.SUBTYPE_OF_BASE_OR_FINAL_IS_NOT_BASE_FINAL_OR_SEALED |
| // [cfe] The type 'SimpleMixinImplementApplied' must be 'base', 'final' or 'sealed' because the supertype 'BaseMixinImplement' is 'base'. |
| |
| interface class InterfaceMixinImplementApplied extends Object |
| // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| // [analyzer] COMPILE_TIME_ERROR.SUBTYPE_OF_BASE_OR_FINAL_IS_NOT_BASE_FINAL_OR_SEALED |
| // [cfe] The type 'InterfaceMixinImplementApplied' must be 'base', 'final' or 'sealed' because the supertype 'BaseMixinImplement' is 'base'. |
| with |
| BaseMixinImplement {} |
| |
| /// It is an error if BaseMixin is the `on` type of something which is not base. |
| |
| mixin SimpleMixinOn on BaseMixin {} |
| // ^^^^^^^^^^^^^ |
| // [analyzer] COMPILE_TIME_ERROR.SUBTYPE_OF_BASE_OR_FINAL_IS_NOT_BASE_FINAL_OR_SEALED |
| // [cfe] The mixin 'SimpleMixinOn' must be 'base' because the supertype 'BaseMixin' is 'base'. |
| |
| mixin SimpleMixinOnBaseSimple on BaseMixin, SimpleClass {} |
| // ^^^^^^^^^^^^^^^^^^^^^^^ |
| // [analyzer] COMPILE_TIME_ERROR.SUBTYPE_OF_BASE_OR_FINAL_IS_NOT_BASE_FINAL_OR_SEALED |
| // [cfe] The mixin 'SimpleMixinOnBaseSimple' must be 'base' because the supertype 'BaseMixin' is 'base'. |
| |
| mixin SimpleMixinOnSimpleBase on SimpleClass, BaseMixin {} |
| // ^^^^^^^^^^^^^^^^^^^^^^^ |
| // [analyzer] COMPILE_TIME_ERROR.SUBTYPE_OF_BASE_OR_FINAL_IS_NOT_BASE_FINAL_OR_SEALED |
| // [cfe] The mixin 'SimpleMixinOnSimpleBase' must be 'base' because the supertype 'BaseMixin' is 'base'. |
| |
| /// It is an error to use BaseMixin as a mixin, if the result is not base, |
| /// final or sealed. |
| |
| class SimpleMixinClassApply extends Object with BaseMixin {} |
| // ^^^^^^^^^^^^^^^^^^^^^ |
| // [analyzer] COMPILE_TIME_ERROR.SUBTYPE_OF_BASE_OR_FINAL_IS_NOT_BASE_FINAL_OR_SEALED |
| // [cfe] The type 'SimpleMixinClassApply' must be 'base', 'final' or 'sealed' because the supertype 'BaseMixin' is 'base'. |
| |
| class SimpleMixinClassApplySimpleBase extends Object |
| // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| // [analyzer] COMPILE_TIME_ERROR.SUBTYPE_OF_BASE_OR_FINAL_IS_NOT_BASE_FINAL_OR_SEALED |
| // [cfe] The type 'SimpleMixinClassApplySimpleBase' must be 'base', 'final' or 'sealed' because the supertype 'BaseMixin' is 'base'. |
| with |
| _MixinOnObject, |
| BaseMixin {} |
| |
| class SimpleMixinClassApplyBaseSimple extends Object |
| // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| // [analyzer] COMPILE_TIME_ERROR.SUBTYPE_OF_BASE_OR_FINAL_IS_NOT_BASE_FINAL_OR_SEALED |
| // [cfe] The type 'SimpleMixinClassApplyBaseSimple' must be 'base', 'final' or 'sealed' because the supertype 'BaseMixin' is 'base'. |
| with |
| BaseMixin, |
| _MixinOnObject {} |
| |
| interface class InterfaceMixinClassApply extends Object with BaseMixin {} |
| // ^^^^^^^^^^^^^^^^^^^^^^^^ |
| // [analyzer] COMPILE_TIME_ERROR.SUBTYPE_OF_BASE_OR_FINAL_IS_NOT_BASE_FINAL_OR_SEALED |
| // [cfe] The type 'InterfaceMixinClassApply' must be 'base', 'final' or 'sealed' because the supertype 'BaseMixin' is 'base'. |
| |
| interface class InterfaceMixinClassApplySimpleBase extends Object |
| // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| // [analyzer] COMPILE_TIME_ERROR.SUBTYPE_OF_BASE_OR_FINAL_IS_NOT_BASE_FINAL_OR_SEALED |
| // [cfe] The type 'InterfaceMixinClassApplySimpleBase' must be 'base', 'final' or 'sealed' because the supertype 'BaseMixin' is 'base'. |
| with |
| _MixinOnObject, |
| BaseMixin {} |
| |
| interface class InterfaceMixinClassApplyBaseSimple extends Object |
| // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| // [analyzer] COMPILE_TIME_ERROR.SUBTYPE_OF_BASE_OR_FINAL_IS_NOT_BASE_FINAL_OR_SEALED |
| // [cfe] The type 'InterfaceMixinClassApplyBaseSimple' must be 'base', 'final' or 'sealed' because the supertype 'BaseMixin' is 'base'. |
| with |
| BaseMixin, |
| _MixinOnObject {} |
| |
| /// It is an error to use BaseMixin as a mixin application, if the result |
| /// is not base, final or sealed. |
| |
| class SimpleMixinClassApplication extends Object with BaseMixin {} |
| // ^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| // [analyzer] COMPILE_TIME_ERROR.SUBTYPE_OF_BASE_OR_FINAL_IS_NOT_BASE_FINAL_OR_SEALED |
| // [cfe] The type 'SimpleMixinClassApplication' must be 'base', 'final' or 'sealed' because the supertype 'BaseMixin' is 'base'. |
| |
| class SimpleMixinClassApplicationSimpleBase extends Object |
| // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| // [analyzer] COMPILE_TIME_ERROR.SUBTYPE_OF_BASE_OR_FINAL_IS_NOT_BASE_FINAL_OR_SEALED |
| // [cfe] The type 'SimpleMixinClassApplicationSimpleBase' must be 'base', 'final' or 'sealed' because the supertype 'BaseMixin' is 'base'. |
| with |
| _MixinOnObject, |
| BaseMixin {} |
| |
| class SimpleMixinClassApplicationBaseSimple extends Object |
| // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| // [analyzer] COMPILE_TIME_ERROR.SUBTYPE_OF_BASE_OR_FINAL_IS_NOT_BASE_FINAL_OR_SEALED |
| // [cfe] The type 'SimpleMixinClassApplicationBaseSimple' must be 'base', 'final' or 'sealed' because the supertype 'BaseMixin' is 'base'. |
| with |
| BaseMixin, |
| _MixinOnObject {} |
| |
| interface class InterfaceMixinClassApplication extends Object with BaseMixin {} |
| // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| // [analyzer] COMPILE_TIME_ERROR.SUBTYPE_OF_BASE_OR_FINAL_IS_NOT_BASE_FINAL_OR_SEALED |
| // [cfe] The type 'InterfaceMixinClassApplication' must be 'base', 'final' or 'sealed' because the supertype 'BaseMixin' is 'base'. |
| |
| interface class InterfaceMixinClassApplicationSimpleBase extends Object |
| // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| // [analyzer] COMPILE_TIME_ERROR.SUBTYPE_OF_BASE_OR_FINAL_IS_NOT_BASE_FINAL_OR_SEALED |
| // [cfe] The type 'InterfaceMixinClassApplicationSimpleBase' must be 'base', 'final' or 'sealed' because the supertype 'BaseMixin' is 'base'. |
| with |
| _MixinOnObject, |
| BaseMixin {} |
| |
| interface class InterfaceMixinClassApplicationBaseSimple extends Object |
| // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| // [analyzer] COMPILE_TIME_ERROR.SUBTYPE_OF_BASE_OR_FINAL_IS_NOT_BASE_FINAL_OR_SEALED |
| // [cfe] The type 'InterfaceMixinClassApplicationBaseSimple' must be 'base', 'final' or 'sealed' because the supertype 'BaseMixin' is 'base'. |
| with |
| BaseMixin, |
| _MixinOnObject {} |