Skip to content

Remove -swift-version 3 from a handful of tests and update them appro… #17748

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,20 +1,10 @@
// RUN: %target-swift-frontend -typecheck %s -swift-version 3
// RUN: %target-swift-frontend -typecheck -update-code -primary-file %s -emit-migrated-file-path %t.result -disable-migrator-fixits -swift-version 3
// RUN: diff -u %s.expected %t.result
// RUN: %target-swift-frontend -typecheck %s.expected -swift-version 4
// RUN: %target-typecheck-verify-swift

func test1(_: ()) {}
test1(())
test1()
func test2() {}
test2()

enum Result<T> {
case success(T)
}
func test3(_: Result<()>) {}
test3(.success())

func test4(_: (Int, Int) -> ()) {}
test4({ (x,y) in })
func test5(_: (Int, Int, Int) -> ()) {}
Expand Down Expand Up @@ -44,10 +34,7 @@ func toString(indexes: Int?...) -> String {
if index != nil {}
return ""
})
let _ = indexes.reduce(0) { print($0); return $0.0 + ($0.1 ?? 0)}
let _ = indexes.reduce(0) { (true ? $0 : (1, 2)).0 + ($0.1 ?? 0) }
let _ = [(1, 2)].contains { $0 != $1 }
_ = ["Hello", "Foo"].sorted { print($0); return $0.0.count > ($0).1.count }
_ = ["Hello" : 2].map { ($0, ($1)) }
}

Expand All @@ -59,7 +46,3 @@ extension Dictionary {

let dictionary: [String: String] = [:]
_ = dictionary.first { (column, value) in true }!.value

func doit(_ x: Int) -> Bool { return x > 0 }
let _: ((String, Int)) -> [String:Bool] = { [$0: doit($1)] }
func returnClosure() -> ((Int, Int)) -> Bool { return {$1 > $0} }
25 changes: 25 additions & 0 deletions test/Constraints/tuple-arguments-unsupported.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// RUN: %target-typecheck-verify-swift

func test1(_: ()) {} // expected-note {{'test1' declared here}}
test1() // expected-error {{missing argument for parameter #1 in call}}

enum Result<T> {
case success(T) // expected-note {{'success' declared here}}
}
func test3(_: Result<()>) {}
test3(.success()) // expected-error {{missing argument for parameter #1 in call}}

func toString(indexes: Int?...) -> String {
let _ = indexes.reduce(0) { print($0); return $0.0 + ($0.1 ?? 0)}
// expected-error@-1 {{contextual closure type '(_, Int?) throws -> _' expects 2 arguments, but 1 was used in closure body}}
let _ = indexes.reduce(0) { (true ? $0 : (1, 2)).0 + ($0.1 ?? 0) }
// expected-error@-1 {{contextual closure type '(_, Int?) throws -> _' expects 2 arguments, but 1 was used in closure body}}
_ = ["Hello", "Foo"].sorted { print($0); return $0.0.count > ($0).1.count }
// expected-error@-1 {{argument passed to call that takes no arguments}}
}

func doit(_ x: Int) -> Bool { return x > 0 }
let _: ((String, Int)) -> [String:Bool] = { [$0: doit($1)] }
// expected-error@-1 {{closure tuple parameter '(String, Int)' does not support destructuring with implicit parameters}}
func returnClosure() -> ((Int, Int)) -> Bool { return {$1 > $0} }
// expected-error@-1 {{closure tuple parameter '(Int, Int)' does not support destructuring with implicit parameters}}
62 changes: 31 additions & 31 deletions test/IDE/complete_func_reference.swift
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
// 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
// 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
// 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
// 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
// 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
// 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
// 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
// RUN: %target-swift-ide-test -swift-version 3 -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=VOID_VOID_0 | %FileCheck %s -check-prefix=VOID_VOID
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=VOID_VOID_1 | %FileCheck %s -check-prefix=VOID_VOID
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=VOID_VOID_2 | %FileCheck %s -check-prefix=VOID_VOID
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=VOID_VOID_3 | %FileCheck %s -check-prefix=VOID_VOID
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=VOID_VOID_4 | %FileCheck %s -check-prefix=VOID_VOID
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=ANY_INT_0 | %FileCheck %s -check-prefix=ANY_INT
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=ANY_INT_1 | %FileCheck %s -check-prefix=ANY_INT
// 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_STATIC_CURRY < %t.results
// 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
// 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
// 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
// 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
// RUN: %target-swift-ide-test -swift-version 3 -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=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_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: %FileCheck %s -check-prefix=INT_ANY < %t.results
// RUN: %FileCheck %s -check-prefix=INT_ANY_STATIC_CURRY < %t.results
// RUN: %target-swift-ide-test -swift-version 3 -code-completion -source-filename %s -code-completion-token=INT_ANY_3 > %t.results
// 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
// 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
// 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
// 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_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

func voidToVoid() {}
func voidToInt() -> Int {}
Expand Down Expand Up @@ -122,7 +122,7 @@ do {
}

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

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

// INT_ANY: Begin completions
// INT_ANY-DAG: Decl{{.*}}/TypeRelation[Convertible]: intToAny(a:);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did these completions go away? Is it a bug?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I asked that same question of @benlangmuir on the other PR. I haven't had a chance to look into it at all, but if it's unexpected we can open a JIRA and look into it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I filed a radar about it already but I thought you determined the change was correct. Until we find out can you leave this test as is for now?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@slavapestov I'm not planning on merging anything until @benlangmuir has a chance to reply to my question below.

// INT_ANY-DAG: Decl{{.*}}/TypeRelation[Convertible]: intToInt(a:);
// INT_ANY-DAG: Decl{{.*}}/TypeRelation[Convertible]: intToVoid(a:);
// INT_ANY-DAG: Decl{{.*}}/TypeRelation[Convertible]: anyToAny(a:);
// INT_ANY-DAG: Decl{{.*}}/TypeRelation[Convertible]: anyToInt(a:);
// INT_ANY-DAG: Decl{{.*}}/TypeRelation[Convertible]: anyToVoid(a:);
// INT_ANY-DAG: Decl{{.*}}: intToAny({#a: Int#})[#Any#]; name=intToAny(a: Int)
// INT_ANY-DAG: Decl{{.*}}: intToInt({#a: Int#})[#Int#]; name=intToInt(a: Int)
// INT_ANY-DAG: Decl{{.*}}: intToVoid({#a: Int#})[#Void#]; name=intToVoid(a: Int)
// INT_ANY-DAG: Decl{{.*}}: anyToAny({#a: Any#})[#Any#]; name=anyToAny(a: Any)
// INT_ANY-DAG: Decl{{.*}}: anyToInt({#a: Any#})[#Int#]; name=anyToInt(a: Any)
// INT_ANY-DAG: Decl{{.*}}: anyToVoid({#a: Any#})[#Void#]; name=anyToVoid(a: Any)
// INT_ANY-DAG: Decl{{.*}}/TypeRelation[Convertible]: returnsIntToInt()[#(Int) -> Int#];
// INT_ANY-DAG: Decl{{.*}}/NotRecommended/TypeRelation[Invalid]: voidToVoid()[#Void#];
// INT_ANY-DAG: Decl{{.*}}: voidToInt()[#Int#];
// INT_ANY-DAG: Decl{{.*}}: voidToAny()[#Any#];
// INT_ANY: End completions

// INT_ANY_STATIC_CURRY: Begin completions
// INT_ANY_STATIC_CURRY-DAG: Decl[InstanceMethod]/CurrNominal/TypeRelation[Convertible]: intToInt({#self: S0#})[#(a: Int) -> Int#];
// INT_ANY_STATIC_CURRY-DAG: Decl[InstanceMethod]/CurrNominal/TypeRelation[Convertible]: intToVoid({#self: S0#})[#(a: Int) -> Void#];
// INT_ANY_STATIC_CURRY-DAG: Decl[InstanceMethod]/CurrNominal/TypeRelation[Convertible]: anyToAny({#self: S0#})[#(a: Any) -> Any#];
// INT_ANY_STATIC_CURRY-DAG: Decl[InstanceMethod]/CurrNominal/TypeRelation[Convertible]: anyToVoid({#self: S0#})[#(a: Any) -> Void#];
// INT_ANY_STATIC_CURRY-DAG: Decl[InstanceMethod]/CurrNominal/TypeRelation[Convertible]: intToAny({#self: S0#})[#(a: Int) -> Any#];
// INT_ANY_STATIC_CURRY-DAG: Decl[InstanceMethod]/CurrNominal/TypeRelation[Convertible]: anyToInt({#self: S0#})[#(a: Any) -> Int#];
// INT_ANY_STATIC_CURRY-DAG: Decl[InstanceMethod]/CurrNominal: intToInt({#self: S0#})[#(a: Int) -> Int#]; name=intToInt(S0)
// INT_ANY_STATIC_CURRY-DAG: Decl[InstanceMethod]/CurrNominal/NotRecommended/TypeRelation[Invalid]: intToVoid({#self: S0#})[#(a: Int) -> Void#]; name=intToVoid(S0)
// INT_ANY_STATIC_CURRY-DAG: Decl[InstanceMethod]/CurrNominal: anyToAny({#self: S0#})[#(a: Any) -> Any#]; name=anyToAny(S0)
// INT_ANY_STATIC_CURRY-DAG: Decl[InstanceMethod]/CurrNominal/NotRecommended/TypeRelation[Invalid]: anyToVoid({#self: S0#})[#(a: Any) -> Void#]; name=anyToVoid(S0)
// INT_ANY_STATIC_CURRY-DAG: Decl[InstanceMethod]/CurrNominal: intToAny({#self: S0#})[#(a: Int) -> Any#]; name=intToAny(S0)
// INT_ANY_STATIC_CURRY-DAG: Decl[InstanceMethod]/CurrNominal: anyToInt({#self: S0#})[#(a: Any) -> Int#]; name=anyToInt(S0)
// INT_ANY_STATIC_CURRY-DAG: Decl[InstanceMethod]/CurrNominal/TypeRelation[Convertible]: returnsIntToInt({#self: S0#})[#() -> (Int) -> Int#];
// INT_ANY_STATIC_CURRY-DAG: Decl[InstanceMethod]/CurrNominal: voidToAny({#self: S0#})[#() -> Any#];
// INT_ANY_STATIC_CURRY-DAG: Decl[InstanceMethod]/CurrNominal: voidToInt({#self: S0#})[#() -> Int#];
Expand Down
16 changes: 8 additions & 8 deletions test/Interpreter/currying_generics.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %target-run-simple-swift-swift3 | %FileCheck %s
// RUN: %target-run-simple-swift | %FileCheck %s
// REQUIRES: executable_test

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

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

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

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

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


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

3 changes: 0 additions & 3 deletions test/Migrator/Inputs/ignore_type_placeholder.swift

This file was deleted.

17 changes: 0 additions & 17 deletions test/Migrator/fixit_void.swift

This file was deleted.

17 changes: 0 additions & 17 deletions test/Migrator/fixit_void.swift.expected

This file was deleted.

3 changes: 0 additions & 3 deletions test/Migrator/ignore_type_placeholder.swift

This file was deleted.

65 changes: 0 additions & 65 deletions test/Migrator/tuple-arguments.swift.expected

This file was deleted.

6 changes: 3 additions & 3 deletions test/Prototypes/Result.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
// RUN: %target-run-stdlib-swift-swift3
// RUN: %target-run-stdlib-swift
// REQUIRES: executable_test

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

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

let results = [three, nasty, four]
print(results.flatMap { $0.success })
Expand Down
3 changes: 2 additions & 1 deletion test/stdlib/Inputs/DictionaryKeyValueTypesObjC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -874,7 +874,8 @@ typealias AnyObjectTuple2 = (AnyObject, AnyObject)
for i in 0..<3 {
var actualContents = [ExpectedDictionaryElement]()
let sink: (AnyObjectTuple2) -> Void = {
(key, value) in
pair in
let (key, value) = pair
actualContents.append(ExpectedDictionaryElement(
key: convertKey(key),
value: convertValue(value),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
// Copyright (c) 2014 - 2018 Apple Inc. and the Swift project authors
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this really necessary?

Copy link
Contributor Author

@rudkx rudkx Jul 4, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Copyright dates should be updated when files are updated. I had the same updates you had plus this, so I kept this as part of the rebase.

// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
Expand Down
Loading