Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 1125460

Browse files
sstricklCommit Queue
authored and
Commit Queue
committed
[vm,dyn_modules] Allow desugared const constructors.
The front end may desugar some const constructors into procedures, so be less strict with what is expected in the list of const constructors. Also updates SourceReport to check all Functions with is_const() true against the collected const constructor hits and not just Constructors. TEST=ci Fixes: #61947 Cq-Include-Trybots: luci.dart.try:vm-dyn-linux-debug-x64-try,vm-dyn-mac-debug-arm64-try Change-Id: I092938eeeb0459de9b3d95400a538ec6528c43fe Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/462442 Reviewed-by: Alexander Markov <alexmarkov@google.com> Commit-Queue: Tess Strickland <sstrickl@google.com>
1 parent 52fb3eb commit 1125460

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

‎pkg/dart2bytecode/lib/bytecode_generator.dart‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,11 @@ class BytecodeGenerator extends RecursiveVisitor {
227227
if (source == null) {
228228
final importUri =
229229
objectTable.getConstStringHandle(astSource.importUri.toString());
230+
// Use asMember instead of asConstructor because some const
231+
// constructors from extension types are desugared to procedures.
230232
final coveredConstConstructors = astSource
231233
.constantCoverageConstructors
232-
?.map((r) => objectTable.getHandle(r.asConstructor)!)
234+
?.map((r) => objectTable.getHandle(r.asMember)!)
233235
.toList();
234236
source = new SourceFile(importUri, coveredConstConstructors);
235237
bytecodeComponent.sourceFiles.add(source);

‎runtime/vm/bytecode_reader.cc‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,8 @@ void BytecodeReaderHelper::ReadCoveredConstConstructors(const Script& script,
334334
auto& function = Function::Handle(Z);
335335
for (intptr_t i = 0; i < len; i++) {
336336
function ^= ReadObject();
337-
ASSERT(function.IsConstructor() && function.is_const());
337+
// Const constructors from extension types can be desugared into procedures.
338+
ASSERT(function.IsFunction() && function.is_const());
338339
constant_coverage.SetAt(i, function);
339340
}
340341
script.set_collected_constant_coverage(constant_coverage);

‎runtime/vm/source_report.cc‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ void SourceReport::PrintCoverageData(JSONObject* jsobj,
341341
const Script& script = Script::Handle(zone(), function.script());
342342

343343
bool const_constructor_hit = false;
344-
if (function.IsConstructor() && function.is_const()) {
344+
if (function.IsFunction() && function.is_const()) {
345345
for (TokenPosition hit :
346346
script_table_entries_[script_index]->const_constructor_hits) {
347347
if (hit == begin_pos) {

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /