Skip to content

Commit

Permalink
Version 3.2.0-157.0.dev
Browse files Browse the repository at this point in the history
Merge 655687d into dev
  • Loading branch information
Dart CI committed Sep 13, 2023
2 parents b679f33 + 655687d commit 88297b5
Show file tree
Hide file tree
Showing 31 changed files with 664 additions and 140 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,13 @@ constraint][language version] lower bound to 3.2 or greater (`sdk: '^3.2.0'`).

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

#### Dart format

- Always split enum declarations containing a line comment.
- Fix regression in splitting type annotations with library prefixes.
- Support `--enable-experiment` command-line option to enable language
experiments.

#### Pub

- New option `dart pub upgrade --tighten` which will update dependencies' lower
Expand Down
4 changes: 2 additions & 2 deletions DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ vars = {
# https://fuchsia.googlesource.com/integration/+/HEAD/toolchain
# If there are problems with the toolchain, contact fuchsia-toolchain@.
"clang_version": "git_revision:6d667d4b261e81f325756fdfd5bb43b3b3d2451d",
"gn_version": "git_revision:e3978de3e8dafb50a2b11efa784e08699a43faf8",
"gn_version": "git_revision:991530ce394efb58fcd848195469022fa17ae126",

# Update from https://chrome-infra-packages.appspot.com/p/fuchsia/sdk/gn
"fuchsia_sdk_version": "version:12.20230407.0.1",
Expand Down Expand Up @@ -141,7 +141,7 @@ vars = {
# and land the review.
#
# For more details, see https://github.com/dart-lang/sdk/issues/30164.
"dart_style_rev": "2956b1a705953f880a5dae9d3a0969df0fc45e99", # disable rev_sdk_deps.dart
"dart_style_rev": "1a2def95a3c04dafd27b85d17e6e828bd4afa1a3", # disable rev_sdk_deps.dart
"dartdoc_rev": "dd28f4ce4135c019c9943ef6c27e10cdcfe6760c",
"ecosystem_rev": "e96fbdbf1135a9e41ef66eb23e6c35f41e0e05b7",
"ffi_rev": "d36e05af55293bcc511d6b3a99ea4b8cb69f6323",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,23 @@ class ExportCreator extends Transformer {
this._typeEnvironment, this._diagnosticReporter, this._exportChecker)
: _callMethodVarArgs = _typeEnvironment.coreTypes.index
.getTopLevelProcedure('dart:js_interop_unsafe',
'JSObjectUtilExtension|callMethodVarArgs'),
'JSObjectUnsafeUtilExtension|callMethodVarArgs'),
_createDartExport = _typeEnvironment.coreTypes.index
.getTopLevelProcedure('dart:js_util', 'createDartExport'),
_createStaticInteropMock = _typeEnvironment.coreTypes.index
.getTopLevelProcedure('dart:js_util', 'createStaticInteropMock'),
_functionToJS = _typeEnvironment.coreTypes.index.getTopLevelProcedure(
'dart:js_interop', 'FunctionToJSExportedDartFunction|get#toJS'),
_getProperty = _typeEnvironment.coreTypes.index.getTopLevelProcedure(
'dart:js_interop_unsafe', 'JSObjectUtilExtension|[]'),
'dart:js_interop_unsafe', 'JSObjectUnsafeUtilExtension|[]'),
_globalContext = _typeEnvironment.coreTypes.index
.getTopLevelProcedure('dart:js_interop', 'get:globalContext'),
_jsAny = _typeEnvironment.coreTypes.index
.getClass('dart:_js_types', 'JSAny'),
_jsObject = _typeEnvironment.coreTypes.index
.getClass('dart:_js_types', 'JSObject'),
_setProperty = _typeEnvironment.coreTypes.index.getTopLevelProcedure(
'dart:js_interop_unsafe', 'JSObjectUtilExtension|[]='),
'dart:js_interop_unsafe', 'JSObjectUnsafeUtilExtension|[]='),
_stringToJS = _typeEnvironment.coreTypes.index.getTopLevelProcedure(
'dart:js_interop', 'StringToJSString|get#toJS'),
_staticInteropMockValidator = StaticInteropMockValidator(
Expand Down Expand Up @@ -201,7 +201,7 @@ class ExportCreator extends Transformer {

// Get the global 'Object' property.
Expression getObjectProperty() => asJSObject(StaticInvocation(_getProperty,
Arguments([StaticGet(_globalContext), toJSString('Object')])))
Arguments([StaticGet(_globalContext), StringLiteral('Object')])))
..fileOffset = node.fileOffset;

// Get a fresh object literal, using the proto to create it if one was
Expand Down Expand Up @@ -240,9 +240,9 @@ class ExportCreator extends Transformer {
var exports = exportMap[exportName]!;
ExpressionStatement setProperty(
VariableGet jsObject, String propertyName, StaticInvocation jsValue) {
// `jsObject[propertyName.toJS] = jsValue`
// `jsObject[propertyName] = jsValue`
return ExpressionStatement(StaticInvocation(_setProperty,
Arguments([jsObject, toJSString(propertyName), jsValue])))
Arguments([jsObject, StringLiteral(propertyName), jsValue])))
..fileOffset = node.fileOffset
..parent = node.parent;
}
Expand All @@ -251,7 +251,7 @@ class ExportCreator extends Transformer {
// With methods, there's only one export per export name.
if (firstExport is Procedure &&
firstExport.kind == ProcedureKind.Method) {
// `jsExport[jsName.toJS] = dartMock.tearoffMethod.toJS`
// `jsExport[jsName] = dartMock.tearoffMethod.toJS`
block.add(setProperty(
VariableGet(jsExporter),
exportName,
Expand All @@ -276,15 +276,15 @@ class ExportCreator extends Transformer {
// The AST code looks like:
//
// ```
// getSetMap['get'.toJS] = () {
// getSetMap['get'] = () {
// return dartInstance.getter;
// }.toJS;
// ```
//
// in the case of a getter and:
//
// ```
// getSetMap['set'.toJS] = (val) {
// getSetMap['set'] = (val) {
// dartInstance.setter = val;
// }.toJS;
// ```
Expand Down
9 changes: 9 additions & 0 deletions pkg/analyzer/lib/src/dart/element/element.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1092,6 +1092,15 @@ class ConstructorElementImpl extends ExecutableElementImpl
InterfaceElement get enclosingElement =>
super.enclosingElement as InterfaceElementImpl;

@override
bool get hasLiteral {
if (super.hasLiteral) return true;
var enclosingElement = this.enclosingElement;
if (enclosingElement is! ExtensionTypeElement) return false;
return this == enclosingElement.primaryConstructor &&
enclosingElement.hasLiteral;
}

@override
bool get isConst {
return hasModifier(Modifier.CONST);
Expand Down
5 changes: 1 addition & 4 deletions pkg/analyzer/lib/src/error/best_practices_verifier.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1172,11 +1172,8 @@ class BestPracticesVerifier extends RecursiveAstVisitor<void> {
if (constructor == null) {
return;
}
var enclosingElement = constructor.enclosingElement;
if (!node.isConst &&
(constructor.hasLiteral ||
(enclosingElement is ExtensionTypeElement &&
enclosingElement.hasLiteral)) &&
constructor.hasLiteral &&
_linterContext.canBeConst(node)) {
// Echoing jwren's TODO from _checkForDeprecatedMemberUse:
// TODO(jwren) We should modify ConstructorElement.getDisplayName(), or
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,17 @@ E e = E.zero();
]);
}

test_usingNew_extensionType_nonConst() async {
await assertNoErrorsInCode(r'''
import 'package:meta/meta.dart';
@literal
extension type const E(int i) {
E.zero(): this(0);
}
E e = E.zero();
''');
}

test_usingNew_extensionType_primaryConstructor() async {
await assertErrorsInCode(r'''
import 'package:meta/meta.dart';
Expand Down
49 changes: 48 additions & 1 deletion pkg/compiler/lib/src/js/js.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,48 @@ CodeBuffer createCodeBuffer(Node node, CompilerOptions compilerOptions,

Dart2JSJavaScriptPrintingContext context = Dart2JSJavaScriptPrintingContext(
monitor, outBuffer, sourceInformationProcessor, annotationMonitor);

/// We defer deserialization of function bodies but maintain maps using
/// nodes as keys for source map generation. In order to ensure the map's
/// references are the same between printing and source map generation we
/// cache the contents of the deferred blocks during these two operations.
final deferredBlockCollector = _CollectDeferredBlocksAndSetCaches();
deferredBlockCollector.setCache(node);
Printer printer = Printer(options, context);
printer.visit(node);
sourceInformationProcessor.process(node, outBuffer);
deferredBlockCollector.clearCache();
return outBuffer;
}

class _CollectDeferredBlocksAndSetCaches extends BaseVisitorVoid {
final List<DeferredBlock> _blocks = [];

_CollectDeferredBlocksAndSetCaches();

void setCache(Node node) {
node.accept(this);
}

void clearCache() {
_blocks.forEach((block) => block._clearCache());
_blocks.clear();
}

@override
void visitBlock(Block node) {
if (node is DeferredBlock) {
if (!node._isCached) {
_blocks.add(node);
node._setCache();
super.visitBlock(node);
}
} else {
super.visitBlock(node);
}
}
}

class JavaScriptAnnotationMonitor {
const JavaScriptAnnotationMonitor();

Expand Down Expand Up @@ -268,8 +304,19 @@ class DeferredExpressionData {
/// Each time [statements] is invoked, the enclosed [Statement] list will be
/// deserialized so care should be taken to limit this.
class DeferredBlock extends Statement implements Block {
bool hit = false;
List<Statement> getLoaded() {
return _statements.loaded();
}

List<Statement>? _cached;

void _setCache() => _cached = getLoaded();
void _clearCache() => _cached = null;
bool get _isCached => _cached != null;

@override
List<Statement> get statements => _statements.loaded();
List<Statement> get statements => _cached ?? getLoaded();

final Deferrable<List<Statement>> _statements;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// @dart = 2.19
base class A {}

abstract base class B {}

base mixin M {}
base
mixin M {}
base class C = Object with M;
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// @dart = 2.19
final class A {}

abstract final class B {}

mixin M {}
final class C = Object with M;
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// @dart = 2.19
abstract final class B {}

final class A {}

final class C = Object with M;
mixin M {}
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// @dart = 2.19
interface class A {}

abstract interface class B {}

mixin M {}
interface class C = Object with M;
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// @dart = 2.19
abstract interface class B {}

interface class A {}

interface class C = Object with M;
mixin M {}
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// @dart = 2.19
mixin class A {}

abstract mixin class B {}

mixin M {}
mixin class C = Object with M;
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
// @dart = 2.19
abstract mixin class B {}

mixin M {}

mixin class A {}

mixin class C = Object with M;
24 changes: 16 additions & 8 deletions pkg/vm/lib/testing/il_matchers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,27 @@ class FlowGraph {
}

void dump() {
String formatOne(Map<String, dynamic> instr) {
final inputs = instr['i']?.map((v) => 'v$v').join(', ') ?? '';
final successors = instr['s'] != null ? ' goto ${instr['s']}' : '';
final attrs = descriptors[instr['o']]
?.attributeIndex
.entries
.map((e) => '${e.key}: ${instr['d'][e.value]}')
.join(',');
final condition = instr['cc'] != null ? formatOne(instr['cc']) : '';
final attrsWrapped = attrs != null ? '[$attrs]' : '';
final inputsWrapped =
condition != '' ? ' if $condition then ' : '($inputs)';
return '${instr['o']}$attrsWrapped$inputsWrapped$successors';
}

for (var block in blocks) {
print('B${block['b']}[${block['o']}]');
for (var instr in [...?block['d'], ...?block['is']]) {
final v = instr['v'] ?? -1;
final prefix = v != -1 ? 'v$v <- ' : '';
final inputs = instr['i']?.map((v) => 'v$v').join(', ') ?? '';
final attrs = descriptors[instr['o']]
?.attributeIndex
.entries
.map((e) => '${e.key}: ${instr['d'][e.value]}')
.join(',');
final attrsWrapped = attrs != null ? '[$attrs]' : '';
print(' ${prefix}${instr['o']}$attrsWrapped($inputs)');
print(' ${prefix}${formatOne(instr)}');
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions runtime/bin/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ template("build_elf_loader") {
"..:dart_os_fuchsia_config",
]
include_dirs = [ ".." ]
defines = [
# The only effect of DART_SHARED_LIB is to export the Dart API.
"DART_SHARED_LIB",
]
sources = [
"elf_loader.cc",
"elf_loader.h",
Expand Down
Loading

0 comments on commit 88297b5

Please sign in to comment.