Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit d257741

Browse files
author
Dart CI
committed
Version 2.12.0-13.0.dev
Merge commit 'e8c4cc60d6376c94d48ace4cf5bb00caccbc11c7' into 'dev'
2 parents a9d5833 + e8c4cc6 commit d257741

File tree

7 files changed

+166
-173
lines changed

7 files changed

+166
-173
lines changed

pkg/analyzer/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@
1111
is now `FunctionTypeAliasElement`, not its function element.
1212
* Removed deprecated `GenericTypeAliasElement`.
1313

14+
## 0.40.6
15+
* The non_nullable feature is released in 2.12 language version.
16+
* Updated the current language version to 2.12.
17+
* Changed the default language version when the package does not specify one.
18+
Instead of the latest known language version, the language version of the
19+
SDK (against which analysis is done, not necessary the same as used to run
20+
the analyzer) is used.
21+
1422
## 0.40.5
1523
* Deprecated `GenericTypeAliasElement`. Use `FunctionTypeAliasElement`.
1624
* Read imports, exports, and parts on demand in `AnalysisDriver`.

pkg/dartdev/lib/src/analytics.dart

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -54,39 +54,46 @@ Analytics createAnalyticsInstance(bool disableAnalytics) {
5454
if (Platform.environment['_DARTDEV_LOG_ANALYTICS'] != null) {
5555
// Used for testing what analytics messages are sent.
5656
_instance = _LoggingAnalytics();
57-
} else if (disableAnalytics) {
57+
return _instance;
58+
}
59+
60+
if (disableAnalytics) {
5861
// Dartdev tests pass a hidden 'disable-dartdev-analytics' flag which is
5962
// handled here.
6063
// Also, stdout.hasTerminal is checked, if there is no terminal we infer that
6164
// a machine is running dartdev so we return analytics shouldn't be set.
6265
_instance = DisabledAnalytics(_trackingId, _appName);
63-
} else {
64-
var settingsDir = getDartStorageDirectory();
65-
if (settingsDir == null) {
66-
// Some systems don't support user home directories; for those, fail
66+
return _instance;
67+
}
68+
69+
var settingsDir = getDartStorageDirectory();
70+
if (settingsDir == null) {
71+
// Some systems don't support user home directories; for those, fail
72+
// gracefully by returning a disabled analytics object.
73+
_instance = DisabledAnalytics(_trackingId, _appName);
74+
return _instance;
75+
}
76+
77+
if (!settingsDir.existsSync()) {
78+
try {
79+
settingsDir.createSync();
80+
} catch (e) {
81+
// If we can't create the directory for the analytics settings, fail
6782
// gracefully by returning a disabled analytics object.
6883
_instance = DisabledAnalytics(_trackingId, _appName);
69-
} else if (!settingsDir.existsSync()) {
70-
try {
71-
settingsDir.createSync();
72-
} catch (e) {
73-
// If we can't create the directory for the analytics settings, fail
74-
// gracefully by returning a disabled analytics object.
75-
_instance = DisabledAnalytics(_trackingId, _appName);
76-
}
77-
} else {
78-
var readmeFile =
79-
File('${settingsDir.absolute.path}${path.separator}$_readmeFileName');
80-
if (!readmeFile.existsSync()) {
81-
readmeFile.createSync();
82-
readmeFile.writeAsStringSync(_readmeFileContents);
83-
}
84-
85-
var settingsFile = File(path.join(settingsDir.path, _settingsFileName));
86-
_instance = DartdevAnalytics(_trackingId, settingsFile, _appName);
84+
return _instance;
8785
}
8886
}
8987

88+
var readmeFile =
89+
File('${settingsDir.absolute.path}${path.separator}$_readmeFileName');
90+
if (!readmeFile.existsSync()) {
91+
readmeFile.createSync();
92+
readmeFile.writeAsStringSync(_readmeFileContents);
93+
}
94+
95+
var settingsFile = File(path.join(settingsDir.path, _settingsFileName));
96+
_instance = DartdevAnalytics(_trackingId, settingsFile, _appName);
9097
return _instance;
9198
}
9299

pkg/dev_compiler/lib/src/kernel/compiler.dart

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3002,12 +3002,49 @@ class ProgramCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
30023002
// size on expression evaluation is better.
30033003
// Issue: https://github.com/dart-lang/sdk/issues/43288
30043004
var fun = _emitFunction(functionNode, name);
3005-
var items = _typeTable?.discharge();
3006-
var body = js_ast.Block([...?items, ...fun.body.statements]);
30073005

3006+
var types = _typeTable.discharge();
3007+
var constants = _dischargeConstTable();
3008+
3009+
var body = js_ast.Block([...?types, ...?constants, ...fun.body.statements]);
30083010
return js_ast.Fun(fun.params, body);
30093011
}
30103012

3013+
/// Emit all collected const symbols
3014+
///
3015+
/// This is similar to how constants are emitted during
3016+
/// initial compilation in emitModule
3017+
///
3018+
/// TODO: unify the code with emitModule.
3019+
List<js_ast.Statement> _dischargeConstTable() {
3020+
var items = <js_ast.Statement>[];
3021+
3022+
if (_constLazyAccessors.isNotEmpty) {
3023+
var constTableBody = runtimeStatement(
3024+
'defineLazy(#, { # }, false)', [_constTable, _constLazyAccessors]);
3025+
items.add(constTableBody);
3026+
_constLazyAccessors.clear();
3027+
}
3028+
3029+
_copyAndFlattenBlocks(items, moduleItems);
3030+
moduleItems.clear();
3031+
return items;
3032+
}
3033+
3034+
/// Flattens blocks in [items] to a single list.
3035+
///
3036+
/// This will not flatten blocks that are marked as being scopes.
3037+
void _copyAndFlattenBlocks(
3038+
List<js_ast.Statement> result, Iterable<js_ast.ModuleItem> items) {
3039+
for (var item in items) {
3040+
if (item is js_ast.Block && !item.isScope) {
3041+
_copyAndFlattenBlocks(result, item.statements);
3042+
} else {
3043+
result.add(item as js_ast.Statement);
3044+
}
3045+
}
3046+
}
3047+
30113048
js_ast.Fun _emitFunction(FunctionNode f, String name) {
30123049
// normal function (sync), vs (sync*, async, async*)
30133050
var isSync = f.asyncMarker == AsyncMarker.Sync;

pkg/dev_compiler/test/expression_compiler/expression_compiler_test.dart

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,28 @@ void main() {
409409
))
410410
''');
411411
});
412+
413+
test('function', () async {
414+
await driver.check(
415+
scope: <String, String>{'x': '1', 'y': '2', 'z': '3'},
416+
expression: 'main',
417+
expectedResult: '''
418+
(function(x, y, z) {
419+
var VoidTodynamic = () => (VoidTodynamic = dart.constFn(dart.fnType(dart.dynamic, [])))();
420+
dart.defineLazy(CT, {
421+
get C0() {
422+
return C0 = dart.fn(foo.main, VoidTodynamic());
423+
}
424+
}, false);
425+
var C0;
426+
return C0 || CT.C0;
427+
}(
428+
1,
429+
2,
430+
3
431+
))
432+
''');
433+
});
412434
});
413435

414436
group('Expression compiler tests in method:', () {
@@ -1313,7 +1335,16 @@ void main() {
13131335
expression: 'const MyClass(1)',
13141336
expectedResult: '''
13151337
(function(p) {
1316-
return C0 || CT.C0;
1338+
dart.defineLazy(CT, {
1339+
get C0() {
1340+
return C0 = dart.const({
1341+
__proto__: foo.MyClass.prototype,
1342+
[_t]: 1
1343+
});
1344+
}
1345+
}, false);
1346+
var C0;
1347+
return C0 || CT.C0;
13171348
}(
13181349
1
13191350
))
@@ -1353,6 +1384,15 @@ void main() {
13531384
expression: "const Key('t')",
13541385
expectedResult: '''
13551386
(function(p) {
1387+
dart.defineLazy(CT, {
1388+
get C0() {
1389+
return C0 = dart.const({
1390+
__proto__: foo.ValueKey.prototype,
1391+
[value]: "t"
1392+
});
1393+
}
1394+
}, false);
1395+
var C0;
13561396
return C0 || CT.C0;
13571397
}(
13581398
1

0 commit comments

Comments
 (0)