mirror of
https://github.com/dart-lang/sdk
synced 2024-09-18 21:31:20 +00:00
[macros] Fix _checkForKernelRuntime.
The previous implementation always returns "true", making the PR a no-op as it only does something for AOT runtimes. e2e test coverage will land in https://dart-review.googlesource.com/c/sdk/+/353100 to prevent such mistakes in future. R=johnniwinther@google.com Change-Id: I8481187070a0af12a3f3bd77baa471f1a7d3256d Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/355682 Reviewed-by: Johnni Winther <johnniwinther@google.com> Auto-Submit: Morgan :) <davidmorgan@google.com> Commit-Queue: Morgan :) <davidmorgan@google.com>
This commit is contained in:
parent
823592363f
commit
a4e15669ec
|
@ -3,6 +3,7 @@
|
|||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'dart:isolate';
|
||||
import 'dart:typed_data';
|
||||
|
||||
/// Whether the current runtime can register kernel blobs and launch kernel
|
||||
/// isolates.
|
||||
|
@ -11,10 +12,17 @@ bool get isKernelRuntime => _isKernelRuntime ??= _checkForKernelRuntime();
|
|||
bool? _isKernelRuntime;
|
||||
|
||||
bool _checkForKernelRuntime() {
|
||||
// `createUriForKernelBlob` throws `UnsupportedError` if kernel blobs are not
|
||||
// supported at all. We don't actually want to register kernel so pass
|
||||
// invalid kernel, an empty list, resulting in an `ArgumentError` if kernel
|
||||
// blobs are supported.
|
||||
try {
|
||||
(Isolate.current as dynamic).createUriForKernelBlob;
|
||||
return true;
|
||||
} catch (_) {
|
||||
(Isolate.current as dynamic)
|
||||
.createUriForKernelBlob(new Uint8List.fromList(const []));
|
||||
throw new StateError('Expected failure.');
|
||||
} on UnsupportedError {
|
||||
return false;
|
||||
} on ArgumentError {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
"Dynamic invocation of 'split'.": 1
|
||||
},
|
||||
"pkg/_fe_analyzer_shared/lib/src/util/runtimes.dart": {
|
||||
"Dynamic access of 'createUriForKernelBlob'.": 1
|
||||
"Dynamic invocation of 'createUriForKernelBlob'.": 1
|
||||
},
|
||||
"pkg/front_end/lib/src/macros/isolate_macro_serializer.dart": {
|
||||
"Dynamic invocation of 'unregisterKernelBlobUri'.": 1,
|
||||
|
|
Loading…
Reference in a new issue