Files
sdk/pkg/dynamic_modules/test/data/enum/modules/entry1.dart
T
Alexander Markov 9ee6b090a4 [dyn_modules] Allow dynamic modules to use and override public members of _Enum
Private class _Enum is an implementation detail of Dart enums, so
we should not require users to explicitly expose it through dynamic
interface in order to use enums in the dynamic modules.

This change adds pragmas to make all public members of _Enum callable
and allows _Enum.toString() to be overridden in dynamic modules.

TEST=pkg/dynamic_modules/test/data/enum

CoreLibraryReviewExempt: no API changes, only pragmas.
Bug: b/448593948
Change-Id: I37040d4912d6da38fbf568c11ae0834a110d3a46
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/452880
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2025-10-01 11:36:12 -07:00

25 lines
512 B
Dart

// Copyright (c) 2025, 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.
enum Foo { e1, e2, e3 }
enum Bar {
e1('E1'),
e2('E2');
final String str;
const Bar(this.str);
@override
String toString() => str;
}
@pragma('dyn-module:entry-point')
Object? dynamicModuleEntrypoint() => [
Foo.e2,
Foo.values[0].index,
Foo.values[2].toString(),
Bar.e1,
];