Skip to content
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
1 change: 0 additions & 1 deletion include/swift/IDE/CodeCompletion.h
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,6 @@ enum class CompletionKind {
AttributeBegin,
AttributeDeclParen,
PoundAvailablePlatform,
AssignmentRHS,
CallArg,
ReturnStmtExpr,
YieldStmtExpr,
Expand Down
2 changes: 0 additions & 2 deletions include/swift/Parse/CodeCompletionCallbacks.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,6 @@ class CodeCompletionCallbacks {
virtual void completeUnresolvedMember(CodeCompletionExpr *E,
SourceLoc DotLoc) {};

virtual void completeAssignmentRHS(AssignExpr *E) {};

virtual void completeCallArg(CodeCompletionExpr *E, bool isFirst) {};

virtual void completeReturnStmt(CodeCompletionExpr *E) {};
Expand Down
18 changes: 0 additions & 18 deletions lib/IDE/CodeCompletion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1213,7 +1213,6 @@ class CodeCompletionCallbacksImpl : public CodeCompletionCallbacks {
std::vector<RequestedCachedModule> RequestedModules;
CodeCompletionConsumer &Consumer;
CodeCompletionExpr *CodeCompleteTokenExpr = nullptr;
AssignExpr *AssignmentExpr;
CompletionKind Kind = CompletionKind::None;
Expr *ParsedExpr = nullptr;
SourceLoc DotLoc;
Expand Down Expand Up @@ -1367,7 +1366,6 @@ class CodeCompletionCallbacksImpl : public CodeCompletionCallbacks {
void completeImportDecl(std::vector<std::pair<Identifier, SourceLoc>> &Path) override;
void completeUnresolvedMember(CodeCompletionExpr *E,
SourceLoc DotLoc) override;
void completeAssignmentRHS(AssignExpr *E) override;
void completeCallArg(CodeCompletionExpr *E, bool isFirst) override;
void completeReturnStmt(CodeCompletionExpr *E) override;
void completeYieldStmt(CodeCompletionExpr *E,
Expand Down Expand Up @@ -4671,13 +4669,6 @@ void CodeCompletionCallbacksImpl::completeUnresolvedMember(CodeCompletionExpr *E
this->DotLoc = DotLoc;
}

void CodeCompletionCallbacksImpl::completeAssignmentRHS(AssignExpr *E) {
AssignmentExpr = E;
ParsedExpr = E->getDest();
CurDeclContext = P.CurDeclContext;
Kind = CompletionKind::AssignmentRHS;
}

void CodeCompletionCallbacksImpl::completeCallArg(CodeCompletionExpr *E,
bool isFirst) {
CurDeclContext = P.CurDeclContext;
Expand Down Expand Up @@ -4906,7 +4897,6 @@ void CodeCompletionCallbacksImpl::addKeywords(CodeCompletionResultSink &Sink,
addDeclKeywords(Sink);
addStmtKeywords(Sink, MaybeFuncBody);
LLVM_FALLTHROUGH;
case CompletionKind::AssignmentRHS:
case CompletionKind::ReturnStmtExpr:
case CompletionKind::YieldStmtExpr:
case CompletionKind::PostfixExprBeginning:
Expand Down Expand Up @@ -5373,14 +5363,6 @@ void CodeCompletionCallbacksImpl::doneParsing() {
Lookup.getUnresolvedMemberCompletions(ContextInfo.getPossibleTypes());
break;
}
case CompletionKind::AssignmentRHS : {
SourceLoc Loc = P.Context.SourceMgr.getCodeCompletionLoc();
if (auto destType = ParsedExpr->getType())
Lookup.setExpectedTypes(destType->getRValueType(),
/*isSingleExpressionBody*/ false);
Lookup.getValueCompletionsInDeclContext(Loc, DefaultFilter);
break;
}
case CompletionKind::CallArg : {
ExprContextInfo ContextInfo(CurDeclContext, CodeCompleteTokenExpr);

Expand Down
22 changes: 0 additions & 22 deletions lib/Parse/ParseExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,28 +279,6 @@ ParserResult<Expr> Parser::parseExprSequence(Diag<> Message,
auto *assign = new (Context) AssignExpr(equalsLoc);
SequencedExprs.push_back(assign);
Message = diag::expected_expr_assignment;
if (Tok.is(tok::code_complete)) {
if (CodeCompletion) {
auto RHS = new (Context) ErrorExpr(
SourceRange(Tok.getRange().getStart(), Tok.getRange().getEnd()));
assign->setSrc(RHS);
SequencedExprs.pop_back();
assign->setDest(SequencedExprs.back());
SequencedExprs.pop_back();
SequencedExprs.push_back(assign);
CodeCompletion->completeAssignmentRHS(assign);
}
consumeToken();
if (!SequencedExprs.empty() && (SequencedExprs.size() & 1) == 0) {
// Make sure we have odd number of sequence exprs.
SequencedExprs.pop_back();
}
auto Result = SequencedExprs.size() == 1 ?
makeParserResult(SequencedExprs[0]):
makeParserResult(SequenceExpr::create(Context, SequencedExprs));
Result.setHasCodeCompletion();
return Result;
}
break;
}

Expand Down
50 changes: 50 additions & 0 deletions test/IDE/complete_associated_types.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=BROKEN_CONFORMANCE_1 > %t.types.txt
// RUN: %FileCheck %s -check-prefix=BROKEN_CONFORMANCE_1 < %t.types.txt

// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=BROKEN_CONFORMANCE_UNASSIGNABLE > %t.types.txt
// RUN: %FileCheck %s -check-prefix=BROKEN_CONFORMANCE_UNASSIGNABLE < %t.types.txt

// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=BROKEN_CONFORMANCE_UNASSIGNABLE_2 > %t.types.txt
// RUN: %FileCheck %s -check-prefix=BROKEN_CONFORMANCE_UNASSIGNABLE < %t.types.txt

// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=BROKEN_CONFORMANCE_ASSIGNABLE > %t.types.txt
// RUN: %FileCheck %s -check-prefix=BROKEN_CONFORMANCE_ASSIGNABLE < %t.types.txt

// FIXME: extensions that introduce conformances?

protocol FooBaseProtocolWithAssociatedTypes {
Expand Down Expand Up @@ -300,3 +309,44 @@ func testBrokenConformances1() {
// BROKEN_CONFORMANCE_1-DAG: Decl[InstanceMethod]/Super: deduceFooBaseC({#(self): StructWithBrokenConformance#})[#() -> StructWithBrokenConformance.FooBaseDeducedTypeC#]{{; name=.+$}}
// BROKEN_CONFORMANCE_1-DAG: Decl[InstanceMethod]/Super: deduceFooBaseD({#(self): StructWithBrokenConformance#})[#() -> StructWithBrokenConformance.FooBaseDeducedTypeD#]{{; name=.+$}}
// BROKEN_CONFORMANCE_1: End completions


protocol MyProto {
associatedtype Element
}

extension MyProto {
var matches: (Int, (Int, Int)) { fatalError() }
func first() -> Element {
fatalError()
}
}

// Does not conform - Element not specified
struct A<T>: MyProto {
func foo() {
self.first = #^BROKEN_CONFORMANCE_UNASSIGNABLE^#
}

func foo2() {
var (a, b): (Int, Int)
let exact = (1, (2, 4))
(a, (b, self.first)) = #^BROKEN_CONFORMANCE_UNASSIGNABLE_2^#
}

func foo3() {
var (a, b, c): (Int, Int, Int)
let exact = (1, (2, 4))
(a, (b, c)) = #^BROKEN_CONFORMANCE_ASSIGNABLE^#
}
}
// BROKEN_CONFORMANCE_UNASSIGNABLE: Begin completions
// BROKEN_CONFORMANCE_UNASSIGNABLE-NOT: TypeRelation
// BROKEN_CONFORMANCE_UNASSIGNABLE: Decl[InstanceMethod]/Super: first()[#MyProto.Element#]; name=first()
// BROKEN_CONFORMANCE_UNASSIGNABLE-NOT: TypeRelation
// BROKEN_CONFORMANCE_UNASSIGNABLE: End completions

// BROKEN_CONFORMANCE_ASSIGNABLE: Begin completions
// BROKEN_CONFORMANCE_ASSIGNABLE-DAG: Decl[LocalVar]/Local/TypeRelation[Identical]: exact[#(Int, (Int, Int))#]; name=exact
// BROKEN_CONFORMANCE_ASSIGNABLE-DAG: Decl[InstanceVar]/Super/TypeRelation[Identical]: matches[#(Int, (Int, Int))#]; name=matches
// BROKEN_CONFORMANCE_ASSIGNABLE: End completions
1 change: 0 additions & 1 deletion tools/SourceKit/lib/SwiftLang/CodeCompletionOrganizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ bool SourceKit::CodeCompletion::addCustomCompletions(
}
break;
case CompletionKind::PostfixExprBeginning:
case CompletionKind::AssignmentRHS:
case CompletionKind::CallArg:
case CompletionKind::ReturnStmtExpr:
case CompletionKind::YieldStmtExpr:
Expand Down