Skip to content

Commit 8a9e8be

Browse files
author
Dart CI
committed
Version 3.9.0-225.0.dev
Merge 9202990 into dev
2 parents ac589db + 9202990 commit 8a9e8be

File tree

4 files changed

+50
-109
lines changed

4 files changed

+50
-109
lines changed

pkg/front_end/test/flutter_gallery_leak_tester.dart

Lines changed: 9 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -59,21 +59,13 @@ Future<void> main(List<String> args) async {
5959
throw "File not found: $frontendServerStarter";
6060
}
6161

62-
Directory gallery = new Directory("$rootPath/gallery");
63-
if (!gallery.existsSync()) {
64-
print("Gallery not found... Copying from flutter dir.");
65-
66-
Directory galleryFlutterDev =
67-
new Directory("$rootPath/flutter/dev/integration_tests/new_gallery");
68-
69-
// Copy it.
70-
Process process = await Process.start(
71-
"cp", ["-r", galleryFlutterDev.path, "$rootPath/gallery"]);
72-
int processExitCode = await process.exitCode;
73-
print("Exit code from cp: $processExitCode");
62+
File packageConfig =
63+
new File("$rootPath/flutter/.dart_tool/package_config.json");
7464

75-
process = await Process.start("../flutter/bin/flutter", ["pub", "get"],
76-
workingDirectory: "$rootPath/gallery/");
65+
if (!packageConfig.existsSync()) {
66+
// If the package_config doesn't exist we should run pub get.
67+
Process process = await Process.start("bin/flutter", ["pub", "get"],
68+
workingDirectory: "$rootPath/flutter/");
7769
process.stdout
7870
.transform(utf8.decoder)
7971
.transform(new LineSplitter())
@@ -86,59 +78,12 @@ Future<void> main(List<String> args) async {
8678
.listen((line) {
8779
print("flutter stderr> $line");
8880
});
89-
processExitCode = await process.exitCode;
81+
int processExitCode = await process.exitCode;
9082
print("Exit code from flutter: $processExitCode");
91-
92-
// Attempt to hack around strings being truncated to 128 bytes in heap dumps
93-
// https://github.com/dart-lang/sdk/blob/c59cdee365b94ce066344840f9e3412d642019b5/runtime/vm/object_graph.cc#L809
94-
// (pub paths can become too long, so two distinct files will look to have
95-
// the same url and thus give a false positive).
96-
Uri pubDirUri = Uri.parse("file://${Platform.environment['HOME']}/"
97-
".pub-cache/hosted/pub.dev/");
98-
Directory pubDir = new Directory.fromUri(pubDirUri);
99-
if (!pubDir.existsSync()) {
100-
File galleryPackageConfig =
101-
new File("$rootPath/gallery/.dart_tool/package_config.json");
102-
String? packagesData;
103-
if (galleryPackageConfig.existsSync()) {
104-
packagesData = galleryPackageConfig.readAsStringSync();
105-
}
106-
107-
throw "Expected to find $pubDir but didn't.\n"
108-
"Content of packages file (${packagesData.runtimeType}): "
109-
"$packagesData";
110-
}
111-
112-
File galleryPackageConfig =
113-
new File("$rootPath/gallery/.dart_tool/package_config.json");
114-
if (!galleryPackageConfig.existsSync()) {
115-
throw "Didn't find $galleryPackageConfig";
116-
}
117-
String data = galleryPackageConfig.readAsStringSync();
118-
data = data.replaceAll(pubDirUri.toString(), "../pub/");
119-
galleryPackageConfig.writeAsStringSync(data);
120-
121-
process = await Process.start("ln", ["-s", pubDir.path, "pub"],
122-
workingDirectory: "$rootPath/gallery/");
123-
process.stdout
124-
.transform(utf8.decoder)
125-
.transform(new LineSplitter())
126-
.listen((line) {
127-
print("ln stdout> $line");
128-
});
129-
process.stderr
130-
.transform(utf8.decoder)
131-
.transform(new LineSplitter())
132-
.listen((line) {
133-
print("ln stderr> $line");
134-
});
135-
processExitCode = await process.exitCode;
136-
print("Exit code from ln: $processExitCode");
13783
}
13884

139-
File packageConfig =
140-
new File("$rootPath/gallery/.dart_tool/package_config.json");
14185
if (!packageConfig.existsSync()) {
86+
// If it still doesn't exist something is wrong.
14287
throw "Didn't find $packageConfig";
14388
}
14489

@@ -179,7 +124,7 @@ Future<void> main(List<String> args) async {
179124
"--output-dill",
180125
"$rootPath/flutter_server_tmp.dill",
181126
"--packages",
182-
"$rootPath/gallery/.dart_tool/package_config.json",
127+
packageConfig.path,
183128
"-Ddart.vm.profile=false",
184129
"-Ddart.vm.product=false",
185130
"--enable-asserts",

pkg/kernel/lib/dart_scope_calculator.dart

Lines changed: 37 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,9 @@ class DartScopeBuilder extends VisitorDefault<void> with VisitorVoidMixin {
160160
//
161161
// A null name signals that the variable was synthetically introduced by the
162162
// compiler so they are skipped.
163-
if ((decl.fileOffset < 0 || decl.fileOffset < _offset) && name != null) {
163+
if ((decl.fileOffset < 0 || decl.fileOffset < _offset) &&
164+
!decl.isWildcard &&
165+
name != null) {
164166
_definitions[name] = decl.type;
165167
}
166168
super.visitVariableDeclaration(decl);
@@ -262,7 +264,7 @@ class DartScopeBuilder2 extends VisitorDefault<void> with VisitorVoidMixin {
262264
final Uri _scriptUri;
263265
final int _offset;
264266
final List<DartScope2> findScopes = [];
265-
final Set<int> foundOffsets = {};
267+
int? closestLessOrEqualFoundOffset;
266268

267269
final Set<VariableDeclaration> hoistedUnwritten = {};
268270
final List<List<VariableDeclaration>> scopes = [];
@@ -289,7 +291,8 @@ class DartScopeBuilder2 extends VisitorDefault<void> with VisitorVoidMixin {
289291
String? name = decl.name;
290292
if (name != null &&
291293
!decl.isSynthesized &&
292-
!hoistedUnwritten.contains(decl)) {
294+
!hoistedUnwritten.contains(decl) &&
295+
!decl.isWildcard) {
293296
definitions[name] = decl;
294297
}
295298
}
@@ -529,20 +532,32 @@ class DartScopeBuilder2 extends VisitorDefault<void> with VisitorVoidMixin {
529532
scopes.last.add(node);
530533
}
531534

535+
void _updateClosestFoundOffset(int offset) {
536+
if (offset > _offset) {
537+
// This offset is larger that the one we're looking for so we'll skip.
538+
return;
539+
}
540+
if (closestLessOrEqualFoundOffset == null ||
541+
offset > closestLessOrEqualFoundOffset!) {
542+
closestLessOrEqualFoundOffset = offset;
543+
return;
544+
}
545+
}
546+
532547
void _checkOffset(TreeNode node) {
533-
if (_currentUri == _scriptUri) {
534-
foundOffsets.add(node.fileOffset);
535-
if (node.fileOffset == _offset) {
536-
addFound(node);
537-
} else {
538-
List<int>? allOffsets = node.fileOffsetsIfMultiple;
539-
if (allOffsets != null) {
540-
for (final int offset in allOffsets) {
541-
foundOffsets.add(offset);
542-
if (offset == _offset) {
543-
addFound(node);
544-
break;
545-
}
548+
if (_currentUri != _scriptUri) return;
549+
550+
_updateClosestFoundOffset(node.fileOffset);
551+
if (node.fileOffset == _offset) {
552+
addFound(node);
553+
} else {
554+
List<int>? allOffsets = node.fileOffsetsIfMultiple;
555+
if (allOffsets != null) {
556+
for (final int offset in allOffsets) {
557+
_updateClosestFoundOffset(offset);
558+
if (offset == _offset) {
559+
addFound(node);
560+
break;
546561
}
547562
}
548563
}
@@ -553,36 +568,15 @@ class DartScopeBuilder2 extends VisitorDefault<void> with VisitorVoidMixin {
553568
Library library, Uri scriptUri, Class? cls, int offset) {
554569
DartScopeBuilder2 data = _raw(library, scriptUri, cls, offset);
555570
if (data.findScopes.isEmpty) {
556-
int? closestMatchingOrSmallerOffset =
557-
_findClosestMatchingOrSmallerOffset(data, offset);
558-
if (closestMatchingOrSmallerOffset != null) {
559-
offset = closestMatchingOrSmallerOffset;
571+
int? closestLessOrEqualFoundOffset = data.closestLessOrEqualFoundOffset;
572+
if (closestLessOrEqualFoundOffset != null) {
573+
offset = closestLessOrEqualFoundOffset;
560574
data = _raw(library, scriptUri, cls, offset);
561575
}
562576
}
563577
return _findScopePick(data.findScopes, library, cls, offset);
564578
}
565579

566-
static int? _findClosestMatchingOrSmallerOffset(
567-
DartScopeBuilder2 data, int offset) {
568-
List<int> foundOffsets = data.foundOffsets.toList()..sort();
569-
if (foundOffsets.isEmpty) return null;
570-
int low = 0;
571-
int high = foundOffsets.length - 1;
572-
while (low < high) {
573-
int mid = high - ((high - low) >> 1); // Get middle, rounding up.
574-
int pivot = foundOffsets[mid];
575-
if (pivot <= offset) {
576-
low = mid;
577-
} else {
578-
high = mid - 1;
579-
}
580-
}
581-
int result = foundOffsets[low];
582-
if (result < 0) return null;
583-
return result;
584-
}
585-
586580
static DartScope _findScopePick(
587581
List<DartScope2> scopes, Library library, Class? cls, int offset) {
588582
DartScope2 scope;
@@ -619,10 +613,9 @@ class DartScopeBuilder2 extends VisitorDefault<void> with VisitorVoidMixin {
619613
Library library, Uri scriptUri, int offset) {
620614
DartScopeBuilder2 data = _rawNoClass(library, scriptUri, offset);
621615
if (data.findScopes.isEmpty) {
622-
int? closestMatchingOrSmallerOffset =
623-
_findClosestMatchingOrSmallerOffset(data, offset);
624-
if (closestMatchingOrSmallerOffset != null) {
625-
offset = closestMatchingOrSmallerOffset;
616+
int? closestLessOrEqualFoundOffset = data.closestLessOrEqualFoundOffset;
617+
if (closestLessOrEqualFoundOffset != null) {
618+
offset = closestLessOrEqualFoundOffset;
626619
data = _rawNoClass(library, scriptUri, offset);
627620
}
628621
}

pkg/kernel/test/dart_scope_calculator_test.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,9 @@ class ScopeTestingBinaryPrinter extends BinaryPrinter {
360360
if (variable.isHoisted && !setVariables.contains(variable)) {
361361
// A hoisted variable that isn't set (yet) --- pretend it isn't
362362
// there.
363+
} else if (variable.isWildcard) {
364+
// A wildcard variable doesn't really exist so we'll ignore it,
365+
// see https://github.com/dart-lang/sdk/issues/60841.
363366
} else {
364367
expectedVariablesMap[name] = variable.type;
365368
}

tools/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@ CHANNEL dev
2727
MAJOR 3
2828
MINOR 9
2929
PATCH 0
30-
PRERELEASE 224
30+
PRERELEASE 225
3131
PRERELEASE_PATCH 0

0 commit comments

Comments
 (0)