Skip to content

Commit 6f6be1e

Browse files
authored
Merge pull request #19200 from rudkx/merge-closure-test
Merge closures_swift4.swift back into closures.swift.
2 parents 59fc174 + 6b96054 commit 6f6be1e

File tree

2 files changed

+17
-21
lines changed

2 files changed

+17
-21
lines changed

test/Constraints/closures.swift

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-typecheck-verify-swift -swift-version 4
1+
// RUN: %target-typecheck-verify-swift
22

33
func myMap<T1, T2>(_ array: [T1], _ fn: (T1) -> T2) -> [T2] {}
44

@@ -539,6 +539,15 @@ _ = ["hi"].compactMap { $0.isEmpty ? nil : $0 }
539539
// rdar://problem/32432145 - compiler should emit fixit to remove "_ in" in closures if 0 parameters is expected
540540

541541
func r32432145(_ a: () -> ()) {}
542+
543+
r32432145 { _ in let _ = 42 }
544+
// expected-error@-1 {{contextual closure type '() -> ()' expects 0 arguments, but 1 was used in closure body}} {{13-17=}}
545+
546+
r32432145 { _ in
547+
// expected-error@-1 {{contextual closure type '() -> ()' expects 0 arguments, but 1 was used in closure body}} {{13-17=}}
548+
print("answer is 42")
549+
}
550+
542551
r32432145 { _,_ in
543552
// expected-error@-1 {{contextual closure type '() -> ()' expects 0 arguments, but 2 were used in closure body}} {{13-19=}}
544553
print("answer is 42")
@@ -733,3 +742,10 @@ func takesTwoInOut(_: (Int, inout Int) -> ()) {}
733742

734743
takesTwo { _ in } // expected-error {{contextual closure type '(Int, Int) -> ()' expects 2 arguments, but 1 was used in closure body}}
735744
takesTwoInOut { _ in } // expected-error {{contextual closure type '(Int, inout Int) -> ()' expects 2 arguments, but 1 was used in closure body}}
745+
746+
// <rdar://problem/20371273> Type errors inside anonymous functions don't provide enough information
747+
func f20371273() {
748+
let x: [Int] = [1, 2, 3, 4]
749+
let y: UInt = 4
750+
_ = x.filter { ($0 + y) > 42 } // expected-error {{'+' is unavailable}}
751+
}

test/Constraints/closures_swift4.swift

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)