Skip to content

Commit

Permalink
Version 3.5.0-0.0.dev
Browse files Browse the repository at this point in the history
Merge b6137f7 into dev
  • Loading branch information
Dart CI committed Mar 28, 2024
2 parents bb65648 + b6137f7 commit 5f2b04b
Show file tree
Hide file tree
Showing 35 changed files with 282 additions and 85 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
## 3.5.0

## 3.4.0

### Language
Expand Down
10 changes: 5 additions & 5 deletions DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ vars = {
"download_reclient": True,

# Update from https://chrome-infra-packages.appspot.com/p/fuchsia/sdk/core
"fuchsia_sdk_version": "version:18.20240208.2.1",
"fuchsia_sdk_version": "version:19.20240327.2.1",
"download_fuchsia_deps": False,

# Ninja, runs the build based on files generated by GN.
Expand All @@ -102,7 +102,7 @@ vars = {
"boringssl_rev": "d24a38200fef19150eef00cad35b138936c08767",
"browser-compat-data_tag": "ac8cae697014da1ff7124fba33b0b4245cc6cd1b", # v1.0.22
"cpu_features_rev": "936b9ab5515dead115606559502e3864958f7f6e",
"devtools_rev": "7421a2d5d67cbcdec92f1a2ac993b8b64b28d7ca",
"devtools_rev": "05714bd031819a53ebddf1e30678b50e733168f0",
"icu_rev": "81d656878ec611cb0b42d52c82e9dae93920d9ba",
"jinja2_rev": "2222b31554f03e62600cd7e383376a7c187967a1",
"libcxx_rev": "44079a4cc04cdeffb9cfe8067bfb3c276fb2bab0",
Expand Down Expand Up @@ -144,14 +144,14 @@ vars = {
#
# For more details, see https://github.com/dart-lang/sdk/issues/30164.
"dart_style_rev": "a6ad7693555a9add6f98ad6fd94de80d35c89415", # disable tools/rev_sdk_deps.dart
"dartdoc_rev": "79c1675956f74b4e3f44134879beeb230a84bcd1",
"dartdoc_rev": "bf6080c8a12bf3a2f29f517d152bbd5fa1bb0a37",
"ecosystem_rev": "5a900ca68466efe8680d3500bc0a6172d07ef5a7",
"file_rev": "3aa06490bf34bddf04c7ea964a50c177a4ca0de7",
"fixnum_rev": "570b28adcfbfdd5b8a7230ea1d6ec0f9587493f1",
"flute_rev": "a531c96a8b43d015c6bfbbfe3ab54867b0763b8b",
"glob_rev": "379d60c7cc5c0e9fe7d0d45549ad0b1ca51396c8",
"html_rev": "327e37a6a4dd46599737ee982f280d73a8f646f7",
"http_rev": "7949d6f4a60bb5e9158da52910aa6bacda6b9286",
"http_rev": "280d3615a2d248d155e87766c9d9bcf586af2c3c",
"http_multi_server_rev": "ba9d07f3596b24718ddf45c9e071d40879cca565",
"http_parser_rev": "84db8b029d9b51859a0bb4966859af009f9442e3",
"intl_rev": "5d65e3808ce40e6282e40881492607df4e35669f",
Expand Down Expand Up @@ -186,7 +186,7 @@ vars = {
"test_descriptor_rev": "35f97afacb2b7fe627f6ed0bede722fd48980848",
"test_process_rev": "7fe39afbb6c444f256c1ec0eef008edebcd44644",
"test_reflective_loader_rev": "9862703a3d14848376c8efde271c88022fba91eb",
"tools_rev": "f611290b530123ee2f0a3fda7c440d85dd080a30",
"tools_rev": "f611290b530123ee2f0a3fda7c440d85dd080a30", # https://github.com/dart-lang/tools/pull/247
"typed_data_rev": "375efaa02a13dad0785cfbd9bdcb9f09aa8ef529",
"usage_rev": "67ecd7d1328347ec15cbf8d8a46918df75a66af8",
"vector_math_rev": "7e705f734e94917e9a5347578e6e496f8db38ac6",
Expand Down
2 changes: 1 addition & 1 deletion pkg/_fe_analyzer_shared/lib/src/experiments/flags.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//
// Instead modify 'tools/experimental_features.yaml' and run
// 'dart pkg/front_end/tool/fasta.dart generate-experimental-flags' to update.
const Version defaultLanguageVersion = const Version(3, 4);
const Version defaultLanguageVersion = const Version(3, 5);

/// Enum for experimental flags shared between the CFE and the analyzer.
enum ExperimentalFlag {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,21 @@ class AddCallSuper extends ResolvedCorrectionProducer {
_addition = '$name($argumentList)';

if (body is BlockFunctionBody) {
await _block(builder, body);
await _block(builder, body.block);
} else if (body is ExpressionFunctionBody) {
await _expression(builder, body);
}
}

Future<void> _block(ChangeBuilder builder, BlockFunctionBody body) async {
var location = utils.prepareNewStatementLocation(body.block, true);

Future<void> _block(ChangeBuilder builder, Block block) async {
await builder.addDartFileEdit(file, (builder) {
builder.addInsertion(location.offset, (builder) {
builder.write(location.prefix);
builder.write('super.$_addition;');
builder.write(location.suffix);
builder.addInsertion(block.leftBracket.end, (builder) {
builder.writeln();
builder.write('${builder.getIndent(2)}super.$_addition;');
if (block.statements.isEmpty) {
builder.writeln();
builder.write(builder.getIndent(1));
}
});
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,33 @@ class UseEffectiveIntegerDivision extends ResolvedCorrectionProducer {
@override
Future<void> compute(ChangeBuilder builder) async {
for (var n in node.withParents) {
if (n is MethodInvocation) {
if (n.offset == errorOffset && n.length == errorLength) {
var target = n.target;
if (target != null) {
target = target.unParenthesized;
await builder.addDartFileEdit(file, (builder) {
// replace "/" with "~/"
var binary = target as BinaryExpression;
builder.addSimpleReplacement(range.token(binary.operator), '~/');
// remove everything before and after
builder.addDeletion(range.startStart(n, binary.leftOperand));
builder.addDeletion(range.endEnd(binary.rightOperand, n));
});
if (n is! MethodInvocation) continue;
if (n.offset != errorOffset && n.length != errorLength) continue;

var target = n.target;
if (target != null) {
target = target.unParenthesized;
await builder.addDartFileEdit(file, (builder) {
// Replace `/` with `~/`.
var binary = target as BinaryExpression;
builder.addSimpleReplacement(range.token(binary.operator), '~/');
var parentOfToIntInvocation = n.parent;
if (parentOfToIntInvocation is Expression &&
parentOfToIntInvocation.precedence >= binary.precedence) {
// Wrap the new `~/` binary expression in parentheses if needed.
builder.addSimpleReplacement(
range.startStart(n, binary.leftOperand), '(');
builder.addSimpleReplacement(
range.endEnd(binary.rightOperand, n), ')');
} else {
// Remove everything before and after.
builder.addDeletion(range.startStart(n, binary.leftOperand));
builder.addDeletion(range.endEnd(binary.rightOperand, n));
}
// done
break;
}
});
}
// Done.
break;
}
}
}
23 changes: 0 additions & 23 deletions pkg/analysis_server/lib/src/services/correction/util.dart
Original file line number Diff line number Diff line change
Expand Up @@ -992,29 +992,6 @@ final class CorrectionUtils {
member is MethodDeclaration);
}

/// Return the location of a new statement in the given [block], as the
/// first statement if [first] is `true`, or the last one if `false`.
InsertionLocation prepareNewStatementLocation(Block block, bool first) {
var statements = block.statements;
var empty = statements.isEmpty;
var last = empty || first ? block.leftBracket : statements.last;

var linePrefix = getLinePrefix(last.offset);
String prefix;
String suffix;
if (empty) {
prefix = endOfLine + linePrefix + oneIndent;
suffix = endOfLine + linePrefix;
} else if (first) {
prefix = endOfLine + linePrefix + oneIndent;
suffix = '';
} else {
prefix = endOfLine + linePrefix;
suffix = '';
}
return InsertionLocation(prefix: prefix, offset: last.end, suffix: suffix);
}

/// Returns the source with indentation changed from [oldIndent] to
/// [newIndent], keeping indentation of lines relative to each other.
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,52 @@ void f(Stream<String> args) {
A.m();
B.m();
}
''');
}

Future<void> test_organizePathImports_thatSpanTwoLines() async {
newFile('$testPackageLibPath/a.dart', '''
class A {
static void m() {}
}
''');
newFile('$testPackageLibPath/a/b.dart', '''
class B {
static void m() {}
}
''');
newFile('$testPackageLibPath/a/c.dart', '''
class C {
static void m() {}
}
''');

await resolveTestCode('''
import 'dart:async';
import 'a/b.dart';
import 'a.dart'
show A;
import 'a/c.dart';
void f(Stream<String> args) {
A.m();
B.m();
C.m();
}
''');
await assertHasFix('''
import 'dart:async';
import 'a.dart'
show A;
import 'a/b.dart';
import 'a/c.dart';
void f(Stream<String> args) {
A.m();
B.m();
C.m();
}
''');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class UseEffectiveIntegerDivisionMultiTest extends BulkFixProcessorTest {
void f() {
var a = 5;
var b = 2;
print((a / ((a / b).toInt())).toInt());
print((a / (a / b).toInt()).toInt());
}
''');
await assertHasFix('''
Expand All @@ -31,6 +31,23 @@ void f() {
var b = 2;
print(a ~/ (a ~/ b));
}
''');
}

Future<void> test_singleFile_extraParentheses() async {
await resolveTestCode('''
void f() {
var a = 5;
var b = 2;
print((a / ((a / b).toInt())).toInt());
}
''');
await assertHasFix('''
void f() {
var a = 5;
var b = 2;
print(a ~/ ((a ~/ b)));
}
''');
}
}
Expand All @@ -54,6 +71,34 @@ void f() {
var b = 2;
print(a ~/ b);
}
''');
}

Future<void> test_normalDivision_targetOfCascadedPropertyAccess() async {
await resolveTestCode('''
void f() {
(1 / 2).toInt()..isEven;
}
''');
// This is surprising, but... `1 ~/ 2..isEven` is parsed the same as
// `(1 ~/ 2)..isEven`.
await assertHasFix('''
void f() {
1 ~/ 2..isEven;
}
''');
}

Future<void> test_normalDivision_targetOfMethodCall() async {
await resolveTestCode('''
void f() {
(1 / 2).toInt().toString();
}
''');
await assertHasFix('''
void f() {
(1 ~/ 2).toString();
}
''');
}
}
2 changes: 1 addition & 1 deletion pkg/analyzer/lib/src/dart/analysis/experiments.g.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ part of 'experiments.dart';

/// The current version of the Dart language (or, for non-stable releases, the
/// version of the language currently in the process of being developed).
const _currentVersion = '3.4.0';
const _currentVersion = '3.5.0';

/// A map containing information about all known experimental flags.
final _knownFeatures = <String, ExperimentalFeature>{
Expand Down
5 changes: 3 additions & 2 deletions pkg/analyzer/lib/src/dart/ast/ast.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6059,8 +6059,9 @@ abstract final class Expression implements CollectionElement {
/// Return the precedence of this expression.
///
/// The precedence is a positive integer value that defines how the source
/// code is parsed into an AST. For example `a * b + c` is parsed as `(a * b)
/// + c` because the precedence of `*` is greater than the precedence of `+`.
/// code is parsed into an AST. For example `a * b + c` is parsed as
/// `(a * b) + c` because the precedence of `*` is greater than the precedence
/// of `+`.
Precedence get precedence;

/// If this expression is an argument to an invocation, and the AST structure
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class DartEditBuilderImpl extends EditBuilderImpl implements DartEditBuilder {
return DartLinkedEditBuilderImpl(this);
}

/// Returns the indentation with the given [level].
@override
String getIndent(int level) => ' ' * level;

@override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ abstract class DartEditBuilder implements EditBuilder {
/// The logic is the same as the one used in [writeType]
bool canWriteType(DartType? type, {ExecutableElement? methodBeingCopied});

/// Returns the indentation with the given [level].
String getIndent(int level);

/// Write the code for a declaration of a class with the given [name]. If a
/// list of [interfaces] is provided, then the class will implement those
/// interfaces. If [isAbstract] is `true`, then the class will be abstract. If
Expand Down
2 changes: 1 addition & 1 deletion pkg/kernel/lib/default_language_version.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@

import "ast.dart";

const Version defaultLanguageVersion = const Version(3, 4);
const Version defaultLanguageVersion = const Version(3, 5);
9 changes: 9 additions & 0 deletions runtime/vm/compiler/backend/flow_graph_compiler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "vm/longjump.h"
#include "vm/object_store.h"
#include "vm/parser.h"
#include "vm/pointer_tagging.h"
#include "vm/raw_object.h"
#include "vm/resolver.h"
#include "vm/service_isolate.h"
Expand Down Expand Up @@ -3192,6 +3193,14 @@ void RangeErrorSlowPath::EmitSharedStubCall(FlowGraphCompiler* compiler,
#endif
}

void WriteErrorSlowPath::PushArgumentsForRuntimeCall(
FlowGraphCompiler* compiler) {
LocationSummary* locs = instruction()->locs();
__ PushRegister(locs->in(CheckWritableInstr::kReceiver).reg());
__ PushImmediate(
compiler::target::ToRawSmi(instruction()->AsCheckWritable()->kind()));
}

void WriteErrorSlowPath::EmitSharedStubCall(FlowGraphCompiler* compiler,
bool save_fpu_registers) {
#if defined(TARGET_ARCH_IA32)
Expand Down
6 changes: 6 additions & 0 deletions runtime/vm/compiler/backend/flow_graph_compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,12 @@ class WriteErrorSlowPath : public ThrowErrorSlowPathCode {

virtual void EmitSharedStubCall(FlowGraphCompiler* compiler,
bool save_fpu_registers);

virtual void PushArgumentsForRuntimeCall(FlowGraphCompiler* compiler);

virtual intptr_t GetNumberOfArgumentsForRuntimeCall() {
return 2; // receiver, kind
}
};

class LateInitializationErrorSlowPath : public ThrowErrorSlowPathCode {
Expand Down
5 changes: 5 additions & 0 deletions runtime/vm/compiler/backend/il.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6814,6 +6814,11 @@ intptr_t CheckArrayBoundInstr::LengthOffsetFor(intptr_t class_id) {
}

Definition* CheckWritableInstr::Canonicalize(FlowGraph* flow_graph) {
if (kind_ == Kind::kDeeplyImmutableAttachNativeFinalizer) {
return this;
}

ASSERT(kind_ == Kind::kWriteUnmodifiableTypedData);
intptr_t cid = value()->Type()->ToCid();
if ((cid != kIllegalCid) && (cid != kDynamicCid) &&
!IsUnmodifiableTypedDataViewClassId(cid)) {
Expand Down
Loading

0 comments on commit 5f2b04b

Please sign in to comment.