Skip to content

Commit ca8871e

Browse files
author
David Ungar
authored
Merge pull request #27536 from davidungar/Fix-rdar-55914036
Fix for "private extension String { private extension String <eof>"
2 parents 16bb84f + 33f3213 commit ca8871e

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

lib/AST/ASTScopeSourceRange.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -310,12 +310,14 @@ SourceRange GenericTypeOrExtensionWholePortion::getChildlessSourceRangeOf(
310310

311311
SourceRange
312312
ExtensionScope::moveStartPastExtendedNominal(const SourceRange sr) const {
313-
const auto start = getLocAfterExtendedNominal(decl);
313+
const auto afterExtendedNominal = getLocAfterExtendedNominal(decl);
314314
// Illegal code can have an endLoc that is before the end of the
315-
// ExtendedNominal, so push the end back, too, in that case.
316-
const auto end =
317-
getSourceManager().isBeforeInBuffer(sr.End, start) ? start : sr.End;
318-
return SourceRange(start, end);
315+
// ExtendedNominal
316+
if (getSourceManager().isBeforeInBuffer(sr.End, afterExtendedNominal)) {
317+
// Must not have the source range returned include the extended nominal
318+
return SourceRange(sr.Start, sr.Start);
319+
}
320+
return SourceRange(afterExtendedNominal, sr.End);
319321
}
320322

321323
SourceRange
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// Ensure scope construction does not crash on this illegal code
2+
// RUN: not %target-swift-frontend -typecheck %s 2> %t.errors
3+
// RUN: %FileCheck %s <%t.errors
4+
// CHECK-NOT: Program arguments:
5+
private extension String {
6+
private extension String

0 commit comments

Comments
 (0)