Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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)
- Deprecated MetadataProvider's soundNullSafety'. - [#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
19 changes: 5 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,17 @@ 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.
@Deprecated(
'This field is deprecated. Use sound null safety enforcement instead.',
)
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 +179,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 +198,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
8 changes: 2 additions & 6 deletions dwds/lib/src/services/chrome_proxy_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -204,13 +204,9 @@ class ChromeProxyService implements VmServiceInterface {
final moduleFormat = loadStrategy.moduleFormat;
final canaryFeatures = loadStrategy.buildSettings.canaryFeatures;
final experiments = loadStrategy.buildSettings.experiments;
final soundNullSafety = true;

// TODO(annagrin): Read null safety setting from the build settings.
final metadataProvider = loadStrategy.metadataProviderFor(entrypoint);
final soundNullSafety = await metadataProvider.soundNullSafety;

_logger.info('Initializing expression compiler for $entrypoint '
'with sound null safety: $soundNullSafety');
_logger.info('Initializing expression compiler for $entrypoint');

final compilerOptions = CompilerOptions(
moduleFormat: ModuleFormat.values.byName(moduleFormat),
Expand Down
23 changes: 0 additions & 23 deletions dwds/test/metadata_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,6 @@ const _emptySourceMetadata =
'"fileUri":"org-dartlang-app:///web/main.dart","partUris":[]}]}\n'
'// intentionally empty: package blah has no dart sources';

const _noNullSafetyMetadata =
'{"version":"1.0.0","name":"web/main","closureName":"load__web__main",'
'"sourceMapUri":"foo/web/main.ddc.js.map",'
'"moduleUri":"foo/web/main.ddc.js",'
'"libraries":[{"name":"main",'
'"importUri":"org-dartlang-app:///web/main.dart",'
'"fileUri":"org-dartlang-app:///web/main.dart","partUris":[]}]}\n'
'// intentionally empty: package blah has no dart sources';

const _fileUriMetadata =
'{"version":"1.0.0","name":"web/main","closureName":"load__web__main",'
'"sourceMapUri":"foo/web/main.ddc.js.map",'
Expand All @@ -57,19 +48,6 @@ void main() {
await provider.libraries,
contains('org-dartlang-app:///web/main.dart'),
);
expect(await provider.soundNullSafety, isNotNull);
});

test('can parse metadata with no null safety information', () async {
final provider = MetadataProvider(
'foo.bootstrap.js',
FakeAssetReader(metadata: _noNullSafetyMetadata),
);
expect(
await provider.libraries,
contains('org-dartlang-app:///web/main.dart'),
);
expect(await provider.soundNullSafety, false);
});

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