Skip to content

Commit

Permalink
[tests] Language tests for errors when implementing a 2.19 class that…
Browse files Browse the repository at this point in the history
… implements a core library base or final class.

Bug: #52078
Change-Id: If97895b9560475f11e8236de87ad5880bdee97c3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/300880
Reviewed-by: Lasse Nielsen <[email protected]>
Commit-Queue: Kallen Tu <[email protected]>
  • Loading branch information
kallentu authored and Commit Queue committed May 4, 2023
1 parent 33ab02b commit 95565e2
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@

/// Test the invalid uses of a base class defined in a different library
import 'dart:collection';
import "shared_library_definitions.dart" show SimpleClass, BaseClass;
import 'shared_library_definitions_legacy.dart' show LegacyImplementBaseCore;

mixin _MixinOnObject {}

Expand Down Expand Up @@ -467,6 +469,14 @@ base mixin BaseMixinImplement implements BaseClass {}
// [analyzer] COMPILE_TIME_ERROR.INVALID_USE_OF_TYPE_OUTSIDE_LIBRARY
// [cfe] The class 'BaseClass' can't be implemented outside of its library because it's a base class.

// Implementing a legacy class that implements a core library base class.

abstract class LegacyImplement<E extends LinkedListEntry<E>>
implements LegacyImplementBaseCore<E> {}
// ^^^^^^^^^^^^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.INVALID_USE_OF_TYPE_OUTSIDE_LIBRARY
// [cfe] unspecified

/// It is an error if BaseClass is the `on` type of something which is not base.
mixin SimpleMixinOn on BaseClass {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
/// Test the invalid uses of a final class defined in a different library
import "shared_library_definitions.dart" show FinalClass, SimpleClass;
import 'shared_library_definitions_legacy.dart' show LegacyImplementFinalCore;

mixin _MixinOnObject {}

Expand Down Expand Up @@ -184,6 +185,17 @@ 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.

// Implementing a legacy class that implements a core library final class.

class LegacyImplement implements LegacyImplementFinalCore {
// ^^^^^^^^^^^^^^^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
int get key => 0;
int get value => 1;
String toString() => "Bad";
}

// It is an error if FinalClass is the `on` type of a mixin outside of
// FinalClass' library.

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// 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

// @dart=2.19

import 'dart:collection';

/// Legacy library which defines some classes and mixins to be used to test
/// behaviors across libraries.
abstract class LegacyImplementBaseCore<E extends LinkedListEntry<E>>
implements LinkedList<E> {}

class LegacyImplementFinalCore implements MapEntry<int, int> {
int get key => 0;
int get value => 1;
String toString() => "Bad";
}

0 comments on commit 95565e2

Please sign in to comment.