mergeFeatureSet function

Map<String, String> mergeFeatureSet(
  1. Map<String, String> base,
  2. Map<String, Object?>? overrides,
  3. int edition
)

Merges overrides onto a copy of base using protobuf MergeFrom semantics: a present override key replaces the base value; an absent feature keeps the base value (later-set-wins, unset-leaves-prior). base is not mutated — a new map is returned.

Setting a feature that is FIXED at edition is a hard error (matches protoc, which rejects overriding a non-overridable feature). This is the single MergeFrom primitive shared by file- and child-level resolution.

Implementation

Map<String, String> mergeFeatureSet(
  Map<String, String> base,
  Map<String, Object?>? overrides,
  int edition,
) {
  final result = <String, String>{};
  _putAll(result, base);
  _applyOverrides(result, overrides, edition);
  return result;
}