mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[CursorInfo] Fix crash on instance variables used directly in if or for when declared in a generic context
For example:
class Foo<T> {
let test: Bool = false
let items: [Int] = []
func foo() {
if test {} // crashes on test
for i in items {} // crashes on items
}
}
We were picking up the incorrect containing type (Bool rather than Foo<T>).
Resolves rdar://problem/36871908.
This commit is contained in:
@@ -192,8 +192,8 @@ bool CursorInfoResolver::walkToExprPre(Expr *E) {
|
||||
ContainerType = SAE->getBase()->getType();
|
||||
}
|
||||
} else if (auto ME = dyn_cast<MemberRefExpr>(E)) {
|
||||
SourceLoc DotLoc = ME->getDotLoc();
|
||||
if (DotLoc.isValid() && DotLoc.getAdvancedLoc(1) == LocToResolve) {
|
||||
SourceLoc MemberLoc = ME->getNameLoc().getBaseNameLoc();
|
||||
if (MemberLoc.isValid() && MemberLoc == LocToResolve) {
|
||||
ContainerType = ME->getBase()->getType();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user