[S] Change in dart/sdk[main]: [analyzer] Fix _OverlayFile.writeAsBytesSync

0 views
Skip to first unread message

Jens Johansen (Gerrit)

unread,
Jun 9, 2026, 9:18:36 AMJun 9
to Johnni Winther, dart-analys...@google.com, rev...@dartlang.org
Attention needed from Johnni Winther

Jens Johansen voted Commit-Queue+1

Commit-Queue+1
Open in Gerrit

Related details

Attention is currently required from:
  • Johnni Winther
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: I3b4d7ad2b7a781c49abebef307a44dd9b3381b37
Gerrit-Change-Number: 510361
Gerrit-PatchSet: 1
Gerrit-Owner: Jens Johansen <je...@google.com>
Gerrit-Reviewer: Jens Johansen <je...@google.com>
Gerrit-Reviewer: Johnni Winther <johnni...@google.com>
Gerrit-Attention: Johnni Winther <johnni...@google.com>
Gerrit-Comment-Date: Tue, 09 Jun 2026 13:18:30 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
satisfied_requirement
unsatisfied_requirement
open
diffy

Johnni Winther (Gerrit)

unread,
Jun 9, 2026, 9:24:38 AMJun 9
to Jens Johansen, dart-...@luci-project-accounts.iam.gserviceaccount.com, dart-analys...@google.com, rev...@dartlang.org
Attention needed from Jens Johansen

Johnni Winther voted and added 2 comments

Votes added by Johnni Winther

Code-Review+1

2 comments

File pkg/analyzer/test/file_system/overlay_file_system_test.dart
Line 357, Patchset 1 (Latest): test_write_read_bytes_can_be_read_as_string() {
var expectedContent = "æble";
File file = _file(exists: true, content: expectedContent);
expect(file.readAsStringSync(), expectedContent);
var byteContent = file.readAsBytesSync();
file.writeAsBytesSync(byteContent);
expect(file.readAsStringSync(), expectedContent);
}
Johnni Winther . unresolved

How is this related to the change?

Line 376, Patchset 1 (Latest): expect(() => file.writeAsBytesSync(bytes), throwsA(_isFileSystemException));
Johnni Winther . unresolved

Why is there no update to the test? Did it not fail before?

Open in Gerrit

Related details

Attention is currently required from:
  • Jens Johansen
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement satisfiedCode-Review
  • requirement satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: I3b4d7ad2b7a781c49abebef307a44dd9b3381b37
Gerrit-Change-Number: 510361
Gerrit-PatchSet: 1
Gerrit-Owner: Jens Johansen <je...@google.com>
Gerrit-Reviewer: Jens Johansen <je...@google.com>
Gerrit-Reviewer: Johnni Winther <johnni...@google.com>
Gerrit-Attention: Jens Johansen <je...@google.com>
Gerrit-Comment-Date: Tue, 09 Jun 2026 13:24:32 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
satisfied_requirement
open
diffy

Jens Johansen (Gerrit)

unread,
Jun 9, 2026, 9:37:02 AMJun 9
to Johnni Winther, dart-...@luci-project-accounts.iam.gserviceaccount.com, dart-analys...@google.com, rev...@dartlang.org
Attention needed from Johnni Winther

Jens Johansen added 2 comments

File pkg/analyzer/test/file_system/overlay_file_system_test.dart
Line 357, Patchset 1 (Latest): test_write_read_bytes_can_be_read_as_string() {
var expectedContent = "æble";
File file = _file(exists: true, content: expectedContent);
expect(file.readAsStringSync(), expectedContent);
var byteContent = file.readAsBytesSync();
file.writeAsBytesSync(byteContent);
expect(file.readAsStringSync(), expectedContent);
}
Johnni Winther . unresolved

How is this related to the change?

Jens Johansen

It's the test for it working (vs not working before)...

Reading as bytes returns the string utf-8 encoded, whereas writing it as bytes used to create a string from the bytes as if they were code units, creating a string of the same length as the list of bytes. For "æble" that becomes 5 bytes/a string of length 5 (with the first two characters being nonsense).

Or am I misreading the question?

Line 376, Patchset 1 (Latest): expect(() => file.writeAsBytesSync(bytes), throwsA(_isFileSystemException));
Johnni Winther . resolved

Why is there no update to the test? Did it not fail before?

Jens Johansen

No. Char-code 99 (`c`) is in ansi-range so the utf8-encoding is the same. Well i suppose that would be the explanation above --- here it is expected to throw because it will not write to a file with an overlay...

Open in Gerrit

Related details

Attention is currently required from:
  • Johnni Winther
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement satisfiedCode-Review
  • requirement satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: I3b4d7ad2b7a781c49abebef307a44dd9b3381b37
Gerrit-Change-Number: 510361
Gerrit-PatchSet: 1
Gerrit-Owner: Jens Johansen <je...@google.com>
Gerrit-Reviewer: Jens Johansen <je...@google.com>
Gerrit-Reviewer: Johnni Winther <johnni...@google.com>
Gerrit-Attention: Johnni Winther <johnni...@google.com>
Gerrit-Comment-Date: Tue, 09 Jun 2026 13:36:56 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Johnni Winther <johnni...@google.com>
satisfied_requirement
open
diffy

Johnni Winther (Gerrit)

unread,
Jun 10, 2026, 3:25:14 AMJun 10
to Jens Johansen, dart-...@luci-project-accounts.iam.gserviceaccount.com, dart-analys...@google.com, rev...@dartlang.org
Attention needed from Jens Johansen

Johnni Winther added 1 comment

File pkg/analyzer/test/file_system/overlay_file_system_test.dart
Line 357, Patchset 1 (Latest): test_write_read_bytes_can_be_read_as_string() {
var expectedContent = "æble";
File file = _file(exists: true, content: expectedContent);
expect(file.readAsStringSync(), expectedContent);
var byteContent = file.readAsBytesSync();
file.writeAsBytesSync(byteContent);
expect(file.readAsStringSync(), expectedContent);
}
Johnni Winther . resolved

How is this related to the change?

Jens Johansen

It's the test for it working (vs not working before)...

Reading as bytes returns the string utf-8 encoded, whereas writing it as bytes used to create a string from the bytes as if they were code units, creating a string of the same length as the list of bytes. For "æble" that becomes 5 bytes/a string of length 5 (with the first two characters being nonsense).

Or am I misreading the question?

Johnni Winther

OK. Thanks

Open in Gerrit

Related details

Attention is currently required from:
  • Jens Johansen
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement satisfiedCode-Review
  • requirement satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: I3b4d7ad2b7a781c49abebef307a44dd9b3381b37
Gerrit-Change-Number: 510361
Gerrit-PatchSet: 1
Gerrit-Owner: Jens Johansen <je...@google.com>
Gerrit-Reviewer: Jens Johansen <je...@google.com>
Gerrit-Reviewer: Johnni Winther <johnni...@google.com>
Gerrit-Attention: Jens Johansen <je...@google.com>
Gerrit-Comment-Date: Wed, 10 Jun 2026 07:25:04 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Jens Johansen <je...@google.com>
Comment-In-Reply-To: Johnni Winther <johnni...@google.com>
satisfied_requirement
open
diffy

Jens Johansen (Gerrit)

unread,
Jun 10, 2026, 4:08:02 AMJun 10
to Johnni Winther, dart-...@luci-project-accounts.iam.gserviceaccount.com, dart-analys...@google.com, rev...@dartlang.org

Jens Johansen voted Commit-Queue+2

Commit-Queue+2
Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement satisfiedCode-Review
  • requirement satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: I3b4d7ad2b7a781c49abebef307a44dd9b3381b37
Gerrit-Change-Number: 510361
Gerrit-PatchSet: 1
Gerrit-Owner: Jens Johansen <je...@google.com>
Gerrit-Reviewer: Jens Johansen <je...@google.com>
Gerrit-Reviewer: Johnni Winther <johnni...@google.com>
Gerrit-Comment-Date: Wed, 10 Jun 2026 08:07:57 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
satisfied_requirement
open
diffy

dart-scoped@luci-project-accounts.iam.gserviceaccount.com (Gerrit)

unread,
Jun 10, 2026, 4:08:23 AMJun 10
to Jens Johansen, Johnni Winther, dart-analys...@google.com, rev...@dartlang.org

dart-...@luci-project-accounts.iam.gserviceaccount.com submitted the change

Change information

Commit message:
[analyzer] Fix _OverlayFile.writeAsBytesSync
Change-Id: I3b4d7ad2b7a781c49abebef307a44dd9b3381b37
Reviewed-by: Johnni Winther <johnni...@google.com>
Commit-Queue: Jens Johansen <je...@google.com>
Files:
  • M pkg/analyzer/lib/file_system/overlay_file_system.dart
  • M pkg/analyzer/test/file_system/overlay_file_system_test.dart
Change size: S
Delta: 2 files changed, 13 insertions(+), 1 deletion(-)
Branch: refs/heads/main
Submit Requirements:
  • requirement satisfiedCode-Review: +1 by Johnni Winther
Open in Gerrit
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: merged
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: I3b4d7ad2b7a781c49abebef307a44dd9b3381b37
Gerrit-Change-Number: 510361
Gerrit-PatchSet: 2
Gerrit-Owner: Jens Johansen <je...@google.com>
Gerrit-Reviewer: Jens Johansen <je...@google.com>
Gerrit-Reviewer: Johnni Winther <johnni...@google.com>
open
diffy
satisfied_requirement
Reply all
Reply to author
Forward
0 new messages