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

Commit 5f4511a

Browse files
scheglovcommit-bot@chromium.org
authored andcommitted
Stop adding tokens to unit API signature at EOF.
[email protected], [email protected] Fixes dart-lang/sdk#34850 Change-Id: Iaa4a537ee7f69446129663467241cc8a8498d57b Reviewed-on: https://dart-review.googlesource.com/c/80680 Commit-Queue: Konstantin Shcheglov <[email protected]> Reviewed-by: Brian Wilkerson <[email protected]>
1 parent 2a63500 commit 5f4511a

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

pkg/analyzer/lib/src/dart/analysis/unlinked_api_signature.dart

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,23 @@ class _UnitApiSignatureComputer {
7070
if (begin is CommentToken) {
7171
begin = (begin as CommentToken).parent;
7272
}
73+
7374
Token token = begin;
7475
while (token != null) {
7576
addToken(token);
77+
7678
if (token == end) {
7779
break;
7880
}
79-
token = token.next;
81+
82+
var nextToken = token.next;
83+
84+
// Stop if EOF.
85+
if (nextToken == token) {
86+
break;
87+
}
88+
89+
token = nextToken;
8090
}
8191
}
8292

pkg/analyzer/test/src/dart/analysis/unlinked_api_signature_test.dart

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -752,6 +752,16 @@ void foo<U>() {}
752752
''');
753753
}
754754

755+
test_issue34850() {
756+
assertNotSameSignature(r'''
757+
foo
758+
Future<List<int>> bar() {}
759+
''', r'''
760+
foo
761+
Future<List<int>> bar() async {}
762+
''');
763+
}
764+
755765
test_mixin_field_withoutType() {
756766
assertNotSameSignature(r'''
757767
mixin M {

0 commit comments

Comments
 (0)