From 58e0b77bd6cb8bc634b37bb0090f982b0359d780 Mon Sep 17 00:00:00 2001 From: Tess Strickland Date: Wed, 20 May 2026 06:04:16 -0700 Subject: [PATCH] [vm,dyn_modules] Fix source reports for enhanced enums with bytecode. Coverage information for enhanced enums should not include initializer functions for enum elements or the values field, so skip over these when the enum is defined in bytecode. TEST=vm/cc/SourceReport_Coverage_IssueCov386_EnhancedEnums Cq-Include-Trybots: luci.dart.try:vm-dyn-linux-debug-x64-try,vm-aot-dyn-linux-debug-x64-try,vm-aot-dyn-linux-product-x64-try Change-Id: I1dba3c87fdfcc39762bba5f0c35cfd061ec76371 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/504240 Commit-Queue: Tess Strickland Reviewed-by: Alexander Markov --- runtime/vm/source_report.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/runtime/vm/source_report.cc b/runtime/vm/source_report.cc index ab8d4837095..96b87bf45b0 100644 --- a/runtime/vm/source_report.cc +++ b/runtime/vm/source_report.cc @@ -202,6 +202,16 @@ bool SourceReport::ShouldSkipField(const Field& field) { return true; } } + + // Static const fields from compiled code will not have an initializer + // function, just an implicit static getter (which is skipped). + // Static const fields in bytecode _do_ have initializer functions, + // though, so skip them to ensure they aren't reported in the coverage + // information so as to match coverage for compile code. + if (field.is_static() && field.is_const()) { + return true; + } + return false; }