mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[CodeCompletion] Do not erase dot for code completion key path optiona root unwrapped members
This commit is contained in:
@@ -3725,8 +3725,12 @@ public:
|
||||
llvm::SaveAndRestore<bool> ChangeNeedOptionalUnwrap(NeedOptionalUnwrap,
|
||||
true);
|
||||
if (DotLoc.isValid()) {
|
||||
// Let's not erase the dot if the completion is after a swift key path
|
||||
// root because \A?.?.member is the correct way to access wrapped type
|
||||
// member from an optional key path root.
|
||||
auto loc = IsAfterSwiftKeyPathRoot ? DotLoc.getAdvancedLoc(1) : DotLoc;
|
||||
NumBytesToEraseForOptionalUnwrap = Ctx.SourceMgr.getByteDistance(
|
||||
DotLoc, Ctx.SourceMgr.getCodeCompletionLoc());
|
||||
loc, Ctx.SourceMgr.getCodeCompletionLoc());
|
||||
} else {
|
||||
NumBytesToEraseForOptionalUnwrap = 0;
|
||||
}
|
||||
@@ -5930,7 +5934,7 @@ void CodeCompletionCallbacksImpl::doneParsing() {
|
||||
if (!OnRoot && KPE->getComponents().back().getKind() ==
|
||||
KeyPathExpr::Component::Kind::OptionalWrap) {
|
||||
// KeyPath expr with '?' (e.g. '\Ty.[0].prop?.another').
|
||||
// Althogh expected type is optional, we should unwrap it because it's
|
||||
// Although expected type is optional, we should unwrap it because it's
|
||||
// unwrapped.
|
||||
baseType = baseType->getOptionalObjectType();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user