Skip to content

Commit

Permalink
Version 3.3.0-277.0.dev
Browse files Browse the repository at this point in the history
Merge f34bdc2 into dev
  • Loading branch information
Dart CI committed Jan 3, 2024
2 parents 7e9f7ea + f34bdc2 commit c5a75ac
Show file tree
Hide file tree
Showing 19 changed files with 239 additions and 103 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,15 @@

[lints-3-0]: https://pub.dev/packages/lints/changelog#300


#### Wasm compiler (dart2wasm)

- **Breaking Change** [#54004][]: `dart:js_util`, `package:js`, and `dart:js`
are now disallowed from being imported when compiling with `dart2wasm`. Prefer
using `dart:js_interop` and `dart:js_interop_unsafe`.

[#54004]: https://github.com/dart-lang/sdk/issues/54004

#### Development JavaScript compiler (DDC)

- Type arguments of `package:js` interop types are now printed as `any` instead
Expand Down
16 changes: 8 additions & 8 deletions DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ vars = {
"boringssl_gen_rev": "a468ba9fec3f59edf46a7db98caaca893e1e4d96",
"boringssl_rev": "74646566e93de7551bfdfc5f49de7462f13d1d05",
"browser-compat-data_tag": "ac8cae697014da1ff7124fba33b0b4245cc6cd1b", # v1.0.22
"devtools_rev": "071405a237dab931ea10be728ec188aa2d55111f",
"devtools_rev": "226af81369622cce9c0d98adbe31598208a27cc0",
"icu_rev": "81d656878ec611cb0b42d52c82e9dae93920d9ba",
"jinja2_rev": "2222b31554f03e62600cd7e383376a7c187967a1",
"libcxx_rev": "44079a4cc04cdeffb9cfe8067bfb3c276fb2bab0",
Expand All @@ -120,16 +120,16 @@ vars = {
"args_rev": "46d5033377d277d70bc6ec68504730b9384b1db1",
"async_rev": "992457079da78dede35a56257d698288c467dc91",
"bazel_worker_rev": "3d9cd5823fc96872b7275fe99a4fabc4dcfe57c8",
"benchmark_harness_rev": "e59f675ae00578e46a283d5868b36e4554398309",
"benchmark_harness_rev": "a62e4169c120ac04b1f5bfdf8f14346459529781",
"boolean_selector_rev": "caea8d41cab1b7f4cc3c86d15a27c011ab01766b",
"browser_launcher_rev": "c68ec25e36187b050ac918d2b614f2d6320f0045",
"characters_rev": "7633a16a22c626e19ca750223237396315268a06",
"cli_util_rev": "500dffab6e00332c4c0b814359f06c8a9c3a5573",
"cli_util_rev": "e5b38ac76887e6eefaf417f5222c317929eed278",
"clock_rev": "f975668839f45bad561d6227f88297bbbcff03fa",
"collection_rev": "2d57a82ad079fe2d127f5a9b188170de2f5cdedc",
"convert_rev": "35031701fab532ada1a75c51155c0a6801055d88",
"crypto_rev": "f3e64d234416466683e29a4b20cf751684cbae6a",
"csslib_rev": "17346e528b19c09b2d20589e0ffa0f01a5ad54ad",
"convert_rev": "f8a72d67a10805bca358be8d7e189a62f79d86b9",
"crypto_rev": "63e9a90c97d216bfd6e3ce72e80df320ef84572a",
"csslib_rev": "1ad2d1ec461fb1836180e917220a5a48fd641897",
# Note: Updates to dart_style have to be coordinated with the infrastructure
# team so that the internal formatter `tools/sdks/dart-sdk/bin/dart format`
# matches the version here. Please follow this process to make updates:
Expand All @@ -142,7 +142,7 @@ vars = {
# For more details, see https://github.com/dart-lang/sdk/issues/30164.
"dart_style_rev": "8b1f24a8475a0116757172cd9acca4acbf87d973", # disable rev_sdk_deps.dart
"dartdoc_rev": "3ce64a3d7da6702a4342bdfd0723b750fddeb35a", # https://github.com/dart-lang/dartdoc/issues/3562
"ecosystem_rev": "ce707fbb45e54cd2b353f33d3849f4b10a262850",
"ecosystem_rev": "dc44e820d0cbe943192bec1e0499aa176463b91f",
"ffi_rev": "c926657618443ff4821411ede01684096b503f84",
"file_rev": "cd3a9324f6483f313ba1f0f3ff382ea4e6982ef2",
"fixnum_rev": "3e08c0d7ce1a0cd832a17391444898ec610b5f89",
Expand All @@ -153,7 +153,7 @@ vars = {
"http_multi_server_rev": "ae484896624cee8b0a8a97a0fb1ea323c4c3d31f",
"http_parser_rev": "224c1a9d24b46c7a9da1f09147e0e1fbda78089d",
"intl_rev": "5d65e3808ce40e6282e40881492607df4e35669f",
"json_rpc_2_rev": "460545c62d12c2cd4635054e327846628288cb7e",
"json_rpc_2_rev": "ac1fabddd51fc90aa6fa4e1248f1a7141899eb4a",
"leak_tracker_rev": "8644f8b1c78009e9149e08e0c349d06c304110a9",
"lints_rev": "3810f8b3dc3205cfaa4ccc0054b021e68046d851",
"logging_rev": "324a0b5fd2b49b80ea4fbe2b48aac7794000e25a",
Expand Down
61 changes: 32 additions & 29 deletions pkg/_fe_analyzer_shared/lib/src/messages/codes_generated.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8570,6 +8570,38 @@ const MessageCode messageJsInteropDartJsInteropAnnotationForStaticInteropOnly =
correctionMessage:
r"""Try making this class an extension type or marking it as '@staticInterop'.""");

// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Template<
Message Function(String name)>
templateJsInteropDisallowedInteropLibraryInDart2Wasm =
const Template<Message Function(String name)>(
"JsInteropDisallowedInteropLibraryInDart2Wasm",
problemMessageTemplate:
r"""JS interop library '#name' can't be imported when compiling to Wasm.""",
correctionMessageTemplate:
r"""Try using 'dart:js_interop' or 'dart:js_interop_unsafe' instead.""",
withArguments:
_withArgumentsJsInteropDisallowedInteropLibraryInDart2Wasm);

// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Code<Message Function(String name)>
codeJsInteropDisallowedInteropLibraryInDart2Wasm =
const Code<Message Function(String name)>(
"JsInteropDisallowedInteropLibraryInDart2Wasm",
);

// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
Message _withArgumentsJsInteropDisallowedInteropLibraryInDart2Wasm(
String name) {
if (name.isEmpty) throw 'No name provided';
name = demangleMixinApplicationName(name);
return new Message(codeJsInteropDisallowedInteropLibraryInDart2Wasm,
problemMessage:
"""JS interop library '${name}' can't be imported when compiling to Wasm.""",
correctionMessage: """Try using 'dart:js_interop' or 'dart:js_interop_unsafe' instead.""",
arguments: {'name': name});
}

// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Code<Null> codeJsInteropEnclosingClassJSAnnotation =
messageJsInteropEnclosingClassJSAnnotation;
Expand Down Expand Up @@ -9329,35 +9361,6 @@ Message _withArgumentsJsInteropStaticInteropWithNonStaticSupertype(
arguments: {'name': name, 'name2': name2});
}

// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Template<Message Function(String name)>
templateJsInteropStrictModeForbiddenLibrary =
const Template<Message Function(String name)>(
"JsInteropStrictModeForbiddenLibrary",
problemMessageTemplate:
r"""Library '#name' is forbidden when strict mode is enabled.""",
correctionMessageTemplate:
r"""Remove the import of a forbidden library.""",
withArguments: _withArgumentsJsInteropStrictModeForbiddenLibrary);

// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Code<Message Function(String name)>
codeJsInteropStrictModeForbiddenLibrary =
const Code<Message Function(String name)>(
"JsInteropStrictModeForbiddenLibrary",
);

// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
Message _withArgumentsJsInteropStrictModeForbiddenLibrary(String name) {
if (name.isEmpty) throw 'No name provided';
name = demangleMixinApplicationName(name);
return new Message(codeJsInteropStrictModeForbiddenLibrary,
problemMessage:
"""Library '${name}' is forbidden when strict mode is enabled.""",
correctionMessage: """Remove the import of a forbidden library.""",
arguments: {'name': name});
}

// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Template<
Message Function(String name)> templateLabelNotFound = const Template<
Expand Down
71 changes: 58 additions & 13 deletions pkg/_js_interop_checks/lib/js_interop_checks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import 'package:_fe_analyzer_shared/src/messages/codes.dart'
messageJsInteropStaticInteropParameterInitializersAreIgnored,
messageJsInteropStaticInteropSyntheticConstructor,
templateJsInteropDartClassExtendsJSClass,
templateJsInteropDisallowedInteropLibraryInDart2Wasm,
templateJsInteropJSClassExtendsDartClass,
templateJsInteropNonStaticWithStaticInteropSupertype,
templateJsInteropStaticInteropNoJSAnnotation,
Expand All @@ -36,8 +37,7 @@ import 'package:_fe_analyzer_shared/src/messages/codes.dart'
templateJsInteropNativeClassInAnnotation,
templateJsInteropStaticInteropTearOffsDisallowed,
templateJsInteropStaticInteropTrustTypesUsageNotAllowed,
templateJsInteropStaticInteropTrustTypesUsedWithoutStaticInterop,
templateJsInteropStrictModeForbiddenLibrary;
templateJsInteropStaticInteropTrustTypesUsedWithoutStaticInterop;
import 'package:_fe_analyzer_shared/src/messages/severity.dart' show Severity;
import 'package:_js_interop_checks/src/transformations/export_checker.dart';
import 'package:_js_interop_checks/src/transformations/js_util_optimizer.dart';
Expand Down Expand Up @@ -71,7 +71,6 @@ class JsInteropChecks extends RecursiveVisitor {
bool _classHasJSAnnotation = false;
bool _classHasAnonymousAnnotation = false;
bool _classHasStaticInteropAnnotation = false;
final _checkDisallowedInterop = false;
bool _inTearoff = false;
bool _libraryHasDartJSInteropAnnotation = false;
bool _libraryHasJSAnnotation = false;
Expand All @@ -92,11 +91,44 @@ class JsInteropChecks extends RecursiveVisitor {
RegExp(r'(?<!generated_)tests/lib/js'),
];

/// Libraries that cannot be used when [_enforceStrictMode] is true.
static const _disallowedLibrariesInStrictMode = [
static final List<Pattern>
_allowedUseOfDart2WasmDisallowedInteropLibrariesTestPatterns = [
// Benchmarks.
RegExp(r'BigIntParsePrint/dart/native_version_javascript.dart'),
RegExp(r'JSInterop/dart/jsinterop_lib.dart'),
// Tests.
RegExp(r'(?<!generated_)tests/lib/js/export'),
// Negative lookahead to test the violation.
RegExp(
r'(?<!generated_)tests/lib/js/static_interop_test(?!/disallowed_interop_libraries_test.dart)'),
RegExp(r'(?<!generated_)tests/web/wasm'),
// Flutter tests.
RegExp(r'flutter/lib/web_ui/test'),
];

// TODO(srujzs): Help migrate some of these away. Once we're done, we can
// remove `dart:*` interop libraries from the check as they can be moved out
// of `libraries.json`.
static const _allowedInteropLibrariesInDart2WasmPackages = [
// Both these packages re-export other interop libraries
'js',
'js_util',
// Flutter/benchmarks.
'flute',
'flutter',
'engine',
'ui',
// Non-SDK packages that have been migrated for the Wasm experiment but
// still have references to older interop libraries.
'package_info_plus',
'test',
'url_launcher_web',
];

/// Interop libraries that cannot be used in dart2wasm.
static const _disallowedInteropLibrariesInDart2Wasm = [
'package:js/js.dart',
'package:js/js_util.dart',
'dart:html',
'dart:js_util',
'dart:js'
];
Expand Down Expand Up @@ -285,10 +317,7 @@ class JsInteropChecks extends RecursiveVisitor {
_libraryHasDartJSInteropAnnotation || hasJSInteropAnnotation(node);
_libraryIsGlobalNamespace = _isLibraryGlobalNamespace(node);

// TODO(srujzs): Should we still keep around this check? Currently, it's
// unused since we allow the old interop on dart2wasm, but we should
// disallow them eventually.
if (_checkDisallowedInterop) _checkDisallowedLibrariesForDart2Wasm(node);
if (isDart2Wasm) _checkDisallowedLibrariesForDart2Wasm(node);

super.visitLibrary(node);
exportChecker.visitLibrary(node);
Expand Down Expand Up @@ -504,12 +533,28 @@ class JsInteropChecks extends RecursiveVisitor {

// JS interop library checks

/// Check that [node] doesn't depend on any disallowed interop libraries in
/// dart2wasm.
///
/// We allowlist `dart:*` libraries, select packages, and test patterns.
void _checkDisallowedLibrariesForDart2Wasm(Library node) {
final uri = node.importUri;
for (final dependency in node.dependencies) {
final dependencyUriString = dependency.targetLibrary.importUri.toString();
if (_disallowedLibrariesInStrictMode.contains(dependencyUriString)) {
if (_disallowedInteropLibrariesInDart2Wasm
.contains(dependencyUriString)) {
// TODO(srujzs): While we allow these imports for all `dart:*`
// libraries, we may want to restrict this further, as it may include
// `dart:ui`.
final allowedToImport = uri.isScheme('dart') ||
(uri.isScheme('package') &&
_allowedInteropLibrariesInDart2WasmPackages
.any((pkg) => uri.pathSegments.first == pkg)) ||
_allowedUseOfDart2WasmDisallowedInteropLibrariesTestPatterns
.any((pattern) => uri.path.contains(pattern));
if (allowedToImport) return;
_reporter.report(
templateJsInteropStrictModeForbiddenLibrary
templateJsInteropDisallowedInteropLibraryInDart2Wasm
.withArguments(dependencyUriString),
dependency.fileOffset,
dependencyUriString.length,
Expand Down Expand Up @@ -582,7 +627,7 @@ class JsInteropChecks extends RecursiveVisitor {
/// a dart low level library, a foreign helper, a native test,
/// or a from environment constructor.
bool _isAllowedExternalUsage(Member member) {
Uri uri = member.enclosingLibrary.importUri;
final uri = member.enclosingLibrary.importUri;
return uri.isScheme('dart') &&
_pathsWithAllowedDartExternalUsage.contains(uri.path) ||
_allowedNativeTestPatterns.any((pattern) => uri.path.contains(pattern));
Expand Down
11 changes: 1 addition & 10 deletions pkg/analyzer/lib/src/lint/linter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,7 @@ import 'package:analyzer/src/dart/element/inheritance_manager3.dart';
import 'package:analyzer/src/dart/element/type_system.dart';
import 'package:analyzer/src/error/codes.dart';
import 'package:analyzer/src/generated/engine.dart'
show
AnalysisErrorInfo,
AnalysisErrorInfoImpl,
AnalysisOptions,
AnalysisOptionsImpl;
show AnalysisErrorInfo, AnalysisErrorInfoImpl, AnalysisOptions;
import 'package:analyzer/src/generated/resolver.dart' show ScopeResolverVisitor;
import 'package:analyzer/src/lint/analysis.dart';
import 'package:analyzer/src/lint/io.dart';
Expand Down Expand Up @@ -314,11 +310,6 @@ class LinterContextImpl implements LinterContext {
'`currentUnit.unit.declaredElement?.session`.')
DeclaredVariables get declaredVariables => _declaredVariables;

bool get strictCasts =>
// TODO(pq): update when there's a better API to access strictCasts.
// ignore: deprecated_member_use_from_same_package
(analysisOptions as AnalysisOptionsImpl).strictCasts;

@override
bool canBeConst(Expression expression) {
if (expression is InstanceCreationExpressionImpl) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ class KernelCompilationService {

static _SdkPaths _computeSdkPaths() {
// Check for google3.
final runFiles = io.Platform.environment['RUNFILES'];
final runFiles = io.Platform.environment['TEST_SRCDIR'];
if (runFiles != null) {
final aotRuntimePath = io.Platform.environment['AOT_RUNTIME_PATH']!;
final frontServerPath = io.Platform.environment['FRONTEND_SERVER_PATH']!;
Expand Down
2 changes: 1 addition & 1 deletion pkg/analyzer_utilities/lib/package_root.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ String get packageRoot {
// Try google3 environment. We expect that all packages that will be
// accessed via this root are configured in the BUILD file, and located
// inside this single root.
final runFiles = Platform.environment['RUNFILES'];
final runFiles = Platform.environment['TEST_SRCDIR'];
final analyzerPackagesRoot = Platform.environment['ANALYZER_PACKAGES_ROOT'];
if (runFiles != null && analyzerPackagesRoot != null) {
return pathos.join(runFiles, analyzerPackagesRoot);
Expand Down
23 changes: 22 additions & 1 deletion pkg/dds/lib/src/dap/isolate_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1157,6 +1157,19 @@ class ThreadInfo with FileUtils {
if (results == null) {
// If no result, all of the results are null.
completers.forEach((uri, completer) => completer.complete(null));
} else if (results.length != requiredUris.length) {
// If the lengths of the lists are different, we have an invalid
// response from the VM. This is a bug in the VM/VM Service:
// https://github.com/dart-lang/sdk/issues/52632

final reason =
results.length > requiredUris.length ? 'more' : 'fewer';
final message =
'lookupResolvedPackageUris result contained $reason results than '
'the request. See https://github.com/dart-lang/sdk/issues/52632';
final error = Exception(message);
completers
.forEach((uri, completer) => completer.completeError(error));
} else {
// Otherwise, complete each one by index with the corresponding value.
results.map(_convertUriToFilePath).forEachIndexed((i, result) {
Expand All @@ -1167,7 +1180,15 @@ class ThreadInfo with FileUtils {
} catch (e) {
// We can't leave dangling completers here because others may already
// be waiting on them, so propagate the error to them.
completers.forEach((uri, completer) => completer.completeError(e));
completers.forEach((uri, completer) {
// Only complete if not already completed. It's possible an exception
// occurred above inside the loop and that some of the completers have
// already completed. We don't want to replace a good exception with
// "Future already completed".
if (!completer.isCompleted) {
completer.completeError(e);
}
});

// Don't rethrow here, because it will cause these completers futures
// to not have error handlers attached which can cause their errors to
Expand Down
31 changes: 31 additions & 0 deletions pkg/dds/test/dap/integration/debug_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,37 @@ main() {
expect(proc!.exitCode, completes);
});

test('runs a simple script with commas in the filename', () async {
final packageUri = await dap.createFooPackage('foo,foo.dart');
final testFile = dap.createTestFile(
'''
import '$packageUri';
void main() {
foo();
}
''',
);

final outputEvents = await dap.client.collectOutput(
launch: () => dap.client.launch(
testFile.path,
args: ['one', 'two'],
),
);

// Expect the normal applications output. This means we set up the
// debugger without crashing, even though we imported files with commas
// in the name.
final output = outputEvents.skip(1).map((e) => e.output).join();
expectLines(output, [
'Hello!',
'World!',
'args: [one, two]',
'',
'Exited.',
]);
}, skip: 'Fails because of https://github.com/dart-lang/sdk/issues/52632');

test('does not resume isolates if user passes --pause-isolates-on-exit',
() async {
// Internally we always pass --pause-isolates-on-exit and resume the
Expand Down
Loading

0 comments on commit c5a75ac

Please sign in to comment.