Skip to content

Commit dec3341

Browse files
authored
Merge pull request #17748 from rudkx/remove-swift3-from-some-tests
Remove -swift-version 3 from a handful of tests and update them appro…
2 parents 99cc322 + 5e75b1a commit dec3341

13 files changed

+84
-180
lines changed

test/Migrator/tuple-arguments.swift test/Constraints/tuple-arguments-supported.swift

+1-18
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,10 @@
1-
// RUN: %target-swift-frontend -typecheck %s -swift-version 3
2-
// RUN: %target-swift-frontend -typecheck -update-code -primary-file %s -emit-migrated-file-path %t.result -disable-migrator-fixits -swift-version 3
3-
// RUN: diff -u %s.expected %t.result
4-
// RUN: %target-swift-frontend -typecheck %s.expected -swift-version 4
1+
// RUN: %target-typecheck-verify-swift
52

63
func test1(_: ()) {}
74
test1(())
8-
test1()
95
func test2() {}
106
test2()
117

12-
enum Result<T> {
13-
case success(T)
14-
}
15-
func test3(_: Result<()>) {}
16-
test3(.success())
17-
188
func test4(_: (Int, Int) -> ()) {}
199
test4({ (x,y) in })
2010
func test5(_: (Int, Int, Int) -> ()) {}
@@ -44,10 +34,7 @@ func toString(indexes: Int?...) -> String {
4434
if index != nil {}
4535
return ""
4636
})
47-
let _ = indexes.reduce(0) { print($0); return $0.0 + ($0.1 ?? 0)}
48-
let _ = indexes.reduce(0) { (true ? $0 : (1, 2)).0 + ($0.1 ?? 0) }
4937
let _ = [(1, 2)].contains { $0 != $1 }
50-
_ = ["Hello", "Foo"].sorted { print($0); return $0.0.count > ($0).1.count }
5138
_ = ["Hello" : 2].map { ($0, ($1)) }
5239
}
5340

@@ -59,7 +46,3 @@ extension Dictionary {
5946

6047
let dictionary: [String: String] = [:]
6148
_ = dictionary.first { (column, value) in true }!.value
62-
63-
func doit(_ x: Int) -> Bool { return x > 0 }
64-
let _: ((String, Int)) -> [String:Bool] = { [$0: doit($1)] }
65-
func returnClosure() -> ((Int, Int)) -> Bool { return {$1 > $0} }
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// RUN: %target-typecheck-verify-swift
2+
3+
func test1(_: ()) {} // expected-note {{'test1' declared here}}
4+
test1() // expected-error {{missing argument for parameter #1 in call}}
5+
6+
enum Result<T> {
7+
case success(T) // expected-note {{'success' declared here}}
8+
}
9+
func test3(_: Result<()>) {}
10+
test3(.success()) // expected-error {{missing argument for parameter #1 in call}}
11+
12+
func toString(indexes: Int?...) -> String {
13+
let _ = indexes.reduce(0) { print($0); return $0.0 + ($0.1 ?? 0)}
14+
// expected-error@-1 {{contextual closure type '(_, Int?) throws -> _' expects 2 arguments, but 1 was used in closure body}}
15+
let _ = indexes.reduce(0) { (true ? $0 : (1, 2)).0 + ($0.1 ?? 0) }
16+
// expected-error@-1 {{contextual closure type '(_, Int?) throws -> _' expects 2 arguments, but 1 was used in closure body}}
17+
_ = ["Hello", "Foo"].sorted { print($0); return $0.0.count > ($0).1.count }
18+
// expected-error@-1 {{argument passed to call that takes no arguments}}
19+
}
20+
21+
func doit(_ x: Int) -> Bool { return x > 0 }
22+
let _: ((String, Int)) -> [String:Bool] = { [$0: doit($1)] }
23+
// expected-error@-1 {{closure tuple parameter '(String, Int)' does not support destructuring with implicit parameters}}
24+
func returnClosure() -> ((Int, Int)) -> Bool { return {$1 > $0} }
25+
// expected-error@-1 {{closure tuple parameter '(Int, Int)' does not support destructuring with implicit parameters}}

test/IDE/complete_func_reference.swift

+31-31
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
1-
// RUN: %target-swift-ide-test -swift-version 3 -code-completion -source-filename %s -code-completion-token=VOID_VOID_0 | %FileCheck %s -check-prefix=VOID_VOID
2-
// RUN: %target-swift-ide-test -swift-version 3 -code-completion -source-filename %s -code-completion-token=VOID_VOID_1 | %FileCheck %s -check-prefix=VOID_VOID
3-
// RUN: %target-swift-ide-test -swift-version 3 -code-completion -source-filename %s -code-completion-token=VOID_VOID_2 | %FileCheck %s -check-prefix=VOID_VOID
4-
// RUN: %target-swift-ide-test -swift-version 3 -code-completion -source-filename %s -code-completion-token=VOID_VOID_3 | %FileCheck %s -check-prefix=VOID_VOID
5-
// RUN: %target-swift-ide-test -swift-version 3 -code-completion -source-filename %s -code-completion-token=VOID_VOID_4 | %FileCheck %s -check-prefix=VOID_VOID
6-
// RUN: %target-swift-ide-test -swift-version 3 -code-completion -source-filename %s -code-completion-token=ANY_INT_0 | %FileCheck %s -check-prefix=ANY_INT
7-
// RUN: %target-swift-ide-test -swift-version 3 -code-completion -source-filename %s -code-completion-token=ANY_INT_1 | %FileCheck %s -check-prefix=ANY_INT
8-
// RUN: %target-swift-ide-test -swift-version 3 -code-completion -source-filename %s -code-completion-token=ANY_INT_2 > %t.results
1+
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=VOID_VOID_0 | %FileCheck %s -check-prefix=VOID_VOID
2+
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=VOID_VOID_1 | %FileCheck %s -check-prefix=VOID_VOID
3+
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=VOID_VOID_2 | %FileCheck %s -check-prefix=VOID_VOID
4+
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=VOID_VOID_3 | %FileCheck %s -check-prefix=VOID_VOID
5+
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=VOID_VOID_4 | %FileCheck %s -check-prefix=VOID_VOID
6+
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=ANY_INT_0 | %FileCheck %s -check-prefix=ANY_INT
7+
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=ANY_INT_1 | %FileCheck %s -check-prefix=ANY_INT
8+
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=ANY_INT_2 > %t.results
99
// RUN:%FileCheck %s -check-prefix=ANY_INT < %t.results
1010
// RUN:%FileCheck %s -check-prefix=ANY_INT_STATIC_CURRY < %t.results
11-
// RUN: %target-swift-ide-test -swift-version 3 -code-completion -source-filename %s -code-completion-token=ANY_INT_3 | %FileCheck %s -check-prefix=ANY_INT
12-
// RUN: %target-swift-ide-test -swift-version 3 -code-completion -source-filename %s -code-completion-token=ANY_INT_4 | %FileCheck %s -check-prefix=ANY_INT
13-
// RUN: %target-swift-ide-test -swift-version 3 -code-completion -source-filename %s -code-completion-token=INT_ANY_0 | %FileCheck %s -check-prefix=INT_ANY
14-
// RUN: %target-swift-ide-test -swift-version 3 -code-completion -source-filename %s -code-completion-token=INT_ANY_1 | %FileCheck %s -check-prefix=INT_ANY
15-
// RUN: %target-swift-ide-test -swift-version 3 -code-completion -source-filename %s -code-completion-token=INT_ANY_2 > %t.results
11+
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=ANY_INT_3 | %FileCheck %s -check-prefix=ANY_INT
12+
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=ANY_INT_4 | %FileCheck %s -check-prefix=ANY_INT
13+
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=INT_ANY_0 | %FileCheck %s -check-prefix=INT_ANY
14+
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=INT_ANY_1 | %FileCheck %s -check-prefix=INT_ANY
15+
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=INT_ANY_2 > %t.results
1616
// RUN: %FileCheck %s -check-prefix=INT_ANY < %t.results
1717
// RUN: %FileCheck %s -check-prefix=INT_ANY_STATIC_CURRY < %t.results
18-
// RUN: %target-swift-ide-test -swift-version 3 -code-completion -source-filename %s -code-completion-token=INT_ANY_3 > %t.results
19-
// RUN: %target-swift-ide-test -swift-version 3 -code-completion -source-filename %s -code-completion-token=VOID_INT_INT_0 | %FileCheck %s -check-prefix=VOID_INT_INT
20-
// RUN: %target-swift-ide-test -swift-version 3 -code-completion -source-filename %s -code-completion-token=VOID_INT_INT_1 | %FileCheck %s -check-prefix=VOID_INT_INT
21-
// RUN: %target-swift-ide-test -swift-version 3 -code-completion -source-filename %s -code-completion-token=VOID_INT_INT_2 | %FileCheck %s -check-prefix=VOID_INT_INT
18+
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=INT_ANY_3 > %t.results
19+
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=VOID_INT_INT_0 | %FileCheck %s -check-prefix=VOID_INT_INT
20+
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=VOID_INT_INT_1 | %FileCheck %s -check-prefix=VOID_INT_INT
21+
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=VOID_INT_INT_2 | %FileCheck %s -check-prefix=VOID_INT_INT
2222

2323
func voidToVoid() {}
2424
func voidToInt() -> Int {}
@@ -122,7 +122,7 @@ do {
122122
}
123123

124124
// ANY_INT: Begin completions
125-
// ANY_INT-DAG: Decl{{.*}}/TypeRelation[Convertible]: anyToInt(a:);
125+
// ANY_INT-DAG: Decl{{.*}}: anyToInt({#a: Any#})[#Int#]; name=anyToInt(a: Any)
126126
// ANY_INT-DAG: Decl{{.*}}/NotRecommended/TypeRelation[Invalid]: intToVoid({#a: Int#})[#Void#];
127127
// ANY_INT-DAG: Decl{{.*}}/NotRecommended/TypeRelation[Invalid]: anyToVoid({#a: Any#})[#Void#];
128128
// ANY_INT-DAG: Decl{{.*}}/NotRecommended/TypeRelation[Invalid]: voidToVoid()[#Void#];
@@ -135,7 +135,7 @@ do {
135135
// ANY_INT: End completions
136136

137137
// ANY_INT_STATIC_CURRY: Begin completions
138-
// ANY_INT_STATIC_CURRY-DAG: Decl[InstanceMethod]/CurrNominal/TypeRelation[Convertible]: anyToInt({#self: S0#})[#(a: Any) -> Int#];
138+
// ANY_INT_STATIC_CURRY-DAG: Decl[InstanceMethod]/CurrNominal: anyToInt({#self: S0#})[#(a: Any) -> Int#]; name=anyToInt(S0)
139139
// ANY_INT_STATIC_CURRY-DAG: Decl[InstanceMethod]/CurrNominal/NotRecommended/TypeRelation[Invalid]: voidToVoid({#self: S0#})[#() -> Void#];
140140
// ANY_INT_STATIC_CURRY-DAG: Decl[InstanceMethod]/CurrNominal/NotRecommended/TypeRelation[Invalid]: intToVoid({#self: S0#})[#(a: Int) -> Void#];
141141
// ANY_INT_STATIC_CURRY-DAG: Decl[InstanceMethod]/CurrNominal/NotRecommended/TypeRelation[Invalid]: anyToVoid({#self: S0#})[#(a: Any) -> Void#];
@@ -153,25 +153,25 @@ do {
153153
}
154154

155155
// INT_ANY: Begin completions
156-
// INT_ANY-DAG: Decl{{.*}}/TypeRelation[Convertible]: intToAny(a:);
157-
// INT_ANY-DAG: Decl{{.*}}/TypeRelation[Convertible]: intToInt(a:);
158-
// INT_ANY-DAG: Decl{{.*}}/TypeRelation[Convertible]: intToVoid(a:);
159-
// INT_ANY-DAG: Decl{{.*}}/TypeRelation[Convertible]: anyToAny(a:);
160-
// INT_ANY-DAG: Decl{{.*}}/TypeRelation[Convertible]: anyToInt(a:);
161-
// INT_ANY-DAG: Decl{{.*}}/TypeRelation[Convertible]: anyToVoid(a:);
156+
// INT_ANY-DAG: Decl{{.*}}: intToAny({#a: Int#})[#Any#]; name=intToAny(a: Int)
157+
// INT_ANY-DAG: Decl{{.*}}: intToInt({#a: Int#})[#Int#]; name=intToInt(a: Int)
158+
// INT_ANY-DAG: Decl{{.*}}: intToVoid({#a: Int#})[#Void#]; name=intToVoid(a: Int)
159+
// INT_ANY-DAG: Decl{{.*}}: anyToAny({#a: Any#})[#Any#]; name=anyToAny(a: Any)
160+
// INT_ANY-DAG: Decl{{.*}}: anyToInt({#a: Any#})[#Int#]; name=anyToInt(a: Any)
161+
// INT_ANY-DAG: Decl{{.*}}: anyToVoid({#a: Any#})[#Void#]; name=anyToVoid(a: Any)
162162
// INT_ANY-DAG: Decl{{.*}}/TypeRelation[Convertible]: returnsIntToInt()[#(Int) -> Int#];
163163
// INT_ANY-DAG: Decl{{.*}}/NotRecommended/TypeRelation[Invalid]: voidToVoid()[#Void#];
164164
// INT_ANY-DAG: Decl{{.*}}: voidToInt()[#Int#];
165165
// INT_ANY-DAG: Decl{{.*}}: voidToAny()[#Any#];
166166
// INT_ANY: End completions
167167

168168
// INT_ANY_STATIC_CURRY: Begin completions
169-
// INT_ANY_STATIC_CURRY-DAG: Decl[InstanceMethod]/CurrNominal/TypeRelation[Convertible]: intToInt({#self: S0#})[#(a: Int) -> Int#];
170-
// INT_ANY_STATIC_CURRY-DAG: Decl[InstanceMethod]/CurrNominal/TypeRelation[Convertible]: intToVoid({#self: S0#})[#(a: Int) -> Void#];
171-
// INT_ANY_STATIC_CURRY-DAG: Decl[InstanceMethod]/CurrNominal/TypeRelation[Convertible]: anyToAny({#self: S0#})[#(a: Any) -> Any#];
172-
// INT_ANY_STATIC_CURRY-DAG: Decl[InstanceMethod]/CurrNominal/TypeRelation[Convertible]: anyToVoid({#self: S0#})[#(a: Any) -> Void#];
173-
// INT_ANY_STATIC_CURRY-DAG: Decl[InstanceMethod]/CurrNominal/TypeRelation[Convertible]: intToAny({#self: S0#})[#(a: Int) -> Any#];
174-
// INT_ANY_STATIC_CURRY-DAG: Decl[InstanceMethod]/CurrNominal/TypeRelation[Convertible]: anyToInt({#self: S0#})[#(a: Any) -> Int#];
169+
// INT_ANY_STATIC_CURRY-DAG: Decl[InstanceMethod]/CurrNominal: intToInt({#self: S0#})[#(a: Int) -> Int#]; name=intToInt(S0)
170+
// INT_ANY_STATIC_CURRY-DAG: Decl[InstanceMethod]/CurrNominal/NotRecommended/TypeRelation[Invalid]: intToVoid({#self: S0#})[#(a: Int) -> Void#]; name=intToVoid(S0)
171+
// INT_ANY_STATIC_CURRY-DAG: Decl[InstanceMethod]/CurrNominal: anyToAny({#self: S0#})[#(a: Any) -> Any#]; name=anyToAny(S0)
172+
// INT_ANY_STATIC_CURRY-DAG: Decl[InstanceMethod]/CurrNominal/NotRecommended/TypeRelation[Invalid]: anyToVoid({#self: S0#})[#(a: Any) -> Void#]; name=anyToVoid(S0)
173+
// INT_ANY_STATIC_CURRY-DAG: Decl[InstanceMethod]/CurrNominal: intToAny({#self: S0#})[#(a: Int) -> Any#]; name=intToAny(S0)
174+
// INT_ANY_STATIC_CURRY-DAG: Decl[InstanceMethod]/CurrNominal: anyToInt({#self: S0#})[#(a: Any) -> Int#]; name=anyToInt(S0)
175175
// INT_ANY_STATIC_CURRY-DAG: Decl[InstanceMethod]/CurrNominal/TypeRelation[Convertible]: returnsIntToInt({#self: S0#})[#() -> (Int) -> Int#];
176176
// INT_ANY_STATIC_CURRY-DAG: Decl[InstanceMethod]/CurrNominal: voidToAny({#self: S0#})[#() -> Any#];
177177
// INT_ANY_STATIC_CURRY-DAG: Decl[InstanceMethod]/CurrNominal: voidToInt({#self: S0#})[#() -> Int#];

test/Interpreter/currying_generics.swift

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-run-simple-swift-swift3 | %FileCheck %s
1+
// RUN: %target-run-simple-swift | %FileCheck %s
22
// REQUIRES: executable_test
33

44
func curry<T, U, V>(_ f: @escaping (T, U) -> V) -> (T) -> (U) -> V {
@@ -120,8 +120,8 @@ func <+><T,U,V> (lhs: T?, rhs: @escaping (T) -> (U) -> V) -> (U) -> V? {
120120

121121
let a : Int? = 23
122122
let b : Int? = 42
123-
print((b <+> pair)(a!)) // CHECK-NEXT: (42, 23)
124-
print((b <+> pair_)(a!)) // CHECK-NEXT: (42, 23)
123+
print((b <+> pair)(a!) as Any) // CHECK-NEXT: (42, 23)
124+
print((b <+> pair_)(a!) as Any) // CHECK-NEXT: (42, 23)
125125

126126
//
127127
// rdar://problem/20475584
@@ -172,12 +172,12 @@ func set<S, A>(_ lens: @escaping (@escaping (A) -> Identity<A>) -> (S) -> (@esca
172172
return { x in { y in over(lens)(const(x))(y) } }
173173
}
174174

175-
func _1<A, B, C, D>(_ f: @escaping (A) -> C) -> (A, B) -> (@escaping (@escaping (A) -> (A, B)) -> (C) -> D) -> D {
176-
return { (x, y) in { fmap in fmap({ ($0, y) })(f(x)) } }
175+
func _1<A, B, C, D>(_ f: @escaping (A) -> C) -> ((A, B)) -> (@escaping (@escaping (A) -> (A, B)) -> (C) -> D) -> D {
176+
return { pair in { fmap in fmap({ ($0, pair.1) })(f(pair.0)) } }
177177
}
178178

179-
func _2<A, B, C, D>(_ f: @escaping (B) -> C) -> (A, B) -> (@escaping (@escaping (B) -> (A, B)) -> (C) -> D) -> D {
180-
return { (x, y) in { fmap in fmap({ (x, $0) })(f(y)) } }
179+
func _2<A, B, C, D>(_ f: @escaping (B) -> C) -> ((A, B)) -> (@escaping (@escaping (B) -> (A, B)) -> (C) -> D) -> D {
180+
return { pair in { fmap in fmap({ (pair.0, $0) })(f(pair.1)) } }
181181
}
182182

183183

@@ -199,6 +199,6 @@ let pt2 = over(_1)({ $0 * 4 })((1, 2))
199199
print(pt2) // CHECK-NEXT: (4, 2)
200200
let pt3 = set(_1)(3)((1, 2))
201201
print(pt3) // CHECK-NEXT: (3, 2)
202-
let pt4 = view(_2)("hello", 5)
202+
let pt4 = view(_2)(("hello", 5))
203203
print(pt4) // CHECK-NEXT: 5
204204

test/Migrator/Inputs/ignore_type_placeholder.swift

-3
This file was deleted.

test/Migrator/fixit_void.swift

-17
This file was deleted.

test/Migrator/fixit_void.swift.expected

-17
This file was deleted.

test/Migrator/ignore_type_placeholder.swift

-3
This file was deleted.

test/Migrator/tuple-arguments.swift.expected

-65
This file was deleted.

test/Prototypes/Result.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
1010
//
1111
//===----------------------------------------------------------------------===//
12-
// RUN: %target-run-stdlib-swift-swift3
12+
// RUN: %target-run-stdlib-swift
1313
// REQUIRES: executable_test
1414

1515
public enum Result<Value> {
@@ -138,8 +138,8 @@ func mayFail(_ fail: Bool) throws -> Int {
138138
print(catchResult { try mayFail(true) })
139139
print(catchResult { try mayFail(false) })
140140

141-
print(catchResult { _ in 1 }.flatMap { _ in Result(success: 4) }.flatMap { _ in Result<String>(error: Icky.Poor) })
142-
print(catchResult { _ in 1 }.map { _ in three }.flatMap {$0} )
141+
print(catchResult { 1 }.flatMap { _ in Result(success: 4) }.flatMap { _ in Result<String>(error: Icky.Poor) })
142+
print(catchResult { 1 }.map { _ in three }.flatMap {$0} )
143143

144144
let results = [three, nasty, four]
145145
print(results.flatMap { $0.success })

test/stdlib/Inputs/DictionaryKeyValueTypesObjC.swift

+2-1
Original file line numberDiff line numberDiff line change
@@ -874,7 +874,8 @@ typealias AnyObjectTuple2 = (AnyObject, AnyObject)
874874
for i in 0..<3 {
875875
var actualContents = [ExpectedDictionaryElement]()
876876
let sink: (AnyObjectTuple2) -> Void = {
877-
(key, value) in
877+
pair in
878+
let (key, value) = pair
878879
actualContents.append(ExpectedDictionaryElement(
879880
key: convertKey(key),
880881
value: convertValue(value),

validation-test/compiler_crashers_fixed/26813-generic-enum-tuple-optional-payload.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// This source file is part of the Swift.org open source project
22
//
3-
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
3+
// Copyright (c) 2014 - 2018 Apple Inc. and the Swift project authors
44
// Licensed under Apache License v2.0 with Runtime Library Exception
55
//
66
// See https://swift.org/LICENSE.txt for license information

0 commit comments

Comments
 (0)