diff --git a/lib/Basic/SourceLoc.cpp b/lib/Basic/SourceLoc.cpp index 4649e58dfddab..5af45683505f9 100644 --- a/lib/Basic/SourceLoc.cpp +++ b/lib/Basic/SourceLoc.cpp @@ -797,11 +797,11 @@ static bool isBeforeInSource( SourceLoc firstLocInLCA = firstMismatch == firstAncestors.end() ? firstLoc : sourceMgr.getGeneratedSourceInfo(*firstMismatch) - ->originalSourceRange.getStart(); + ->originalSourceRange.getEnd(); SourceLoc secondLocInLCA = secondMismatch == secondAncestors.end() ? secondLoc : sourceMgr.getGeneratedSourceInfo(*secondMismatch) - ->originalSourceRange.getStart(); + ->originalSourceRange.getEnd(); return sourceMgr.isBeforeInBuffer(firstLocInLCA, secondLocInLCA) || (allowEqual && firstLocInLCA == secondLocInLCA); } diff --git a/test/stdlib/Observation/Observable.swift b/test/stdlib/Observation/Observable.swift index 50c140f15640e..4cd0f2f9dca0e 100644 --- a/test/stdlib/Observation/Observable.swift +++ b/test/stdlib/Observation/Observable.swift @@ -215,6 +215,16 @@ class RecursiveOuter { class GuardedAvailability { } +@Observable class TestASTScopeLCA { + // Make sure ASTScope unqualified lookup can find local variables + // inside initial values with closures when accessor macros are + // involved. + var state : Bool = { + let value = true + return value + }() +} + @main struct Validator { @MainActor