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

Commit f79fb10

Browse files
author
Dart CI
committed
Version 2.12.0-177.0.dev
Merge commit '03adde55558d274ca11a11374629eb5ab817d4be' into 'dev'
2 parents 6e1161e + 03adde5 commit f79fb10

File tree

5 files changed

+43
-15
lines changed

5 files changed

+43
-15
lines changed

pkg/analysis_server/lib/src/services/correction/fix_internal.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,6 +1085,9 @@ class FixProcessor extends BaseProcessor {
10851085
StaticWarningCode.INVALID_NULL_AWARE_OPERATOR: [
10861086
ReplaceWithNotNullAware.newInstance,
10871087
],
1088+
StaticWarningCode.INVALID_NULL_AWARE_OPERATOR_AFTER_SHORT_CIRCUIT: [
1089+
ReplaceWithNotNullAware.newInstance,
1090+
],
10881091
StaticWarningCode.MISSING_ENUM_CONSTANT_IN_SWITCH: [
10891092
AddMissingEnumCaseClauses.newInstance,
10901093
],

pkg/analysis_server/test/src/services/correction/fix/replace_with_not_null_aware_test.dart

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,22 @@ class C {
137137
''');
138138
}
139139

140+
Future<void> test_shortCircuit() async {
141+
await resolveTestCode('''
142+
class C {
143+
C a(C? c) => c?.b?.b ?? this;
144+
C get b => this;
145+
}
146+
''');
147+
148+
await assertHasFix('''
149+
class C {
150+
C a(C? c) => c?.b.b ?? this;
151+
C get b => this;
152+
}
153+
''');
154+
}
155+
140156
Future<void> test_spread() async {
141157
await resolveTestCode('''
142158
void f(List<int> x) {

pkg/front_end/lib/src/base/processed_options.dart

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,8 @@ class ProcessedOptions {
400400
if (sdkSummary == null) return null;
401401
List<int> bytes = await loadSdkSummaryBytes();
402402
if (bytes != null && bytes.isNotEmpty) {
403-
_sdkSummaryComponent = loadComponent(bytes, nameRoot);
403+
_sdkSummaryComponent =
404+
loadComponent(bytes, nameRoot, fileUri: sdkSummary);
404405
}
405406
}
406407
return _sdkSummaryComponent;
@@ -424,10 +425,13 @@ class ProcessedOptions {
424425
// TODO(sigmund): throttle # of concurrent operations.
425426
List<List<int>> allBytes = await Future.wait(
426427
uris.map((uri) => _readAsBytes(fileSystem.entityForUri(uri))));
427-
_additionalDillComponents = allBytes
428-
.where((bytes) => bytes != null)
429-
.map((bytes) => loadComponent(bytes, nameRoot))
430-
.toList();
428+
List<Component> result = [];
429+
for (int i = 0; i < uris.length; i++) {
430+
if (allBytes[i] == null) continue;
431+
List<int> bytes = allBytes[i];
432+
result.add(loadComponent(bytes, nameRoot, fileUri: uris[i]));
433+
}
434+
_additionalDillComponents = result;
431435
}
432436
return _additionalDillComponents;
433437
}
@@ -442,13 +446,12 @@ class ProcessedOptions {
442446

443447
/// Helper to load a .dill file from [uri] using the existing [nameRoot].
444448
Component loadComponent(List<int> bytes, CanonicalName nameRoot,
445-
{bool alwaysCreateNewNamedNodes}) {
449+
{bool alwaysCreateNewNamedNodes, Uri fileUri}) {
446450
Component component =
447451
target.configureComponent(new Component(nameRoot: nameRoot));
448-
// TODO(ahe): Pass file name to BinaryBuilder.
449452
// TODO(ahe): Control lazy loading via an option.
450453
new BinaryBuilder(bytes,
451-
filename: null,
454+
filename: fileUri == null ? null : '$fileUri',
452455
disableLazyReading: false,
453456
alwaysCreateNewNamedNodes: alwaysCreateNewNamedNodes)
454457
.readComponent(component);

pkg/kernel/lib/binary/ast_from_binary.dart

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,19 @@ class ParseError {
2424
}
2525

2626
class InvalidKernelVersionError {
27+
final String filename;
2728
final int version;
2829

29-
InvalidKernelVersionError(this.version);
30+
InvalidKernelVersionError(this.filename, this.version);
3031

3132
String toString() {
32-
return 'Unexpected Kernel Format Version ${version} '
33-
'(expected ${Tag.BinaryFormatVersion}).';
33+
StringBuffer sb = new StringBuffer();
34+
sb.write('Unexpected Kernel Format Version ${version} '
35+
'(expected ${Tag.BinaryFormatVersion})');
36+
if (filename != null) {
37+
sb.write(' when reading $filename.');
38+
}
39+
return '$sb';
3440
}
3541
}
3642

@@ -529,7 +535,7 @@ class BinaryBuilder {
529535
}
530536
int version = readUint32();
531537
if (version != Tag.BinaryFormatVersion) {
532-
throw InvalidKernelVersionError(version);
538+
throw InvalidKernelVersionError(filename, version);
533539
}
534540

535541
_readAndVerifySdkHash();
@@ -717,7 +723,7 @@ class BinaryBuilder {
717723

718724
final int formatVersion = readUint32();
719725
if (formatVersion != Tag.BinaryFormatVersion) {
720-
throw InvalidKernelVersionError(formatVersion);
726+
throw InvalidKernelVersionError(filename, formatVersion);
721727
}
722728

723729
_readAndVerifySdkHash();
@@ -743,7 +749,7 @@ class BinaryBuilder {
743749

744750
final int formatVersion = readUint32();
745751
if (formatVersion != Tag.BinaryFormatVersion) {
746-
throw InvalidKernelVersionError(formatVersion);
752+
throw InvalidKernelVersionError(filename, formatVersion);
747753
}
748754

749755
_readAndVerifySdkHash();

tools/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@ CHANNEL dev
2727
MAJOR 2
2828
MINOR 12
2929
PATCH 0
30-
PRERELEASE 176
30+
PRERELEASE 177
3131
PRERELEASE_PATCH 0

0 commit comments

Comments
 (0)