Skip to content

Fix for "private extension String { private extension String <eof>" #27536

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions lib/AST/ASTScopeSourceRange.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,12 +310,14 @@ SourceRange GenericTypeOrExtensionWholePortion::getChildlessSourceRangeOf(

SourceRange
ExtensionScope::moveStartPastExtendedNominal(const SourceRange sr) const {
const auto start = getLocAfterExtendedNominal(decl);
const auto afterExtendedNominal = getLocAfterExtendedNominal(decl);
// Illegal code can have an endLoc that is before the end of the
// ExtendedNominal, so push the end back, too, in that case.
const auto end =
getSourceManager().isBeforeInBuffer(sr.End, start) ? start : sr.End;
return SourceRange(start, end);
// ExtendedNominal
if (getSourceManager().isBeforeInBuffer(sr.End, afterExtendedNominal)) {
// Must not have the source range returned include the extended nominal
return SourceRange(sr.Start, sr.Start);
}
return SourceRange(afterExtendedNominal, sr.End);
}

SourceRange
Expand Down
6 changes: 6 additions & 0 deletions test/NameBinding/scope_map_lookup_extension_extension.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Ensure scope construction does not crash on this illegal code
// RUN: not %target-swift-frontend -typecheck %s 2> %t.errors
// RUN: %FileCheck %s <%t.errors
// CHECK-NOT: Program arguments:
private extension String {
private extension String