Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed unsound null safety options from classes ModuleMetadata and MetadataProvider #2509

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dwds/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

- Replace deprecated JS code `this.__proto__` with `Object.getPrototypeOf(this)`. - [#2500](https://github.com/dart-lang/webdev/pull/2500)
- Migrate injected client code to `package:web`. - [#2491](https://github.com/dart-lang/webdev/pull/2491)
- Removed unsound null safety options from classes ModuleMetadata, MetadataProvider & Metadata_test. - [#2427](https://github.com/dart-lang/webdev/issues/2427)

## 24.1.0

Expand Down
11 changes: 2 additions & 9 deletions dwds/lib/src/debugging/metadata/module_metadata.dart
Original file line number Diff line number Diff line change
Expand Up @@ -114,18 +114,13 @@ class ModuleMetadata {
/// Module uri
final String moduleUri;

/// True if the module corresponding to this metadata was compiled with sound
/// null safety enabled.
final bool soundNullSafety;

final Map<String, LibraryMetadata> libraries = {};

ModuleMetadata(
this.name,
this.closureName,
this.sourceMapUri,
this.moduleUri,
this.soundNullSafety, {
this.moduleUri, {
String? ver,
}) {
version = ver ?? ModuleMetadataVersion.current.version;
Expand All @@ -151,8 +146,7 @@ class ModuleMetadata {
name = _readRequiredField(json, 'name'),
closureName = _readRequiredField(json, 'closureName'),
sourceMapUri = _readRequiredField(json, 'sourceMapUri'),
moduleUri = _readRequiredField(json, 'moduleUri'),
soundNullSafety = _readOptionalField(json, 'soundNullSafety') ?? false {
moduleUri = _readRequiredField(json, 'moduleUri') {
if (!ModuleMetadataVersion.current.isCompatibleWith(version) &&
!ModuleMetadataVersion.previous.isCompatibleWith(version)) {
throw Exception('Unsupported metadata version $version. '
Expand All @@ -174,7 +168,6 @@ class ModuleMetadata {
'sourceMapUri': sourceMapUri,
'moduleUri': moduleUri,
'libraries': [for (final lib in libraries.values) lib.toJson()],
'soundNullSafety': soundNullSafety,
};
}
}
Expand Down
16 changes: 2 additions & 14 deletions dwds/lib/src/debugging/metadata/provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ class MetadataProvider {
final AssetReader _assetReader;
final _logger = Logger('MetadataProvider');
final String entrypoint;
bool _soundNullSafety;
final List<String> _libraries = [];
final Map<String, String> _scriptToModule = {};
final Map<String, String> _moduleToSourceMap = {};
Expand Down Expand Up @@ -65,15 +64,14 @@ class MetadataProvider {
'dart:ui',
];

MetadataProvider(this.entrypoint, this._assetReader)
: _soundNullSafety = false;
MetadataProvider(this.entrypoint, this._assetReader);

/// A sound null safety mode for the whole app.
///
/// All libraries have to agree on null safety mode.
Future<bool> get soundNullSafety async {
await _initialize();
return _soundNullSafety;
return true;
}

/// A list of all libraries in the Dart application.
Expand Down Expand Up @@ -178,8 +176,6 @@ class MetadataProvider {

Future<void> _initialize() async {
await _metadataMemoizer.runOnce(() async {
var hasSoundNullSafety = true;
var hasUnsoundNullSafety = true;
// The merged metadata resides next to the entrypoint.
// Assume that <name>.bootstrap.js has <name>.ddc_merged_metadata
if (entrypoint.endsWith('.bootstrap.js')) {
Expand All @@ -199,22 +195,14 @@ class MetadataProvider {
final metadata =
ModuleMetadata.fromJson(moduleJson as Map<String, dynamic>);
_addMetadata(metadata);
hasUnsoundNullSafety &= !metadata.soundNullSafety;
hasSoundNullSafety &= metadata.soundNullSafety;
_logger
.fine('Loaded debug metadata for module: ${metadata.name}');
} catch (e) {
_logger.warning('Failed to read metadata: $e');
rethrow;
}
}
if (!hasSoundNullSafety && !hasUnsoundNullSafety) {
throw Exception('Metadata contains modules with mixed null safety');
}
_soundNullSafety = hasSoundNullSafety;
}
_logger.info('Loaded debug metadata '
'(${_soundNullSafety ? "sound" : "weak"} null safety)');
}
});
}
Expand Down
3 changes: 1 addition & 2 deletions dwds/test/metadata_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void main() {
await provider.libraries,
contains('org-dartlang-app:///web/main.dart'),
);
expect(await provider.soundNullSafety, false);
expect(await provider.soundNullSafety, true);
});

test('throws on metadata with absolute import uris', () async {
Expand Down Expand Up @@ -114,6 +114,5 @@ void main() {
expect(parts.length, 1);
expect(parts[0], 'org-dartlang-app:///web/main.dart');
}
expect(metadata.soundNullSafety, false);
});
}
Loading