Skip to content

Commit

Permalink
Version 3.5.0-300.0.dev
Browse files Browse the repository at this point in the history
Merge ee5881b into dev
  • Loading branch information
Dart CI committed Jun 25, 2024
2 parents 38bb74f + ee5881b commit 713ec11
Show file tree
Hide file tree
Showing 22 changed files with 270 additions and 81 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,16 @@

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

#### `dart:js_interop`

- **Breaking Change** [#55508][]: `importModule` now accepts a `JSAny` instead
of a `String` to support other JS values as well, like `TrustedScriptURL`s.
- **Breaking Change** [#55267][]: `isTruthy` and `not` now return `JSBoolean`
instead of `bool` to be consistent with the other operators.

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

### Tools

#### Linter
Expand Down
4 changes: 2 additions & 2 deletions DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ vars = {
# Checked-in SDK version. The checked-in SDK is a Dart SDK distribution
# in a cipd package used to run Dart scripts in the build and test
# infrastructure, which is automatically built on the release commits.
"sdk_tag": "version:3.4.0-247.0.dev",
"sdk_tag": "version:3.5.0-278.0.dev",

# co19 is a cipd package automatically generated for each co19 commit.
# Use tests/co19/update.sh to update this hash.
Expand Down Expand Up @@ -190,7 +190,7 @@ vars = {
"typed_data_rev": "85299290551297a28202b6e7a177bb787f790ffd",
"vector_math_rev": "e7b11a234638bd5d76a05bae99d20b937637dfe8",
"watcher_rev": "c00fc2a6cd869cdebbc52e00af3d912d25745729",
"web_rev": "2fe754fb396cb9b87010f0318cfbfc5408346c48",
"web_rev": "6b8a46561b82de9b20d77d9ac491844d303ca08f",
"web_socket_channel_rev": "bf69990738f173c07e67cf6945551194bc8c2d92",
"webdev_rev": "c56611255f3f02642da10750448a8c90a9fa7b47",
"webdriver_rev": "f85779edd7c9f66198d4391ed3631db1d97a5b11",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,9 @@ class InScopeCompletionPass extends SimpleAstVisitor<void> {
declarationHelper(
preferNonInvocation: true,
).addConstructorNamesForElement(element: element);
declarationHelper(
preferNonInvocation: true,
).addStaticMembersOfElement(element);
}
} else {
var type = node.type.type;
Expand Down
5 changes: 0 additions & 5 deletions pkg/analysis_server/test/lsp/completion_dart_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2757,12 +2757,7 @@ void f() { }
expect(updated, contains('a.abcdefghij'));
}

@FailingTest(reason: 'https://github.com/Dart-Code/Dart-Code/issues/4794')
Future<void> test_prefixed_enumMember() async {
// If the first character of the enum member is typed (`self.MyEnum.o^`)
// this test passes. Without any characters typed (`self.MyEnum.^`) the
// dotTarget on the completion is `null`. The containingNode is a
// ConstructorName.
var content = '''
import 'main.dart' as self;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,32 @@ suggestions
''');
}

Future<void> test_importPrefix_dot_enumConstantName() async {
allowedIdentifiers = {'foo01', 'foo02'};
newFile('$testPackageLibPath/a.dart', r'''
enum E0 {
foo01,
foo02;
}
''');

await computeSuggestions('''
import 'a.dart' as p0;
void f() {
p0.E0.^
}
''');

assertResponse(r'''
suggestions
foo01
kind: enumConstant
foo02
kind: enumConstant
''');
}

Future<void> test_nothing() async {
_configureWithMyEnum();

Expand Down
26 changes: 26 additions & 0 deletions pkg/analyzer/doc/implementation/experiment_flags.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Experiment flags

If you're implementing a language feature, then it needs to have an accompanying
experiment flag. (Or multiple experiments if it's going to be enabled over the
course of multiple releases.)

## Adding an experiment flag

Experiment flags are shared across all of the tools, so they are defined in a
single location. To add a new flag, edit
[`experimental_features.yaml`](https://github.com/dart-lang/sdk/blob/main/tools/experimental_features.yaml).
The initial commit is only required to define the name and to include a `help:`
key.

To generate the declarations used by the analyzer, run
`dart pkg/analyzer/tool/experiments/generate.dart`.

To generate the declarations used by the front-end, run
`dart pkg/front_end/tool/fasta.dart generate-experimental-flags`.

## Summary representation

The set of (the indexes of) enabled experiments is used to build the hash for
[summary files](summaries.md). If defining the new experiment flag changes the
indexes of existing experiment flags, then the value of the static field
`AnalysisDriver.DATA_VERSION` needs to be incremented.
1 change: 1 addition & 0 deletions pkg/analyzer/doc/process/new_language_feature.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Separate issues should be created for each of the items in the list.
The following is a list of the individual features that need to be considered.
The features are listed roughly in dependency order.

- [ ] If needed, add an experiment flag
- [ ] AST enhancements (`AstBuilder`)
- [ ] Resolution of directives
- [ ] Element model
Expand Down
51 changes: 51 additions & 0 deletions pkg/dds/test/control_web_server_starts_dds_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'dart:convert';
import 'dart:developer';
import 'dart:io';

import 'package:test/test.dart';
import 'package:vm_service/vm_service.dart';
import 'package:vm_service/vm_service_io.dart';

void main() {
HttpClient? client;
VmService? service;

tearDown(() async {
client?.close();
await service?.dispose();
});

test('Enabling the VM service starts DDS and serves DevTools', () async {
var serviceInfo = await Service.getInfo();
expect(serviceInfo.serverUri, isNull);

serviceInfo = await Service.controlWebServer(
enable: true,
silenceOutput: true,
);
expect(serviceInfo.serverUri, isNotNull);
expect(serviceInfo.serverWebSocketUri, isNotNull);
service = await vmServiceConnectUri(
serviceInfo.serverWebSocketUri!.toString(),
);

// Check that DDS has been launched.
final supportedProtocols =
(await service!.getSupportedProtocols()).protocols!;
expect(supportedProtocols.length, 2);
expect(supportedProtocols.map((e) => e.protocolName), contains('DDS'));

// Check that DevTools assets are accessible.
client = HttpClient();
final devtoolsRequest = await client!.getUrl(serviceInfo.serverUri!);
final devtoolsResponse = await devtoolsRequest.close();
expect(devtoolsResponse.statusCode, 200);
final devtoolsContent =
await devtoolsResponse.transform(utf8.decoder).join();
expect(devtoolsContent, startsWith('<!DOCTYPE html>'));
});
}
8 changes: 8 additions & 0 deletions pkg/vm/lib/transformations/type_flow/unboxing_info.dart
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,14 @@ class UnboxingInfoManager {
final inferredType = typeFlowAnalysis.getFieldValue(member).value;
if (member.hasSetter) {
_applyToArg(member, unboxingInfo, 0, inferredType);
// Arguments of implicit setters for covariant fields
// cannot be unboxed based on the field type as setter
// performs a type check before value is assigned to the field.
if (member.isCovariantByDeclaration) {
unboxingInfo.argsInfo.length = 0;
} else {
_applyToArg(member, unboxingInfo, 0, inferredType);
}
}
_applyToReturn(member, unboxingInfo, inferredType);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Uri? wsServerUri;

Future<Null> testeeBefore() async {
print('testee before');
// First grab the URL where the observatory is listening on and the
// First grab the URL where the VM service is listening and the
// service protocol version numbers. We expect the URL to be null as
// the server has not been started yet.
ServiceProtocolInfo info = await Service.getInfo();
Expand Down
29 changes: 29 additions & 0 deletions runtime/tests/vm/dart/regress_56051_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

// Regression test for https://github.com/dart-lang/sdk/issues/56051.

// VMOptions=--compiler-passes=-Inlining

import 'package:expect/expect.dart';

class Foo {
covariant late num a;
}

class Bar extends Foo {
@override
late int a;
}

void main() {
Foo bar = Bar();
bar.a = 2;
Expect.equals(2, bar.a);
Expect.throws(() {
bar.a = 3.14 as dynamic;
print('bar.a is now ${bar.a}');
});
print("success!");
}
6 changes: 4 additions & 2 deletions runtime/vm/compiler/frontend/scope_builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -300,15 +300,17 @@ ScopeBuildingResult* ScopeBuilder::BuildScopes() {
if (is_setter) {
if (CompilerState::Current().is_aot()) {
const intptr_t kernel_offset = field.kernel_offset();
const InferredTypeMetadata parameter_type =
const InferredTypeMetadata inferred_field_type =
inferred_type_metadata_helper_.GetInferredType(kernel_offset);
result_->setter_value = MakeVariable(
TokenPosition::kNoSource, TokenPosition::kNoSource,
Symbols::Value(),
AbstractType::ZoneHandle(Z, function.ParameterTypeAt(pos)),
LocalVariable::kNoKernelOffset, /*is_late=*/false,
/*inferred_type=*/nullptr,
/*inferred_arg_type=*/&parameter_type);
/*inferred_arg_type=*/field.is_covariant()
? nullptr
: &inferred_field_type);
} else {
result_->setter_value = MakeVariable(
TokenPosition::kNoSource, TokenPosition::kNoSource,
Expand Down
6 changes: 3 additions & 3 deletions sdk/lib/_internal/js_shared/lib/js_interop_patch.dart
Original file line number Diff line number Diff line change
Expand Up @@ -467,14 +467,14 @@ extension JSAnyOperatorExtension on JSAny? {

@patch
@pragma('dart2js:prefer-inline')
bool get not => js_util.not(this);
JSBoolean get not => js_util.not(this);

@patch
@pragma('dart2js:prefer-inline')
bool get isTruthy => js_util.isTruthy(this);
JSBoolean get isTruthy => JSBoolean._(js_util.isTruthy(this));
}

@patch
@pragma('dart2js:prefer-inline')
JSPromise<JSObject> importModule(String moduleName) =>
JSPromise<JSObject> importModule(JSAny moduleName) =>
foreign_helper.JS('', 'import(#)', moduleName);
76 changes: 34 additions & 42 deletions sdk/lib/_internal/vm/bin/vmservice_io.dart
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class _DebuggingSession {
bool disableServiceAuthCodes,
bool enableDevTools,
) async {
final dartDir = File(Platform.resolvedExecutable).parent.path;
final dartDir = File(Platform.executable).parent.path;
final executable = [
dartDir,
'dart${Platform.isWindows ? '.exe' : ''}',
Expand Down Expand Up @@ -133,15 +133,15 @@ class _DebuggingSession {
// is changed to ensure consistency.
const devToolsMessagePrefix =
'The Dart DevTools debugger and profiler is available at:';
print('$devToolsMessagePrefix $devToolsUri');
serverPrint('$devToolsMessagePrefix $devToolsUri');
}
if (result
case {
'dtd': {
'uri': String dtdUri,
}
} when _printDtd) {
print('The Dart Tooling Daemon (DTD) is available at: $dtdUri');
serverPrint('The Dart Tooling Daemon (DTD) is available at: $dtdUri');
}
} else {
printError(result['error'] ?? result);
Expand Down Expand Up @@ -308,18 +308,37 @@ Future<List<Map<String, dynamic>>> listFilesCallback(Uri dirPath) async {

Uri? serverInformationCallback() => _lazyServerBoot().serverAddress;

Future<void> _toggleWebServer(Server server) async {
// Toggle HTTP server.
if (server.running) {
await server.shutdown(true).then((_) async {
ddsInstance?.shutdown();
ddsInstance = null;
await VMService().clearState();
serverFuture = null;
});
} else {
await server.startup().then((_) async {
if (_waitForDdsToAdvertiseService) {
ddsInstance = _DebuggingSession();
await ddsInstance!.start(
_ddsIP,
_ddsPort.toString(),
_authCodesDisabled,
_serveDevtools,
);
}
});
}
}

Future<Uri?> webServerControlCallback(bool enable, bool? silenceOutput) async {
if (silenceOutput != null) {
silentObservatory = silenceOutput;
}
final _server = _lazyServerBoot();
if (_server.running != enable) {
if (enable) {
await _server.startup();
// TODO: if dds is enabled a dds instance needs to be started.
} else {
await _server.shutdown(true);
}
await _toggleWebServer(_server);
}
return _server.serverAddress;
}
Expand All @@ -329,32 +348,13 @@ void webServerAcceptNewWebSocketConnections(bool enable) {
_server.acceptNewWebSocketConnections = enable;
}

_onSignal(ProcessSignal signal) async {
Future<void> _onSignal(ProcessSignal signal) async {
if (serverFuture != null) {
// Still waiting.
return;
}
final _server = _lazyServerBoot();
// Toggle HTTP server.
if (_server.running) {
_server.shutdown(true).then((_) async {
ddsInstance?.shutdown();
await VMService().clearState();
serverFuture = null;
});
} else {
_server.startup().then((_) {
if (_waitForDdsToAdvertiseService) {
ddsInstance = _DebuggingSession()
..start(
_ddsIP,
_ddsPort.toString(),
_authCodesDisabled,
_serveDevtools,
);
}
});
}
final server = _lazyServerBoot();
await _toggleWebServer(server);
}

Timer? _registerSignalHandlerTimer;
Expand Down Expand Up @@ -400,18 +400,10 @@ main() {
// can be delivered and waiting loaders can be cancelled.
VMService();
if (_autoStart) {
assert(server == null);
final _server = _lazyServerBoot();
_server.startup().then((_) {
if (_waitForDdsToAdvertiseService) {
ddsInstance = _DebuggingSession()
..start(
_ddsIP,
_ddsPort.toString(),
_authCodesDisabled,
_serveDevtools,
);
}
});
assert(!_server.running);
_toggleWebServer(_server);
// It's just here to push an event on the event loop so that we invoke the
// scheduled microtasks.
Timer.run(() {});
Expand Down
Loading

0 comments on commit 713ec11

Please sign in to comment.