[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: https://github.com/dart-lang/sdk/issues/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>
This commit is contained in:
committed by
Commit Queue
parent
52fb3eb37d
commit
1125460f2e
@@ -227,9 +227,11 @@ class BytecodeGenerator extends RecursiveVisitor {
|
||||
if (source == null) {
|
||||
final importUri =
|
||||
objectTable.getConstStringHandle(astSource.importUri.toString());
|
||||
// Use asMember instead of asConstructor because some const
|
||||
// constructors from extension types are desugared to procedures.
|
||||
final coveredConstConstructors = astSource
|
||||
.constantCoverageConstructors
|
||||
?.map((r) => objectTable.getHandle(r.asConstructor)!)
|
||||
?.map((r) => objectTable.getHandle(r.asMember)!)
|
||||
.toList();
|
||||
source = new SourceFile(importUri, coveredConstConstructors);
|
||||
bytecodeComponent.sourceFiles.add(source);
|
||||
|
||||
@@ -334,7 +334,8 @@ void BytecodeReaderHelper::ReadCoveredConstConstructors(const Script& script,
|
||||
auto& function = Function::Handle(Z);
|
||||
for (intptr_t i = 0; i < len; i++) {
|
||||
function ^= ReadObject();
|
||||
ASSERT(function.IsConstructor() && function.is_const());
|
||||
// Const constructors from extension types can be desugared into procedures.
|
||||
ASSERT(function.IsFunction() && function.is_const());
|
||||
constant_coverage.SetAt(i, function);
|
||||
}
|
||||
script.set_collected_constant_coverage(constant_coverage);
|
||||
|
||||
@@ -341,7 +341,7 @@ void SourceReport::PrintCoverageData(JSONObject* jsobj,
|
||||
const Script& script = Script::Handle(zone(), function.script());
|
||||
|
||||
bool const_constructor_hit = false;
|
||||
if (function.IsConstructor() && function.is_const()) {
|
||||
if (function.IsFunction() && function.is_const()) {
|
||||
for (TokenPosition hit :
|
||||
script_table_entries_[script_index]->const_constructor_hits) {
|
||||
if (hit == begin_pos) {
|
||||
|
||||
Reference in New Issue
Block a user