From f316c5fcfe278efc23fbd556f7ab9afd2bdd7d26 Mon Sep 17 00:00:00 2001 From: Doug Gregor Date: Mon, 13 Nov 2023 14:08:44 -0800 Subject: [PATCH] Update tests for map switching to typed throws --- test/Constraints/closures.swift | 7 ++++--- test/Constraints/enum_cases.swift | 8 ++++---- test/Constraints/tuple_arguments.swift | 2 +- test/IDE/complete_from_stdlib.swift | 10 +++++----- test/SILGen/function_conversion.swift | 4 ++-- test/SILGen/partial_apply_override.swift | 6 ++---- ...tability-stdlib-source-x86_64.swift.expected | 12 ++++++++++++ .../stability-stdlib-abi-without-asserts.test | 17 +++++++++++++++++ 8 files changed, 47 insertions(+), 19 deletions(-) diff --git a/test/Constraints/closures.swift b/test/Constraints/closures.swift index 95d9b182c72..3d8e56f73c1 100644 --- a/test/Constraints/closures.swift +++ b/test/Constraints/closures.swift @@ -1143,11 +1143,11 @@ struct R_76250381 { // https://github.com/apple/swift/issues/55926 (0..<10).map { x, y in } -// expected-error@-1 {{contextual closure type '(Range.Element) throws -> ()' (aka '(Int) throws -> ()') expects 1 argument, but 2 were used in closure body}} +// expected-error@-1 {{contextual closure type '(Range.Element) -> ()' (aka '(Int) -> ()') expects 1 argument, but 2 were used in closure body}} (0..<10).map { x, y, z in } -// expected-error@-1 {{contextual closure type '(Range.Element) throws -> ()' (aka '(Int) throws -> ()') expects 1 argument, but 3 were used in closure body}} +// expected-error@-1 {{contextual closure type '(Range.Element) -> ()' (aka '(Int) -> ()') expects 1 argument, but 3 were used in closure body}} (0..<10).map { x, y, z, w in } -// expected-error@-1 {{contextual closure type '(Range.Element) throws -> ()' (aka '(Int) throws -> ()') expects 1 argument, but 4 were used in closure body}} +// expected-error@-1 {{contextual closure type '(Range.Element) -> ()' (aka '(Int) -> ()') expects 1 argument, but 4 were used in closure body}} // rdar://77022842 - crash due to a missing argument to a ternary operator func rdar77022842(argA: Bool? = nil, argB: Bool? = nil) { @@ -1171,6 +1171,7 @@ func rdar76058892() { test { // expected-error {{contextual closure type '() -> String' expects 0 arguments, but 1 was used in closure body}} if let arr = arr { arr.map($0.test) // expected-note {{anonymous closure parameter '$0' is used here}} // expected-error {{generic parameter 'T' could not be inferred}} + // expected-error@-1 {{generic parameter 'E' could not be inferred}} } } } diff --git a/test/Constraints/enum_cases.swift b/test/Constraints/enum_cases.swift index 6d925378351..6408ed1b657 100644 --- a/test/Constraints/enum_cases.swift +++ b/test/Constraints/enum_cases.swift @@ -19,14 +19,14 @@ enum G_E { let arr: [String] = [] let _ = arr.map(E.foo) // Ok let _ = arr.map(E.bar) // Ok -let _ = arr.map(E.two) // expected-error {{cannot convert value of type '(Int, Int) -> E' to expected argument type '(String) throws -> E'}} +let _ = arr.map(E.two) // expected-error {{cannot convert value of type '(Int, Int) -> E' to expected argument type '(String) -> E'}} -let _ = arr.map(E.tuple) // expected-error {{cannot convert value of type '((x: Int, y: Int)) -> E' to expected argument type '(String) throws -> E'}} +let _ = arr.map(E.tuple) // expected-error {{cannot convert value of type '((x: Int, y: Int)) -> E' to expected argument type '(String) -> E'}} let _ = arr.map(G_E.foo) // Ok let _ = arr.map(G_E.bar) // Ok -let _ = arr.map(G_E.two) // expected-error {{cannot convert value of type '(String, String) -> G_E' to expected argument type '(String) throws -> G_E'}} -let _ = arr.map(G_E.tuple) // expected-error {{cannot convert value of type '((x: Int, y: Int)) -> G_E' to expected argument type '(String) throws -> G_E'}} +let _ = arr.map(G_E.two) // expected-error {{cannot convert value of type '(String, String) -> G_E' to expected argument type '(String) -> G_E'}} +let _ = arr.map(G_E.tuple) // expected-error {{cannot convert value of type '((x: Int, y: Int)) -> G_E' to expected argument type '(String) -> G_E'}} let _ = E.foo("hello") // expected-error {{missing argument label 'bar:' in call}} let _ = E.bar("hello") // Ok diff --git a/test/Constraints/tuple_arguments.swift b/test/Constraints/tuple_arguments.swift index ad0c6acdd71..0cb5250e6cd 100644 --- a/test/Constraints/tuple_arguments.swift +++ b/test/Constraints/tuple_arguments.swift @@ -1726,7 +1726,7 @@ do { do { func f(_: Int...) {} let _ = [(1, 2, 3)].map(f) // expected-error {{no exact matches in call to instance method 'map'}} - // expected-note@-1 {{found candidate with type '(((Int, Int, Int)) throws -> _) throws -> Array<_>'}} + // expected-note@-1 {{found candidate with type '(((Int, Int, Int)) -> _) -> Array<_>'}} } // rdar://problem/48443263 - cannot convert value of type '() -> Void' to expected argument type '(_) -> Void' diff --git a/test/IDE/complete_from_stdlib.swift b/test/IDE/complete_from_stdlib.swift index de35aa28046..bb7f11eea3b 100644 --- a/test/IDE/complete_from_stdlib.swift +++ b/test/IDE/complete_from_stdlib.swift @@ -20,7 +20,7 @@ func protocolExtCollection1a(_ a: C) { a.#^PRIVATE_NOMINAL_MEMBERS_2A?check=PRIVATE_NOMINAL_MEMBERS_2A;check=NEGATIVE_PRIVATE_NOMINAL_MEMBERS_2A;check=NO_STDLIB_PRIVATE^# } -// PRIVATE_NOMINAL_MEMBERS_2A-DAG: Decl[InstanceMethod]/CurrNominal/IsSystem: map({#(transform): (C.Element) throws -> T##(C.Element) throws -> T#})[' rethrows'][#[T]#]; +// PRIVATE_NOMINAL_MEMBERS_2A-DAG: Decl[InstanceMethod]/CurrNominal/IsSystem: map({#(transform): (C.Element) throws(Error) -> T##(C.Element) throws(Error) -> T#})[' throws'][#[T]#]; // NEGATIVE_PRIVATE_NOMINAL_MEMBERS_2A-NOT: Decl{{.*}}: index({#before: any Comparable#}) func protocolExtCollection1b(_ a: Collection) { @@ -28,14 +28,14 @@ func protocolExtCollection1b(_ a: Collection) { } // FIXME(https://github.com/apple/swift/issues/65696): We should not be showing this because (1) it cannot be accessed on the existential (2) we don't have the syntax and features to represent the projected type sig anyway. -// PRIVATE_NOMINAL_MEMBERS_2B-DAG: map({#(transform): (any Collection.Element) throws -> T##(any Collection.Element) throws -> T#})[' rethrows'][#[T]#]{{; name=.+}} +// PRIVATE_NOMINAL_MEMBERS_2B-DAG: map({#(transform): (any Collection.Element) throws(Error) -> T##(any Collection.Element) throws(Error) -> T#})[' throws'][#[T]#]{{; name=.+}} // NEGATIVE_PRIVATE_NOMINAL_MEMBERS_2B-NOT: Decl{{.*}}: index({#before: any Comparable#}) func protocolExtCollection2(_ a: C) { a.#^PRIVATE_NOMINAL_MEMBERS_3?check=PRIVATE_NOMINAL_MEMBERS_3;check=NEGATIVE_PRIVATE_NOMINAL_MEMBERS_3;check=NO_STDLIB_PRIVATE^# } -// PRIVATE_NOMINAL_MEMBERS_3-DAG: Decl[InstanceMethod]/Super/IsSystem: map({#(transform): (C.Element) throws -> T##(C.Element) throws -> T#})[' rethrows'][#[T]#]{{; name=.+}} +// PRIVATE_NOMINAL_MEMBERS_3-DAG: Decl[InstanceMethod]/Super/IsSystem: map({#(transform): (C.Element) throws(Error) -> T##(C.Element) throws(Error) -> T#})[' throws'][#[T]#]{{; name=.+}} // PRIVATE_NOMINAL_MEMBERS_3-DAG: Decl[InstanceVar]/Super/IsSystem: lazy[#LazySequence#]{{; name=.+}} // PRIVATE_NOMINAL_MEMBERS_3-DAG: firstIndex({#where: (C.Element) throws -> Bool##(C.Element) throws -> Bool#})[' rethrows'][#Comparable?#]{{; name=.+}} // NEGATIVE_PRIVATE_NOMINAL_MEMBERS_3-NOT: Decl{{.*}}: firstIndex({#({{.*}}): Self.Iterator.Element @@ -43,7 +43,7 @@ func protocolExtCollection2(_ func protocolExtArray(_ a: [T]) { a.#^PRIVATE_NOMINAL_MEMBERS_4?check=PRIVATE_NOMINAL_MEMBERS_4;check=NO_STDLIB_PRIVATE^# } -// PRIVATE_NOMINAL_MEMBERS_4-DAG: Decl[InstanceMethod]/Super/IsSystem: map({#(transform): (Equatable) throws -> T##(Equatable) throws -> T#})[' rethrows'][#[T]#]{{; name=.+}} +// PRIVATE_NOMINAL_MEMBERS_4-DAG: Decl[InstanceMethod]/Super/IsSystem: map({#(transform): (Equatable) throws(Error) -> T##(Equatable) throws(Error) -> T#})[' throws'][#[T]#]{{; name=.+}} // PRIVATE_NOMINAL_MEMBERS_4-DAG: Decl[InstanceVar]/Super/IsSystem: last[#Equatable?#]{{; name=.+}} // PRIVATE_NOMINAL_MEMBERS_4-DAG: Decl[InstanceMethod]/Super/IsSystem: firstIndex({#of: Equatable#})[#Int?#]{{; name=.+}} // PRIVATE_NOMINAL_MEMBERS_4-DAG: Decl[InstanceMethod]/Super/IsSystem: firstIndex({#where: (Equatable) throws -> Bool##(Equatable) throws -> Bool#})[' rethrows'][#Int?#]{{; name=.+}} @@ -85,7 +85,7 @@ func testArchetypeReplacement3 (_ a : [Int]) { // PRIVATE_NOMINAL_MEMBERS_7-DAG: Decl[InstanceMethod]/CurrNominal/IsSystem: append({#(newElement): Int#})[#Void#] // PRIVATE_NOMINAL_MEMBERS_7-DAG: Decl[InstanceMethod]/Super/IsSystem: removeLast()[#Int#] // PRIVATE_NOMINAL_MEMBERS_7-DAG: Decl[InstanceVar]/Super/IsSystem: first[#Int?#] -// PRIVATE_NOMINAL_MEMBERS_7-DAG: Decl[InstanceMethod]/Super/IsSystem: map({#(transform): (Int) throws -> T##(Int) throws -> T#})[' rethrows'][#[T]#] +// PRIVATE_NOMINAL_MEMBERS_7-DAG: Decl[InstanceMethod]/Super/IsSystem: map({#(transform): (Int) throws(Error) -> T##(Int) throws(Error) -> T#})[' throws'][#[T]#] // PRIVATE_NOMINAL_MEMBERS_7-DAG: Decl[InstanceMethod]/Super/IsSystem: dropLast({#(k): Int#})[#ArraySlice#] // PRIVATE_NOMINAL_MEMBERS_7-DAG: Decl[InstanceMethod]/Super/IsSystem: elementsEqual({#(other): Sequence#}, {#by: (Int, Sequence.Element) throws -> Bool##(Int, Sequence.Element) throws -> Bool#})[' rethrows'][#Bool#]; name=elementsEqual(:by:) // PRIVATE_NOMINAL_MEMBERS_7-DAG: Decl[InstanceMethod]/Super/IsSystem: elementsEqual({#(other): Sequence#})[#Bool#]; name=elementsEqual(:) diff --git a/test/SILGen/function_conversion.swift b/test/SILGen/function_conversion.swift index e2365c513e3..04383fa50e5 100644 --- a/test/SILGen/function_conversion.swift +++ b/test/SILGen/function_conversion.swift @@ -660,14 +660,14 @@ struct FunctionConversionParameterSubstToOrigReabstractionTest { } } -// CHECK: sil {{.*}} [ossa] @$sS4SIgggoo_S2Ss11AnyHashableVyps5Error_pIegggrrzo_TR +// CHECK: sil {{.*}} [ossa] @$sS4SIgggoo_S2Ss11AnyHashableVypIegggrr_TR // CHECK: [[TUPLE:%.*]] = apply %4(%2, %3) : $@noescape @callee_guaranteed (@guaranteed String, @guaranteed String) -> (@owned String, @owned String) // CHECK: ([[LHS:%.*]], [[RHS:%.*]]) = destructure_tuple [[TUPLE]] // CHECK: [[ADDR:%.*]] = alloc_stack $String // CHECK: store [[LHS]] to [init] [[ADDR]] : $*String // CHECK: [[CVT:%.*]] = function_ref @$ss21_convertToAnyHashableys0cD0VxSHRzlF : $@convention(thin) <τ_0_0 where τ_0_0 : Hashable> (@in_guaranteed τ_0_0) -> @out AnyHashable // CHECK: apply [[CVT]](%0, [[ADDR]]) -// CHECK: } // end sil function '$sS4SIgggoo_S2Ss11AnyHashableVyps5Error_pIegggrrzo_TR' +// CHECK: } // end sil function '$sS4SIgggoo_S2Ss11AnyHashableVypIegggrr_TR' func dontCrash() { let userInfo = ["hello": "world"] diff --git a/test/SILGen/partial_apply_override.swift b/test/SILGen/partial_apply_override.swift index c84540bb2bb..915c1b84ede 100644 --- a/test/SILGen/partial_apply_override.swift +++ b/test/SILGen/partial_apply_override.swift @@ -26,11 +26,9 @@ public func convert(strings: [String]) -> [Int] { // CHECK-NEXT: // function_ref // CHECK-NEXT: [[CURRY_THUNK:%.*]] = function_ref @$s22partial_apply_override7convert7stringsSaySiGSaySSG_tFSiSScAA18StringIntConverterCcfu_ : $@convention(thin) (@guaranteed StringIntConverter) -> @owned @callee_guaranteed (@guaranteed String) -> Int // CHECK-NEXT: [[CURRY_RESULT:%.*]] = apply [[CURRY_THUNK]]([[CONVERTER]]) -// CHECK: [[CONVERTED:%.*]] = convert_function [[CURRY_RESULT]] -// CHECK: [[NOESCAPE:%.*]] = convert_escape_to_noescape [not_guaranteed] [[CONVERTED]] +// CHECK: [[NOESCAPE:%.*]] = convert_escape_to_noescape [not_guaranteed] [[CURRY_RESULT]] // CHECK: // function_ref -// CHECK-NEXT: [[THUNK:%.*]] = function_ref @$sSSSis5Error_pIggdzo_SSSisAA_pIegnrzo_TR : $@convention(thin) (@in_guaranteed String, @guaranteed @noescape @callee_guaranteed (@guaranteed String) -> (Int, @error any Error)) -> (@out Int, @error any Error) -// CHECK-NEXT: [[REABSTRACTED:%.*]] = partial_apply [callee_guaranteed] [[THUNK]]([[NOESCAPE]]) +// CHECK-NEXT: [[THUNK:%.*]] = function_ref @$sSSSiIggd_SSSis5NeverOIegnrzr_TR : $@convention(thin) (@in_guaranteed String, @guaranteed @noescape @callee_guaranteed (@guaranteed String) -> Int) -> (@out Int, @error_indirect Never) // CHECK-LABEL: sil private [ossa] @$s22partial_apply_override7convert7stringsSaySiGSaySSG_tFSiSScAA18StringIntConverterCcfu_SiSScfu0_ : $@convention(thin) (@guaranteed String, @guaranteed StringIntConverter) -> Int // CHECK: [[METHOD:%.*]] = class_method %1 : $StringIntConverter, #StringIntConverter.convert : (StringIntConverter) -> (String) -> Int, $@convention(method) (@in_guaranteed String, @guaranteed StringIntConverter) -> @out Int diff --git a/test/api-digester/Outputs/stability-stdlib-source-x86_64.swift.expected b/test/api-digester/Outputs/stability-stdlib-source-x86_64.swift.expected index 3a939634857..6402a5ea5b7 100644 --- a/test/api-digester/Outputs/stability-stdlib-source-x86_64.swift.expected +++ b/test/api-digester/Outputs/stability-stdlib-source-x86_64.swift.expected @@ -26,5 +26,17 @@ Func Unicode.UTF32.Parser.parseScalar(from:) has generic signature change from < Func Unicode.UTF32.decode(_:) has generic signature change from to Func Unicode.UTF8.decode(_:) has generic signature change from to Constructor Mirror.init(_:children:displayStyle:ancestorRepresentation:) has generic signature change from to +Func AnyBidirectionalCollection.map(_:) has generic signature change from to +Func AnyBidirectionalCollection.map(_:) is now without @rethrows +Func AnyCollection.map(_:) has generic signature change from to +Func AnyCollection.map(_:) is now without @rethrows +Func AnyRandomAccessCollection.map(_:) has generic signature change from to +Func AnyRandomAccessCollection.map(_:) is now without @rethrows +Func AnySequence.map(_:) has generic signature change from to +Func AnySequence.map(_:) is now without @rethrows +Func Collection.map(_:) has generic signature change from to +Func Collection.map(_:) is now without @rethrows +Func Sequence.map(_:) has generic signature change from to +Func Sequence.map(_:) is now without @rethrows Protocol SIMDScalar has generic signature change from to diff --git a/test/api-digester/stability-stdlib-abi-without-asserts.test b/test/api-digester/stability-stdlib-abi-without-asserts.test index ff6819673bb..403c2158a12 100644 --- a/test/api-digester/stability-stdlib-abi-without-asserts.test +++ b/test/api-digester/stability-stdlib-abi-without-asserts.test @@ -75,6 +75,18 @@ Constructor _SmallString.init(taggedCocoa:) has return type change from Swift._S Enum Never has added a conformance to an existing protocol Decodable Enum Never has added a conformance to an existing protocol Encodable Enum Never has added a conformance to an existing protocol Identifiable +Func AnyBidirectionalCollection.map(_:) has been renamed to Func __rethrows_map(_:) +Func AnyBidirectionalCollection.map(_:) has mangled name changing from 'Swift.AnyBidirectionalCollection.map((A) throws -> A1) throws -> Swift.Array' to 'Swift.AnyBidirectionalCollection.__rethrows_map((A) throws -> A1) throws -> Swift.Array' +Func AnyBidirectionalCollection.map(_:) is now without @rethrows +Func AnyCollection.map(_:) has been renamed to Func __rethrows_map(_:) +Func AnyCollection.map(_:) has mangled name changing from 'Swift.AnyCollection.map((A) throws -> A1) throws -> Swift.Array' to 'Swift.AnyCollection.__rethrows_map((A) throws -> A1) throws -> Swift.Array' +Func AnyCollection.map(_:) is now without @rethrows +Func AnyRandomAccessCollection.map(_:) has been renamed to Func __rethrows_map(_:) +Func AnyRandomAccessCollection.map(_:) has mangled name changing from 'Swift.AnyRandomAccessCollection.map((A) throws -> A1) throws -> Swift.Array' to 'Swift.AnyRandomAccessCollection.__rethrows_map((A) throws -> A1) throws -> Swift.Array' +Func AnyRandomAccessCollection.map(_:) is now without @rethrows +Func AnySequence.map(_:) has been renamed to Func __rethrows_map(_:) +Func AnySequence.map(_:) has mangled name changing from 'Swift.AnySequence.map((A) throws -> A1) throws -> Swift.Array' to 'Swift.AnySequence.__rethrows_map((A) throws -> A1) throws -> Swift.Array' +Func AnySequence.map(_:) is now without @rethrows // These haven't actually been removed; they are simply marked unavailable. // This seems to be a false positive in the ABI checker. This is not an ABI @@ -100,6 +112,11 @@ Func UnsafeBufferPointer.withMemoryRebound(to:_:) has been removed Func UnsafeMutableBufferPointer.withMemoryRebound(to:_:) has been removed Func UnsafeMutablePointer.withMemoryRebound(to:capacity:_:) has been removed Func UnsafePointer.withMemoryRebound(to:capacity:_:) has been removed +Func _AnySequenceBox._map(_:) is now without @rethrows +Func _BidirectionalCollectionBox._map(_:) is now without @rethrows +Func _CollectionBox._map(_:) is now without @rethrows +Func _RandomAccessCollectionBox._map(_:) is now without @rethrows +Func _SequenceBox._map(_:) is now without @rethrows Func UnsafeMutableRawBufferPointer.storeBytes(of:toByteOffset:as:) has been removed Func UnsafeMutableRawPointer.storeBytes(of:toByteOffset:as:) has been removed Func UnsafeMutableBufferPointer.assign(repeating:) has been removed