diff --git a/lib/IDE/CodeCompletion.cpp b/lib/IDE/CodeCompletion.cpp index 792fdd7f387..3c42c606bc2 100644 --- a/lib/IDE/CodeCompletion.cpp +++ b/lib/IDE/CodeCompletion.cpp @@ -3087,7 +3087,7 @@ public: } if (leadingSequence.empty() && LHS->getType() && - LHS->getType()->isAssignableType()) { + LHS->getType()->isLValueType()) { addAssignmentOperator(LHS->getType()->getRValueType(), CurrDeclContext->getASTContext().TheEmptyTupleType); } diff --git a/test/IDE/complete_operators.swift b/test/IDE/complete_operators.swift index 5874e2b8996..a45e6026b62 100644 --- a/test/IDE/complete_operators.swift +++ b/test/IDE/complete_operators.swift @@ -55,6 +55,7 @@ // RUN: %target-swift-ide-test -code-completion -source-filename=%s -code-completion-token=EXT_INFIX_4 | FileCheck %s -check-prefix=S4_EXT_INFIX_SIMPLE // RUN: %target-swift-ide-test -code-completion -source-filename=%s -code-completion-token=ASSIGN_TUPLE_1| FileCheck %s -check-prefix=ASSIGN_TUPLE_1 // RUN: %target-swift-ide-test -code-completion -source-filename=%s -code-completion-token=ASSIGN_TUPLE_2| FileCheck %s -check-prefix=ASSIGN_TUPLE_2 +// RUN: %target-swift-ide-test -code-completion -source-filename=%s -code-completion-token=ASSIGN_TUPLE_3| FileCheck %s -check-prefix=ASSIGN_TUPLE_1 struct S {} postfix operator ++ {} @@ -343,7 +344,14 @@ func testExtInfix4(x: S4) { func testAssignTuple1() { ()#^ASSIGN_TUPLE_1^# } -// ASSIGN_TUPLE_1: Pattern/None: = {#()#}[#Void#]; +func testAssignTuple3() { + func void() {} + void()#^ASSIGN_TUPLE_3^# +} +// FIXME: technically this is sometimes legal, but we would need to +// differentiate between casese like () = and print() =. Since it's not very +// useful anyway, just omit the completion. +// ASSIGN_TUPLE_1-NOT: Pattern/None: = { func testAssignTuple2() { var x: S2