From 6b96054159dfe1886cff03b516cd8f3f9327fd9c Mon Sep 17 00:00:00 2001 From: Mark Lacey Date: Fri, 7 Sep 2018 11:13:46 -0700 Subject: [PATCH] Merge closures_swift4.swift back into closures.swift. This should have happened when closures_swift3.swift was removed. --- test/Constraints/closures.swift | 18 +++++++++++++++++- test/Constraints/closures_swift4.swift | 20 -------------------- 2 files changed, 17 insertions(+), 21 deletions(-) delete mode 100644 test/Constraints/closures_swift4.swift diff --git a/test/Constraints/closures.swift b/test/Constraints/closures.swift index 1b962e9e6d123..132bec162bff1 100644 --- a/test/Constraints/closures.swift +++ b/test/Constraints/closures.swift @@ -1,4 +1,4 @@ -// RUN: %target-typecheck-verify-swift -swift-version 4 +// RUN: %target-typecheck-verify-swift func myMap(_ array: [T1], _ fn: (T1) -> T2) -> [T2] {} @@ -539,6 +539,15 @@ _ = ["hi"].compactMap { $0.isEmpty ? nil : $0 } // rdar://problem/32432145 - compiler should emit fixit to remove "_ in" in closures if 0 parameters is expected func r32432145(_ a: () -> ()) {} + +r32432145 { _ in let _ = 42 } +// expected-error@-1 {{contextual closure type '() -> ()' expects 0 arguments, but 1 was used in closure body}} {{13-17=}} + +r32432145 { _ in + // expected-error@-1 {{contextual closure type '() -> ()' expects 0 arguments, but 1 was used in closure body}} {{13-17=}} + print("answer is 42") +} + r32432145 { _,_ in // expected-error@-1 {{contextual closure type '() -> ()' expects 0 arguments, but 2 were used in closure body}} {{13-19=}} print("answer is 42") @@ -733,3 +742,10 @@ func takesTwoInOut(_: (Int, inout Int) -> ()) {} takesTwo { _ in } // expected-error {{contextual closure type '(Int, Int) -> ()' expects 2 arguments, but 1 was used in closure body}} takesTwoInOut { _ in } // expected-error {{contextual closure type '(Int, inout Int) -> ()' expects 2 arguments, but 1 was used in closure body}} + +// Type errors inside anonymous functions don't provide enough information +func f20371273() { + let x: [Int] = [1, 2, 3, 4] + let y: UInt = 4 + _ = x.filter { ($0 + y) > 42 } // expected-error {{'+' is unavailable}} +} diff --git a/test/Constraints/closures_swift4.swift b/test/Constraints/closures_swift4.swift deleted file mode 100644 index 8e124740c1b09..0000000000000 --- a/test/Constraints/closures_swift4.swift +++ /dev/null @@ -1,20 +0,0 @@ -// RUN: %target-typecheck-verify-swift -swift-version 4 - -// Type errors inside anonymous functions don't provide enough information -func f20371273() { - let x: [Int] = [1, 2, 3, 4] - let y: UInt = 4 - _ = x.filter { ($0 + y) > 42 } // expected-error {{'+' is unavailable}} -} - -// rdar://problem/32432145 - compiler should emit fixit to remove "_ in" in closures if 0 parameters is expected - -func r32432145(_ a: () -> ()) {} - -r32432145 { _ in let _ = 42 } -// expected-error@-1 {{contextual closure type '() -> ()' expects 0 arguments, but 1 was used in closure body}} {{13-17=}} - -r32432145 { _ in - // expected-error@-1 {{contextual closure type '() -> ()' expects 0 arguments, but 1 was used in closure body}} {{13-17=}} - print("answer is 42") -}