mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 00:13:50 +00:00
[tests] Fix existing on clause tests for final classes.
Disallow using final classes on on-clauses outside of its library. Update tests to show this behaviour. (Or at least in a state where I can test out the implementation) Change-Id: I74306c873dbd047c6b94d8e8e75c215562dd9483 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/290915 Commit-Queue: Kallen Tu <kallentu@google.com> Reviewed-by: Leaf Petersen <leafp@google.com>
This commit is contained in:
parent
22f6200fb0
commit
24d210a18c
|
@ -177,7 +177,8 @@ base mixin BaseMixinImplement implements FinalClass {}
|
|||
// [analyzer] COMPILE_TIME_ERROR.INVALID_USE_OF_TYPE_OUTSIDE_LIBRARY
|
||||
// [cfe] The class 'FinalClass' can't be implemented outside of its library because it's a final class.
|
||||
|
||||
/// It is an error if FinalClass is the `on` type of a mixin which is not marked base.
|
||||
// It is an error if FinalClass is the `on` type of a mixin outside of
|
||||
// FinalClass' library.
|
||||
|
||||
mixin SimpleMixinOn on FinalClass {}
|
||||
// ^^^^^^^^^^^^^
|
||||
|
@ -194,4 +195,9 @@ mixin SimpleMixinOnSimpleFinal on SimpleClass, FinalClass {}
|
|||
// [analyzer] COMPILE_TIME_ERROR.SUBTYPE_OF_BASE_OR_FINAL_IS_NOT_BASE_FINAL_OR_SEALED
|
||||
// [cfe] The type 'SimpleMixinOnSimpleFinal' must be 'base', 'final' or 'sealed' because the supertype 'FinalClass' is 'final'.
|
||||
|
||||
base mixin BaseMixinOn on FinalClass {}
|
||||
// ^
|
||||
// [analyzer] unspecified
|
||||
// [cfe] unspecified
|
||||
|
||||
main() {}
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
// 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.
|
||||
|
||||
// SharedOptions=--enable-experiment=class-modifiers
|
||||
|
||||
/// Test the valid uses of a final class defined in a different library
|
||||
|
||||
import "shared_library_definitions.dart" show FinalClass;
|
||||
|
||||
base mixin BaseMixinOn on FinalClass {}
|
||||
|
||||
main() {}
|
|
@ -1,46 +0,0 @@
|
|||
// Copyright (c) 2022, 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.
|
||||
|
||||
// SharedOptions=--enable-experiment=class-modifiers
|
||||
|
||||
// Allow a final type to appear in the "on" clause of a mixin declaration.
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
|
||||
final class FinalClass {}
|
||||
|
||||
abstract final class A extends FinalClass {}
|
||||
|
||||
final class B extends FinalClass {}
|
||||
|
||||
final mixin FinalMixin {}
|
||||
|
||||
final class C extends FinalClass with FinalMixin {}
|
||||
|
||||
final class D with FinalMixin {}
|
||||
|
||||
final mixin MA on FinalClass {}
|
||||
final mixin MB on FinalClass {}
|
||||
|
||||
final class ConcreteA extends A with MA, MB {
|
||||
int foo = 0;
|
||||
}
|
||||
|
||||
final mixin MC on FinalClass, FinalMixin {}
|
||||
|
||||
final class ConcreteC extends C with MC {
|
||||
int foo = 0;
|
||||
}
|
||||
|
||||
final mixin MCSingular on FinalMixin {}
|
||||
|
||||
final class ConcreteD extends D with MCSingular {
|
||||
int foo = 0;
|
||||
}
|
||||
|
||||
main() {
|
||||
Expect.equals(0, ConcreteA().foo);
|
||||
Expect.equals(0, ConcreteC().foo);
|
||||
Expect.equals(0, ConcreteD().foo);
|
||||
}
|
Loading…
Reference in a new issue