Skip to content

Commit 081211f

Browse files
alexmarkovCommit Queue
authored andcommitted
[vm,dyn_modules] Fix parameter names for closures declared in bytecode
TEST=existing (e.g. language/vm/regress_32502_test) Change-Id: I2ea118aa34046a52c7c0d648e60f0d928c7702f5 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428620 Reviewed-by: Slava Egorov <[email protected]> Commit-Queue: Alexander Markov <[email protected]>
1 parent 4cd2c1d commit 081211f

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

runtime/vm/bytecode_reader.cc

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ void BytecodeReaderHelper::ReadClosureDeclaration(const Function& function,
314314

315315
auto& signature = FunctionType::Handle(Z, closure.signature());
316316
signature = ReadFunctionSignature(
317-
signature, (flags & kHasOptionalPositionalParamsFlag) != 0,
317+
signature, closure, (flags & kHasOptionalPositionalParamsFlag) != 0,
318318
(flags & kHasOptionalNamedParamsFlag) != 0,
319319
(flags & kHasTypeParamsFlag) != 0,
320320
/* has_positional_param_names = */ true,
@@ -325,6 +325,7 @@ void BytecodeReaderHelper::ReadClosureDeclaration(const Function& function,
325325

326326
FunctionTypePtr BytecodeReaderHelper::ReadFunctionSignature(
327327
const FunctionType& signature,
328+
const Function& closure_function,
328329
bool has_optional_positional_params,
329330
bool has_optional_named_params,
330331
bool has_type_params,
@@ -351,6 +352,11 @@ FunctionTypePtr BytecodeReaderHelper::ReadFunctionSignature(
351352
signature.set_parameter_types(
352353
Array::Handle(Z, Array::New(num_params, Heap::kOld)));
353354
signature.CreateNameArrayIncludingFlags(Heap::kOld);
355+
#if !defined(DART_PRECOMPILED_RUNTIME)
356+
if (has_positional_param_names) {
357+
closure_function.CreateNameArray();
358+
}
359+
#endif
354360

355361
intptr_t i = 0;
356362
signature.SetParameterTypeAt(i, AbstractType::dynamic_type());
@@ -364,6 +370,10 @@ FunctionTypePtr BytecodeReaderHelper::ReadFunctionSignature(
364370
name ^= ReadObject();
365371
if (has_optional_named_params && (i >= num_required_params)) {
366372
signature.SetParameterNameAt(i, name);
373+
#if !defined(DART_PRECOMPILED_RUNTIME)
374+
} else {
375+
closure_function.SetParameterNameAt(i, name);
376+
#endif
367377
}
368378
}
369379
type ^= ReadObject();
@@ -1354,7 +1364,8 @@ ObjectPtr BytecodeReaderHelper::ReadType(intptr_t tag,
13541364
Z, FunctionType::New(num_parent_type_args, nullability));
13551365
// TODO(alexmarkov): skip type finalization
13561366
return ReadFunctionSignature(
1357-
signature_type, (flags & kFlagHasOptionalPositionalParams) != 0,
1367+
signature_type, Function::null_function(),
1368+
(flags & kFlagHasOptionalPositionalParams) != 0,
13581369
(flags & kFlagHasOptionalNamedParams) != 0,
13591370
(flags & kFlagHasTypeParams) != 0,
13601371
/* has_positional_param_names = */ false,

runtime/vm/bytecode_reader.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,7 @@ class BytecodeReaderHelper : public ValueObject {
317317

318318
void ReadClosureDeclaration(const Function& function, intptr_t closureIndex);
319319
FunctionTypePtr ReadFunctionSignature(const FunctionType& signature,
320+
const Function& closure_function,
320321
bool has_optional_positional_params,
321322
bool has_optional_named_params,
322323
bool has_type_params,

0 commit comments

Comments
 (0)