Skip to content

Commit 41c97b1

Browse files
committed
Remove unsound null safety options from classes ModuleMetadata and MetadataProvider
1 parent f1ba240 commit 41c97b1

File tree

3 files changed

+12
-21
lines changed

3 files changed

+12
-21
lines changed

dwds/lib/src/debugging/metadata/module_metadata.dart

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@ class ModuleMetadata {
114114
/// Module uri
115115
final String moduleUri;
116116

117-
/// True if the module corresponding to this metadata was compiled with sound
118-
/// null safety enabled.
117+
// Keep the soundNullSafety flag for backward compatibility
118+
@Deprecated('This field is deprecated as sound null safety is enforced.')
119119
final bool soundNullSafety;
120120

121121
final Map<String, LibraryMetadata> libraries = {};
@@ -124,8 +124,8 @@ class ModuleMetadata {
124124
this.name,
125125
this.closureName,
126126
this.sourceMapUri,
127-
this.moduleUri,
128-
this.soundNullSafety, {
127+
this.moduleUri, {
128+
this.soundNullSafety = true, // Default to true
129129
String? ver,
130130
}) {
131131
version = ver ?? ModuleMetadataVersion.current.version;
@@ -152,7 +152,9 @@ class ModuleMetadata {
152152
closureName = _readRequiredField(json, 'closureName'),
153153
sourceMapUri = _readRequiredField(json, 'sourceMapUri'),
154154
moduleUri = _readRequiredField(json, 'moduleUri'),
155-
soundNullSafety = _readOptionalField(json, 'soundNullSafety') ?? false {
155+
// Deprecated field still present for backward compatibility
156+
// Defaults to true if missing
157+
soundNullSafety = _readOptionalField(json, 'soundNullSafety') ?? true {
156158
if (!ModuleMetadataVersion.current.isCompatibleWith(version) &&
157159
!ModuleMetadataVersion.previous.isCompatibleWith(version)) {
158160
throw Exception('Unsupported metadata version $version. '
@@ -174,7 +176,6 @@ class ModuleMetadata {
174176
'sourceMapUri': sourceMapUri,
175177
'moduleUri': moduleUri,
176178
'libraries': [for (final lib in libraries.values) lib.toJson()],
177-
'soundNullSafety': soundNullSafety,
178179
};
179180
}
180181
}

dwds/lib/src/debugging/metadata/provider.dart

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ class MetadataProvider {
1515
final AssetReader _assetReader;
1616
final _logger = Logger('MetadataProvider');
1717
final String entrypoint;
18-
bool _soundNullSafety;
18+
@Deprecated('This field is deprecated as sound null safety is enforced.')
19+
final bool _soundNullSafety = true;
1920
final List<String> _libraries = [];
2021
final Map<String, String> _scriptToModule = {};
2122
final Map<String, String> _moduleToSourceMap = {};
@@ -65,8 +66,7 @@ class MetadataProvider {
6566
'dart:ui',
6667
];
6768

68-
MetadataProvider(this.entrypoint, this._assetReader)
69-
: _soundNullSafety = false;
69+
MetadataProvider(this.entrypoint, this._assetReader);
7070

7171
/// A sound null safety mode for the whole app.
7272
///
@@ -178,8 +178,6 @@ class MetadataProvider {
178178

179179
Future<void> _initialize() async {
180180
await _metadataMemoizer.runOnce(() async {
181-
var hasSoundNullSafety = true;
182-
var hasUnsoundNullSafety = true;
183181
// The merged metadata resides next to the entrypoint.
184182
// Assume that <name>.bootstrap.js has <name>.ddc_merged_metadata
185183
if (entrypoint.endsWith('.bootstrap.js')) {
@@ -199,22 +197,14 @@ class MetadataProvider {
199197
final metadata =
200198
ModuleMetadata.fromJson(moduleJson as Map<String, dynamic>);
201199
_addMetadata(metadata);
202-
hasUnsoundNullSafety &= !metadata.soundNullSafety;
203-
hasSoundNullSafety &= metadata.soundNullSafety;
204200
_logger
205201
.fine('Loaded debug metadata for module: ${metadata.name}');
206202
} catch (e) {
207203
_logger.warning('Failed to read metadata: $e');
208204
rethrow;
209205
}
210206
}
211-
if (!hasSoundNullSafety && !hasUnsoundNullSafety) {
212-
throw Exception('Metadata contains modules with mixed null safety');
213-
}
214-
_soundNullSafety = hasSoundNullSafety;
215207
}
216-
_logger.info('Loaded debug metadata '
217-
'(${_soundNullSafety ? "sound" : "weak"} null safety)');
218208
}
219209
});
220210
}

dwds/test/metadata_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ void main() {
6969
await provider.libraries,
7070
contains('org-dartlang-app:///web/main.dart'),
7171
);
72-
expect(await provider.soundNullSafety, false);
72+
expect(await provider.soundNullSafety, true);
7373
});
7474

7575
test('throws on metadata with absolute import uris', () async {
@@ -114,6 +114,6 @@ void main() {
114114
expect(parts.length, 1);
115115
expect(parts[0], 'org-dartlang-app:///web/main.dart');
116116
}
117-
expect(metadata.soundNullSafety, false);
117+
expect(metadata.soundNullSafety, true);
118118
});
119119
}

0 commit comments

Comments
 (0)