Files
sdk/pkg/dart2bytecode/testcases/invisible.dart
T
Tess Strickland db8563d4d6 [vm,dyn_modules] Recognize the vm:invisible pragma.
Adds a new isInvisible flag for both FunctionDeclarations and
ClosureDeclarations and sets it if the function or closure declaration
is annotated with @pragma('vm:invisible'). This way, function visibility
is appropriately recorded even if options.emitAnnotations is false.

The bytecode reader checks for the isInvisible flag when reading
FunctionDeclarations and ClosureDeclarations and appropriately
sets the is_visible flag for the Function object accordingly.

TEST=pkg/dart2bytecode/test/bytecode_generator_test
     vm/dart/invisible_function_pragma_test

Cq-Include-Trybots: luci.dart.try:vm-dyn-linux-debug-x64-try
Change-Id: If435afbe5e74adc022ce064784b6b3e5e8a88164
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/486381
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2026-03-09 10:16:02 -07:00

49 lines
873 B
Dart

// Copyright (c) 2026, 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.
class A {
A.visible(void Function() fun) {
print('A.visible');
fun();
}
@pragma('vm:invisible')
A.invisible(void Function() fun) {
print('A.invisible');
fun();
}
}
void visible(void Function() fun) {
print('visible()');
fun();
}
@pragma('vm:invisible')
void invisible(void Function() fun) {
print('invisible()');
fun();
}
void visibleClosure(void Function() fun) {
visibleInner() {
print('visibleInner');
fun();
}
visibleInner();
}
void invisibleClosure(void Function() fun) {
@pragma('vm:invisible')
invisibleInner() {
print('invisibleInner');
fun();
}
invisibleInner();
}
main() {}