mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Merge remote-tracking branch 'origin/main' into rebranch
This commit is contained in:
@@ -4852,8 +4852,7 @@ public:
|
||||
/// Expand the children of the given type refinement context.
|
||||
class ExpandChildTypeRefinementContextsRequest
|
||||
: public SimpleRequest<ExpandChildTypeRefinementContextsRequest,
|
||||
std::vector<TypeRefinementContext *>(
|
||||
TypeRefinementContext *),
|
||||
evaluator::SideEffect(TypeRefinementContext *),
|
||||
RequestFlags::SeparatelyCached> {
|
||||
public:
|
||||
using SimpleRequest::SimpleRequest;
|
||||
@@ -4861,14 +4860,14 @@ public:
|
||||
private:
|
||||
friend SimpleRequest;
|
||||
|
||||
std::vector<TypeRefinementContext *>
|
||||
evaluate(Evaluator &evaluator, TypeRefinementContext *parentTRC) const;
|
||||
evaluator::SideEffect evaluate(Evaluator &evaluator,
|
||||
TypeRefinementContext *parentTRC) const;
|
||||
|
||||
public:
|
||||
// Separate caching.
|
||||
bool isCached() const { return true; }
|
||||
std::optional<std::vector<TypeRefinementContext *>> getCachedResult() const;
|
||||
void cacheResult(std::vector<TypeRefinementContext *> children) const;
|
||||
std::optional<evaluator::SideEffect> getCachedResult() const;
|
||||
void cacheResult(evaluator::SideEffect) const;
|
||||
};
|
||||
|
||||
class SerializeAttrGenericSignatureRequest
|
||||
|
||||
@@ -208,20 +208,21 @@ TypeRefinementContext::findMostRefinedSubContext(SourceLoc Loc,
|
||||
if (SrcRange.isValid() && !Ctx.SourceMgr.containsTokenLoc(SrcRange, Loc))
|
||||
return nullptr;
|
||||
|
||||
auto expandedChildren = evaluateOrDefault(
|
||||
Ctx.evaluator, ExpandChildTypeRefinementContextsRequest{this}, {});
|
||||
(void)evaluateOrDefault(Ctx.evaluator,
|
||||
ExpandChildTypeRefinementContextsRequest{this}, {});
|
||||
assert(!getNeedsExpansion());
|
||||
|
||||
// Do a binary search to find the first child with a source range that
|
||||
// ends after the given location.
|
||||
auto iter = std::lower_bound(
|
||||
expandedChildren.begin(), expandedChildren.end(), Loc,
|
||||
Children.begin(), Children.end(), Loc,
|
||||
[&Ctx](TypeRefinementContext *context, SourceLoc loc) {
|
||||
return Ctx.SourceMgr.isBefore(context->getSourceRange().End, loc);
|
||||
});
|
||||
|
||||
// Check whether the matching child or any of its descendants contain
|
||||
// the given location.
|
||||
if (iter != expandedChildren.end()) {
|
||||
if (iter != Children.end()) {
|
||||
if (auto found = (*iter)->findMostRefinedSubContext(Loc, Ctx))
|
||||
return found;
|
||||
}
|
||||
@@ -478,18 +479,17 @@ void swift::simple_display(
|
||||
out << "TRC @" << trc;
|
||||
}
|
||||
|
||||
std::optional<std::vector<TypeRefinementContext *>>
|
||||
std::optional<evaluator::SideEffect>
|
||||
ExpandChildTypeRefinementContextsRequest::getCachedResult() const {
|
||||
auto *TRC = std::get<0>(getStorage());
|
||||
if (TRC->getNeedsExpansion())
|
||||
return std::nullopt;
|
||||
return TRC->Children;
|
||||
return evaluator::SideEffect();
|
||||
}
|
||||
|
||||
void ExpandChildTypeRefinementContextsRequest::cacheResult(
|
||||
std::vector<TypeRefinementContext *> children) const {
|
||||
evaluator::SideEffect sideEffect) const {
|
||||
auto *TRC = std::get<0>(getStorage());
|
||||
TRC->Children = children;
|
||||
TRC->setNeedsExpansion(false);
|
||||
}
|
||||
|
||||
|
||||
@@ -354,6 +354,7 @@ bool IDEInspectionInstance::performCachedOperationIfPossible(
|
||||
nullptr
|
||||
}
|
||||
);
|
||||
SM.recordSourceFile(newBufferID, AFD->getParentSourceFile());
|
||||
|
||||
AFD->setBodyToBeReparsed(newBodyRange);
|
||||
oldSF->clearScope();
|
||||
|
||||
@@ -1384,8 +1384,7 @@ TypeChecker::getOrBuildTypeRefinementContext(SourceFile *SF) {
|
||||
return TRC;
|
||||
}
|
||||
|
||||
std::vector<TypeRefinementContext *>
|
||||
ExpandChildTypeRefinementContextsRequest::evaluate(
|
||||
evaluator::SideEffect ExpandChildTypeRefinementContextsRequest::evaluate(
|
||||
Evaluator &evaluator, TypeRefinementContext *parentTRC) const {
|
||||
assert(parentTRC->getNeedsExpansion());
|
||||
if (auto decl = parentTRC->getDeclOrNull()) {
|
||||
@@ -1394,7 +1393,7 @@ ExpandChildTypeRefinementContextsRequest::evaluate(
|
||||
builder.prepareDeclForLazyExpansion(decl);
|
||||
builder.build(decl);
|
||||
}
|
||||
return parentTRC->Children;
|
||||
return evaluator::SideEffect();
|
||||
}
|
||||
|
||||
AvailabilityRange TypeChecker::overApproximateAvailabilityAtLocation(
|
||||
|
||||
23
test/SourceKit/CodeComplete/issue-76944.swift
Normal file
23
test/SourceKit/CodeComplete/issue-76944.swift
Normal file
@@ -0,0 +1,23 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
// RUN: split-file %s %t
|
||||
|
||||
//--- input.swift
|
||||
|
||||
//--- input2.swift
|
||||
func body() {
|
||||
|
||||
extension InvalidProto {}
|
||||
|
||||
//--- input3.swift
|
||||
func body() {
|
||||
|
||||
extension InvalidProto {}
|
||||
|
||||
struct MyStruct {
|
||||
|
||||
//--- dummy.swift
|
||||
|
||||
// RUN: %sourcekitd-test \
|
||||
// RUN: -req=open %t/input.swift -req-opts=syntactic_only=1 -print-raw-response == \
|
||||
// RUN: -req=typecontextinfo -pos=4:1 %t/input.swift -text-input %t/input2.swift -- %t/input.swift == \
|
||||
// RUN: -req=complete -pos=6:1 %t/input.swift -text-input %t/input3.swift -repeat-request 2 -- %t/input.swift
|
||||
Reference in New Issue
Block a user