mirror of
https://github.com/dart-lang/sdk
synced 2024-09-15 23:59:47 +00:00
82b78916fd
Change-Id: If31c487e3ebe2c1ae847aff7c8994580b8b6f2f6 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/309660 Reviewed-by: Alexander Thomas <athom@google.com> Commit-Queue: Alexander Thomas <athom@google.com>
53 lines
1.5 KiB
Dart
53 lines
1.5 KiB
Dart
// 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.
|
|
|
|
// Allow sealed classes to be implemented by multiple classes in the same
|
|
// library.
|
|
// Additionally, allow their subclasses/subtypes to be used freely.
|
|
|
|
import "package:expect/expect.dart";
|
|
import 'sealed_class_implement_lib.dart';
|
|
|
|
class AExtends extends A {
|
|
int nonAbstractFoo = 0;
|
|
int foo = 0;
|
|
int bar(int value) => value;
|
|
int nonAbstractBar(int value) => value;
|
|
}
|
|
|
|
class AImplements implements A {
|
|
int nonAbstractFoo = 0;
|
|
int foo = 0;
|
|
int bar(int value) => value;
|
|
int nonAbstractBar(int value) => value;
|
|
}
|
|
|
|
main() {
|
|
A a = AImpl();
|
|
Expect.equals(0, a.nonAbstractFoo);
|
|
Expect.equals(1, a.foo);
|
|
Expect.equals(3, a.bar(2));
|
|
Expect.equals(100, a.nonAbstractBar(0));
|
|
|
|
var b = B();
|
|
Expect.equals(100, b.nonAbstractFoo);
|
|
Expect.equals(2, b.foo);
|
|
Expect.equals(2, b.bar(2));
|
|
Expect.equals(100, b.nonAbstractBar(0));
|
|
|
|
var aExtends = AExtends();
|
|
Expect.equals(0, aExtends.nonAbstractFoo);
|
|
Expect.equals(0, aExtends.foo);
|
|
Expect.equals(0, aExtends.bar(0));
|
|
Expect.equals(0, aExtends.nonAbstractBar(0));
|
|
|
|
var aImplements = AImplements();
|
|
Expect.equals(0, aImplements.nonAbstractFoo);
|
|
Expect.equals(0, aImplements.foo);
|
|
Expect.equals(0, aImplements.bar(0));
|
|
Expect.equals(0, aImplements.nonAbstractBar(0));
|
|
|
|
Expect.equals(0, EnumInside.x.index);
|
|
}
|