[cfe] Reset EnumConstantInfo.argumentsBeginToken

This avoids leaking Token through EnumConstantInfo.argumentsBeginToken
and allows us to verify that no leaks occur when compiling the sdk.

Change-Id: I0168471fbc6609147c671204d119d161833e7c5e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/329904
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
This commit is contained in:
Johnni Winther 2023-10-11 07:38:13 +00:00 committed by Commit Queue
parent 09f3eb0c8b
commit 96ae2c3cad
3 changed files with 22 additions and 6 deletions

View file

@ -740,6 +740,7 @@ class SourceEnumBuilder extends SourceClassBuilder {
arguments.positional.insertAll(0, enumSyntheticArguments);
arguments.argumentsOriginalOrder?.insertAll(0, enumSyntheticArguments);
enumConstantInfo.argumentsBeginToken = null;
} else {
arguments = new ArgumentsImpl(enumSyntheticArguments);
}

View file

@ -5,6 +5,7 @@
import "dart:developer" as developer;
import 'package:front_end/src/api_prototype/file_system.dart' as api;
import 'package:_fe_analyzer_shared/src/util/filenames.dart';
import 'package:front_end/src/fasta/dill/dill_target.dart';
import 'package:front_end/src/fasta/kernel/kernel_target.dart';
import 'package:front_end/src/fasta/kernel/macro/macro.dart';
@ -16,7 +17,9 @@ import "package:vm_service/vm_service_io.dart" as vmServiceIo;
import 'compiler_test_helper.dart';
import 'vm_service_helper.dart';
Future<void> main() async {
Future<void> main(List<String> args) async {
args = args.toList();
bool compileSdk = !args.remove('--no-sdk');
developer.ServiceProtocolInfo serviceProtocolInfo =
await developer.Service.getInfo();
bool startedServiceProtocol = false;
@ -36,11 +39,13 @@ Future<void> main() async {
VmService serviceClient = await vmServiceIo.vmServiceConnectUri(wsUriString);
await compile(
inputs: [
Uri.base.resolve('pkg/front_end/test/token_leak_test_helper.dart'),
],
// TODO(johnniwinther): Enable sdk compilation.
compileSdk: false,
inputs: args.isNotEmpty
? args.map(nativeToUri).toList()
: [
Uri.base
.resolve('pkg/front_end/test/token_leak_test_helper.dart'),
],
compileSdk: compileSdk,
kernelTargetCreator: (api.FileSystem fileSystem,
bool includeComments,
DillTarget dillTarget,

View file

@ -30,3 +30,13 @@ class Class {
factory Class.fact3() = self.Class;
factory Class.fact4() = self.Class.named;
}
enum E {
a(0),
b(1),
;
final int value;
const E(this.value);
}