mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[code-completion] Handle func-reference syntax for optional expected type
The underlying type-check was correct, but I forgot to consider it in the outer code, and embarassingly never tested this case. rdar://problem/28435922
This commit is contained in:
@@ -1652,7 +1652,9 @@ private:
|
|||||||
return true;
|
return true;
|
||||||
bool isImplicitlyCurriedIM = isImplicitlyCurriedInstanceMethod(D);
|
bool isImplicitlyCurriedIM = isImplicitlyCurriedInstanceMethod(D);
|
||||||
for (auto expectedType : ExpectedTypes) {
|
for (auto expectedType : ExpectedTypes) {
|
||||||
if (expectedType && expectedType->is<AnyFunctionType>() &&
|
if (expectedType &&
|
||||||
|
expectedType->lookThroughAllAnyOptionalTypes()
|
||||||
|
->is<AnyFunctionType>() &&
|
||||||
calculateTypeRelationForDecl(D, expectedType, isImplicitlyCurriedIM,
|
calculateTypeRelationForDecl(D, expectedType, isImplicitlyCurriedIM,
|
||||||
/*UseFuncResult=*/false) >=
|
/*UseFuncResult=*/false) >=
|
||||||
CodeCompletionResult::ExpectedTypeRelation::Convertible) {
|
CodeCompletionResult::ExpectedTypeRelation::Convertible) {
|
||||||
|
|||||||
@@ -8,11 +8,14 @@
|
|||||||
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=ANY_INT_2 > %t.results
|
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=ANY_INT_2 > %t.results
|
||||||
// RUN:%FileCheck %s -check-prefix=ANY_INT < %t.results
|
// RUN:%FileCheck %s -check-prefix=ANY_INT < %t.results
|
||||||
// RUN:%FileCheck %s -check-prefix=ANY_INT_STATIC_CURRY < %t.results
|
// RUN:%FileCheck %s -check-prefix=ANY_INT_STATIC_CURRY < %t.results
|
||||||
|
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=ANY_INT_3 | %FileCheck %s -check-prefix=ANY_INT
|
||||||
|
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=ANY_INT_4 | %FileCheck %s -check-prefix=ANY_INT
|
||||||
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=INT_ANY_0 | %FileCheck %s -check-prefix=INT_ANY
|
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=INT_ANY_0 | %FileCheck %s -check-prefix=INT_ANY
|
||||||
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=INT_ANY_1 | %FileCheck %s -check-prefix=INT_ANY
|
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=INT_ANY_1 | %FileCheck %s -check-prefix=INT_ANY
|
||||||
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=INT_ANY_2 > %t.results
|
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=INT_ANY_2 > %t.results
|
||||||
// RUN: %FileCheck %s -check-prefix=INT_ANY < %t.results
|
// RUN: %FileCheck %s -check-prefix=INT_ANY < %t.results
|
||||||
// RUN: %FileCheck %s -check-prefix=INT_ANY_STATIC_CURRY < %t.results
|
// RUN: %FileCheck %s -check-prefix=INT_ANY_STATIC_CURRY < %t.results
|
||||||
|
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=INT_ANY_3 > %t.results
|
||||||
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=VOID_INT_INT_0 | %FileCheck %s -check-prefix=VOID_INT_INT
|
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=VOID_INT_INT_0 | %FileCheck %s -check-prefix=VOID_INT_INT
|
||||||
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=VOID_INT_INT_1 | %FileCheck %s -check-prefix=VOID_INT_INT
|
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=VOID_INT_INT_1 | %FileCheck %s -check-prefix=VOID_INT_INT
|
||||||
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=VOID_INT_INT_2 | %FileCheck %s -check-prefix=VOID_INT_INT
|
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=VOID_INT_INT_2 | %FileCheck %s -check-prefix=VOID_INT_INT
|
||||||
@@ -109,6 +112,14 @@ do {
|
|||||||
func take(_: @escaping (Any)->Int) {}
|
func take(_: @escaping (Any)->Int) {}
|
||||||
take(S0.#^ANY_INT_2^#)
|
take(S0.#^ANY_INT_2^#)
|
||||||
}
|
}
|
||||||
|
do {
|
||||||
|
func take(_: @escaping ((Any)->Int)???!) {}
|
||||||
|
take(S0().#^ANY_INT_3^#)
|
||||||
|
}
|
||||||
|
do {
|
||||||
|
let take: ((Any)->Int)?
|
||||||
|
take = S0().#^ANY_INT_4^#
|
||||||
|
}
|
||||||
|
|
||||||
// ANY_INT: Begin completions
|
// ANY_INT: Begin completions
|
||||||
// ANY_INT-DAG: Decl{{.*}}/TypeRelation[Convertible]: anyToInt(a:);
|
// ANY_INT-DAG: Decl{{.*}}/TypeRelation[Convertible]: anyToInt(a:);
|
||||||
@@ -174,6 +185,10 @@ do {
|
|||||||
func take(_: @escaping (Int)->Any) {}
|
func take(_: @escaping (Int)->Any) {}
|
||||||
take(S0.#^INT_ANY_2^#)
|
take(S0.#^INT_ANY_2^#)
|
||||||
}
|
}
|
||||||
|
do {
|
||||||
|
func take(_: @escaping ((Int)->Any)?) {}
|
||||||
|
take(S0.#^INT_ANY_3^#)
|
||||||
|
}
|
||||||
|
|
||||||
do {
|
do {
|
||||||
func take(_: @escaping ()->(Int)->Int) {}
|
func take(_: @escaping ()->(Int)->Int) {}
|
||||||
|
|||||||
Reference in New Issue
Block a user