Skip to content

Commit fae5f55

Browse files
Remove Swift 3-only Compatibility Shims (#21019) (#21101)
1 parent 56831e1 commit fae5f55

File tree

9 files changed

+74
-559
lines changed

9 files changed

+74
-559
lines changed

stdlib/public/core/MigrationSupport.swift

Lines changed: 2 additions & 519 deletions
Large diffs are not rendered by default.

test/Constraints/closures.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -747,7 +747,7 @@ takesTwoInOut { _ in } // expected-error {{contextual closure type '(Int, inout
747747
func f20371273() {
748748
let x: [Int] = [1, 2, 3, 4]
749749
let y: UInt = 4
750-
_ = x.filter { ($0 + y) > 42 } // expected-error {{'+' is unavailable}}
750+
_ = x.filter { ($0 + y) > 42 } // expected-error {{binary operator '+' cannot be applied to operands of type 'Int' and 'UInt'}} expected-note {{overloads for '+' exist with these partially matching parameter lists: (UInt, UInt), (Int, Int)}}
751751
}
752752

753753
// rdar://problem/42337247

test/Constraints/diagnostics.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -708,9 +708,10 @@ if AssocTest.one(1) == AssocTest.one(1) {} // expected-error{{binary operator '=
708708
func r24251022() {
709709
var a = 1
710710
var b: UInt32 = 2
711-
_ = a + b // expected-error {{unavailable}}
712-
a += a + // expected-error {{binary operator '+=' cannot be applied to operands of type 'Int' and 'UInt32'}} expected-note {{overloads for '+=' exist}}
711+
_ = a + b // expected-error {{binary operator '+' cannot be applied to operands of type 'Int' and 'UInt32'}} expected-note {{overloads for '+' exist with these partially matching parameter lists: (UInt32, UInt32), (Int, Int)}}
712+
a += a + // expected-error {{binary operator '+' cannot be applied to operands of type 'Int' and 'UInt32'}} expected-note {{overloads for '+' exist with these partially matching parameter lists:}}
713713
b
714+
a += b // expected-error {{binary operator '+=' cannot be applied to operands of type 'Int' and 'UInt32'}} expected-note {{overloads for '+=' exist with these partially matching parameter lists: (inout UInt32, UInt32), (inout Int, Int)}}
714715
}
715716

716717
func overloadSetResultType(_ a : Int, b : Int) -> Int {

test/Sema/substring_to_string_conversion_swift4.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,6 @@ do {
8181
// Substring-to-String via subscripting in a context expecting String
8282
func takesString(_ s: String) {}
8383

84-
func apply(_ fn: (String) -> (), _ s: String) {
85-
fn(s[s.startIndex..<s.endIndex]) // expected-error{{subscripts returning String were obsoleted in Swift 4; explicitly construct a String from subscripted result}} {{6-6=String(}} {{34-34=)}}
86-
let _: String = s[s.startIndex..<s.endIndex] // expected-error{{subscripts returning String were obsoleted in Swift 4; explicitly construct a String from subscripted result}} {{19-19=String(}} {{47-47=)}}
87-
_ = s[s.startIndex..<s.endIndex] as String // expected-error{{subscripts returning String were obsoleted in Swift 4; explicitly construct a String from subscripted result}} {{7-7=String(}} {{35-35=)}}
88-
}
89-
9084
// rdar://33474838
9185
protocol Derivable {
9286
func derive() -> Substring

test/api-digester/Outputs/stability-stdlib-abi.swift.expected

Lines changed: 60 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -357,8 +357,6 @@ Struct _DropWhileSequence has generic signature change from <τ_0_0 where τ_0_0
357357
Struct _DropWhileSequence has removed conformance to IteratorProtocol
358358
Struct _DropWhileSequence has type witness type for Sequence.Iterator changing from _DropWhileSequence<τ_0_0> to DropWhileSequence<τ_0_0>.Iterator
359359
Var Collection.lazy has been removed
360-
Var Dictionary.keys has declared type change from LazyMapCollection<Dictionary<τ_0_0, τ_0_1>, τ_0_0> to LazyMapSequence<Dictionary<τ_0_0, τ_0_1>, τ_0_0>
361-
Var Dictionary.values has declared type change from LazyMapCollection<Dictionary<τ_0_0, τ_0_1>, τ_0_1> to LazyMapSequence<Dictionary<τ_0_0, τ_0_1>, τ_0_1>
362360
Var LazySequence._base has removed its setter
363361
Var _DropWhileSequence._iterator has declared type change from τ_0_0 to τ_0_0.Iterator
364362
Func Collection._preprocessingPass(_:) has been removed
@@ -528,8 +526,6 @@ Func LazyCollectionProtocol.prefix(while:) has been removed
528526
Func LazyCollectionProtocol.reversed() has been removed
529527
Var LazyCollectionProtocol.lazy has declared type change from LazyCollection<τ_0_0.Elements> to LazySequence<τ_0_0.Elements>
530528

531-
Func Sequence.reduce(into:_:) has parameter 0 changing from Default to Owned
532-
533529
Class _AbstractStringStorage has been changed to a Protocol
534530
Class _AbstractStringStorage has generic signature change from to <τ_0_0 : _NSCopying>
535531
Class _AbstractStringStorage has removed conformance to _NSCopying
@@ -542,5 +538,65 @@ Constructor _AbstractStringStorage.init() has been removed
542538
Func _AbstractStringStorage.copy(with:) has been removed
543539
Func _AbstractStringStorage.getOrComputeBreadcrumbs() has been removed
544540

541+
Func Sequence.reduce(into:_:) has parameter 0 changing from Default to Owned
542+
543+
Constructor String.Index.init(_codeUnitOffset:) has been removed (deprecated)
544+
Constructor String.Index.init(_position:) has been removed (deprecated)
545+
Constructor String.init(_:) has been removed (deprecated)
546+
Constructor String.init(_:obsoletedInSwift4:) has been removed
547+
Constructor _ExpressibleByColorLiteral.init(colorLiteralRed:green:blue:alpha:) has been removed (deprecated)
548+
Func BinaryInteger.toIntMax() has been removed
549+
Func Dictionary.filter(_:obsoletedInSwift4:) has been removed
550+
Func FixedWidthInteger.unsafeAdding(_:) has been removed
551+
Func FixedWidthInteger.unsafeDivided(by:) has been removed
552+
Func FixedWidthInteger.unsafeMultiplied(by:) has been removed
553+
Func FixedWidthInteger.unsafeSubtracting(_:) has been removed
554+
Func FloatingPoint._fromBitPattern(_:) has been removed
555+
Func FloatingPoint._toBitPattern() has been removed
556+
Func FloatingPoint.abs(_:) has been removed (deprecated)
557+
Func FloatingPoint.add(_:) has been removed
558+
Func FloatingPoint.adding(_:) has been removed
559+
Func FloatingPoint.divide(by:) has been removed
560+
Func FloatingPoint.divided(by:) has been removed
561+
Func FloatingPoint.multiplied(by:) has been removed
562+
Func FloatingPoint.multiply(by:) has been removed
563+
Func FloatingPoint.negated() has been removed
564+
Func FloatingPoint.subtract(_:) has been removed
565+
Func FloatingPoint.subtracting(_:) has been removed
566+
Func Optional....(_:_:) has been removed
567+
Func Optional...<(_:_:) has been removed
568+
Func Set.filter(_:obsoletedInSwift4:) has been removed
569+
Func SignedNumeric.abs(_:) has been removed
570+
Func Strideable.+(_:_:) has been removed (deprecated)
571+
Func Strideable.+=(_:_:) has been removed (deprecated)
572+
Func Strideable.-(_:_:) has been removed (deprecated)
573+
Func Strideable.-=(_:_:) has been removed (deprecated)
574+
Func String.UTF16View.distance(from:to:) has been removed
575+
Func String.UTF16View.index(_:offsetBy:) has been removed
576+
Func String.UTF16View.index(after:) has been removed
577+
Func String.UTF8View.distance(from:to:) has been removed
578+
Func String.UTF8View.index(_:offsetBy:) has been removed
579+
Func String.UTF8View.index(after:) has been removed
580+
Func String.UnicodeScalarView.distance(from:to:) has been removed
581+
Func String.UnicodeScalarView.index(_:offsetBy:) has been removed
582+
Func String.UnicodeScalarView.index(after:) has been removed
583+
Func String.UnicodeScalarView.popFirst() has been removed (deprecated)
584+
Func String.popFirst() has been removed (deprecated)
585+
Func TextOutputStreamable.writeTo(_:) has been removed
586+
Func UnsignedInteger.toUIntMax() has been removed
587+
Protocol _BitwiseOperations has been removed
588+
Subscript String.UTF16View.subscript(_:) has been removed
589+
Subscript String.UTF8View.subscript(_:) has been removed
590+
Subscript String.UnicodeScalarView.subscript(_:) has been removed
591+
Subscript String.subscript(_:) has been removed
592+
Var BinaryFloatingPoint.NaN has been removed
593+
Var BinaryFloatingPoint.isSignaling has been removed
594+
Var BinaryFloatingPoint.quietNaN has been removed
595+
Var Dictionary.keys has been removed
596+
Var Dictionary.values has been removed
597+
Var FixedWidthInteger.allZeros has been removed (deprecated)
598+
Var String.Index._offset has been removed (deprecated)
599+
Var String.Index._utf16Index has been removed (deprecated)
600+
545601
Func MutableCollection.withContiguousMutableStorageIfAvailable(_:) has been added as a protocol requirement
546602
Func Sequence.withContiguousStorageIfAvailable(_:) has been added as a protocol requirement

test/stdlib/IntegerRenames4.swift

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,8 @@ do {
2121
let _: UIntMax = 0 // expected-error {{'UIntMax' has been renamed to 'UInt64'}}
2222
}
2323

24-
func integer<T : Integer>(x: T) {} // expected-error {{'Integer' has been renamed to 'BinaryInteger'}}
25-
func integerArithmetic<T : IntegerArithmetic>(x: T) {} // expected-error {{'IntegerArithmetic' has been renamed to 'BinaryInteger'}}
26-
func signedNumber<T : SignedNumber>(x: T) {} // expected-error {{Please use 'SignedNumeric & Comparable' instead.}}
27-
func absoluteValuable<T : AbsoluteValuable>(x: T) {} // expected-error {{Please use 'SignedNumeric & Comparable' instead.}}
28-
func _signedInteger<T : _SignedInteger>(x: T) {} // expected-error {{'_SignedInteger' has been renamed to 'SignedInteger'}}
29-
3024
func absolutaValuable<T : SignedNumeric & Comparable>(x: T) {
31-
_ = T.abs(x) // expected-error {{use the 'abs(_:)' free function}}
25+
_ = T.abs(x) // expected-error {{type 'T' has no member 'abs'}}
3226
}
3327

3428
func signedIntegerMaskingArithmetics<T : SignedInteger>(x: T) {

test/stdlib/StringCompatibilityDiagnostics.swift

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,6 @@
22

33
func testPopFirst() {
44
var str = "abc"
5-
_ = str.popFirst() // expected-error{{'popFirst()' is unavailable: Please use 'first', 'dropFirst()', or 'Substring.popFirst()'}}
6-
_ = str.characters.popFirst() // expected-error{{'characters' is unavailable: Please use String directly}}
7-
// expected-error@-1{{'popFirst()' is unavailable: Please use 'first', 'dropFirst()', or 'Substring.popFirst()'}}
8-
_ = str.unicodeScalars.popFirst() // expected-error{{'popFirst()' is unavailable: Please use 'first', 'dropFirst()', or 'Substring.UnicodeScalarView.popFirst()'}}
9-
105
var charView: String.CharacterView // expected-error{{'CharacterView' is unavailable: Please use String directly}}
116
_ = str.characters // expected-error{{'characters' is unavailable: Please use String directly}}
127
dump(charView)

test/stdlib/StringCompatibilityDiagnostics4.swift

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,6 @@
22

33
func testPopFirst() {
44
var str = "abc"
5-
_ = str.popFirst() // expected-error{{'popFirst()' is unavailable: Please use 'first', 'dropFirst()', or 'Substring.popFirst()'}}
6-
_ = str.characters.popFirst() // expected-warning{{'characters' is deprecated: Please use String directly}}
7-
// expected-error@-1{{'popFirst()' is unavailable: Please use 'first', 'dropFirst()', or 'Substring.popFirst()'}}
8-
_ = str.popFirst() // expected-error{{'popFirst()' is unavailable: Please use 'first', 'dropFirst()', or 'Substring.popFirst()'}}
9-
_ = str.unicodeScalars.popFirst() // expected-error{{'popFirst()' is unavailable: Please use 'first', 'dropFirst()', or 'Substring.UnicodeScalarView.popFirst()'}}
10-
115
var charView: String.CharacterView // expected-warning{{'CharacterView' is deprecated: Please use String directly}}
126
charView = str.characters // expected-warning{{'characters' is deprecated: Please use String directly}}
137
dump(charView)
@@ -22,7 +16,6 @@ func testPopFirst() {
2216
dump(charSubView)
2317

2418
var _ = String(str.utf8) ?? "" // expected-warning{{left side of nil coalescing operator '??' has non-optional type 'String', so the right side is never used}}
25-
var _: String = String(str.utf8)! // expected-error{{'init(_:)' is unavailable: Please use non-failable String.init(_:UTF8View) instead}}
2619
var _: String = String(str.utf8) // ok
2720
}
2821

validation-test/stdlib/FixedPointDiagnostics.swift.gyb

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,23 +87,22 @@ func testMixedSignArithmetic() {
8787
typealias Stride = ${T}.Stride
8888
_ = ${T}(1) + 0 // OK
8989
_ = 0 + ${T}(1) // OK
90-
_ = ${T}(1) + Stride(0) // expected-error {{'+' is unavailable: Please use explicit type conversions or Strideable methods for mixed-type arithmetics.}}
91-
_ = Stride(1) + ${T}(0) // expected-error {{'+' is unavailable: Please use explicit type conversions or Strideable methods for mixed-type arithmetics.}}
92-
_ = ${T}(1) - Stride(0) // expected-error {{'-' is unavailable: Please use explicit type conversions or Strideable methods for mixed-type arithmetics.}}
90+
_ = ${T}(1) + Stride(0) // expected-error {{}} expected-note {{}}
91+
_ = Stride(1) + ${T}(0) // expected-error {{}} expected-note {{}}
92+
_ = ${T}(1) - Stride(0) // expected-error {{}} expected-note {{}}
9393
var x: ${T} = 0
9494
x += 1 // OK
95-
x += Stride(1) // expected-error {{'+=' is unavailable: Please use explicit type conversions or Strideable methods for mixed-type arithmetics.}}
96-
x -= Stride(1) // expected-error {{'-=' is unavailable: Please use explicit type conversions or Strideable methods for mixed-type arithmetics.}}
95+
x += Stride(1) // expected-error {{}} expected-note {{}}
96+
x -= Stride(1) // expected-error {{}} expected-note {{}}
9797

98-
// Terrible over-specific error, but at least disabled
99-
_ = (x - x) as Stride // expected-error {{'(@lvalue ${T}, @lvalue ${T}) -> ${T}' is not convertible to '(${T}, ${T}) -> ${T}'}}
98+
_ = (x - x) as Stride // expected-error {{}}
10099

101100
//===------------------------------------------------------------------===//
102101
// The following errors are different because they're not being
103102
// disabled by the ambiguity trick.
104103
//===------------------------------------------------------------------===//
105104

106-
(x + x) as Stride // expected-error {{cannot convert value of type '${T}' to type 'Stride' (aka 'Int') in coercion}}
105+
(x + x) as Stride // expected-error {{}}
107106
Stride(1) - ${T}(0) // expected-error {{}} expected-note {{}}
108107

109108
// These tests are expected to start failing when we get improved diagnostics.

0 commit comments

Comments
 (0)