You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/CppInteroperability/CppInteroperabilityStatus.md
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -76,7 +76,7 @@ This status table describes which of the following C++ language features can be
76
76
| Typedefs / Type aliases | Yes |
77
77
| Global Variables | Yes |
78
78
| Namespaces | Yes |
79
-
| Inline Namespaces | Yes, with some known issues (https://bugs.swift.org/browse/SR-15956)|
79
+
| Inline Namespaces | Yes, with some known issues ([#58217](https://github.com/apple/swift/issues/58217)) |
80
80
| Exceptions | No |
81
81
| Fields | Yes |
82
82
| Member functions | Yes. Some value category overloads aren't imported |
@@ -120,7 +120,7 @@ This status table describes which of the following C++ standard library features
120
120
## Known Issues
121
121
122
122
### Inline Namespaces
123
-
-https://bugs.swift.org/browse/SR-15956: Swift's typechecker currently doesn't allow calling a function from an inline namespace when it's referenced through the parent namespace. Example of a test that fails: https://github.com/apple/swift/blob/main/test/Interop/Cxx/namespace/inline-namespace-function-call-broken.swift
123
+
-[#58217](https://github.com/apple/swift/issues/58217): Swift's typechecker currently doesn't allow calling a function from an inline namespace when it's referenced through the parent namespace. Example of a test that fails: https://github.com/apple/swift/blob/main/test/Interop/Cxx/namespace/inline-namespace-function-call-broken.swift
Copy file name to clipboardExpand all lines: docs/DynamicCasting.md
+33-33Lines changed: 33 additions & 33 deletions
Original file line number
Diff line number
Diff line change
@@ -36,7 +36,7 @@ Where possible, each section includes machine-verifiable _invariants_ that can b
36
36
37
37
Casting an instance of a type to its own type will always succeed and return the original value unchanged.
38
38
39
-
```
39
+
```swift
40
40
let a: Int=7
41
41
a isInt// true
42
42
a as?Int// Succeeds
@@ -109,13 +109,13 @@ Note: The associated `_ObjectiveCType` is constrained to be a subtype of `AnyObj
109
109
In particular, this mechanism is equally available to the Swift implementation of Foundation on non-Apple platforms and the Objective-C Foundation on Apple platforms.
110
110
111
111
Example #1: Foundation extends the `Array` type in the standard library with an `_ObjectiveCBridgeable` conformance to `NSArray`. This allows Swift arrays to be cast to and from Foundation `NSArray` instances.
112
-
```
112
+
```swift
113
113
let a = [1, 2, 3] // Array<Int>
114
114
let b = a as?AnyObject// casts to NSArray
115
115
```
116
116
117
117
Example #2: Foundation also extends each Swift numeric type with an `_ObjectiveCBridgeable` conformance to `NSNumber`.
118
-
```
118
+
```swift
119
119
let a =1// Int
120
120
// After the next line, b is an Optional<AnyObject>
121
121
// holding a reference to an NSNumber
@@ -151,7 +151,7 @@ Casting to and from optional types will transparently unwrap optionals as much a
151
151
Note: For "Optional Injection" above, the requirement that `t` is a non-nil instance of `T` implies that either `T` is not an `Optional` or that `T` is `Optional` and `t` has the form `.some(u)`
152
152
153
153
Examples
154
-
```
154
+
```swift
155
155
// T and U are any two distinct types (possibly optional)
156
156
// NO is any non-optional type
157
157
let t: T
@@ -187,7 +187,7 @@ Note that "optional depth" here refers to the number of optional wrappers needed
187
187
2. Otherwise, the value should inject with the greatest optional depth possible.
188
188
189
189
Examples
190
-
```
190
+
```swift
191
191
// Depth preservation
192
192
// The `.none` here has type `T?` with optional depth 1
193
193
let t1: T????= .some(.some(.some(.none)))
@@ -220,14 +220,14 @@ The result will be a new array where each `Int` in the original array has been i
220
220
221
221
However, if any component item cannot be cast, then the outer cast will also fail.
222
222
For example, consider the following:
223
-
```
223
+
```swift
224
224
let a: Array<Any> = [Int(7), "string"]
225
225
a as?Array<Int>// Fails because "string" cannot be cast to `Int`
226
226
```
227
227
228
228
Specifically, the casting operator acts for `Array` as if it were implemented as follows.
229
229
In particular, note that an empty array can be successfully cast to any destination array type.
@@ -249,7 +249,7 @@ Similar logic applies to `Set` and `Dictionary` casts.
249
249
Note that the resulting `Set` or `Dictionary` may have fewer items than the original if the component casting operation converts non-equal items in the source into equal items in the destination.
250
250
251
251
Specifically, the casting operator acts on `Set` and `Dictionary` as if by the following code:
@@ -382,7 +382,7 @@ For example, its metatype is named `AnyHashable.Type` and it does not have an ex
382
382
Any protocol definition (except those that include an `associatedtype` property or which makes use of the `Self` typealias) has an associated existential type named after the protocol.
383
383
384
384
Specifically, assume you have a protocol definition
385
-
```
385
+
```swift
386
386
protocolP {}
387
387
```
388
388
@@ -427,7 +427,7 @@ We call this type the "metatype of `T`".
427
427
Technically, static variables or methods of a type belong to the `T.self` instance and are defined by the metatype of `T`:
428
428
429
429
Example:
430
-
```
430
+
```swift
431
431
structS {
432
432
let ivar =2
433
433
staticlet svar =1
@@ -447,7 +447,7 @@ However, in the following cases the metatype has a different name:
447
447
* As explained above, although `AnyHashable` behaves like an existential type in some respects, its metatype is called `AnyHashable.Type`.
448
448
449
449
Example:
450
-
```
450
+
```swift
451
451
// Metatype of a struct type
452
452
structS: P {}
453
453
S.selfis S.Type// always true
@@ -501,7 +501,7 @@ As with other existentials, casting _from_ an existential metatype is equivalent
501
501
Casting _to_ an existential metatype succeeds whenever the source is a conforming metatype instance (or can be unwrapped to yield such a metatype instance).
502
502
503
503
Example
504
-
```
504
+
```swift
505
505
protocolP {
506
506
var ivar: Int { get }
507
507
static svar:Int { get }
@@ -532,15 +532,15 @@ This is equivalent to saying that `P.self` is an instance of `P.Type`.
532
532
(Remember that `P.self` is always an instance of `P.Protocol`.)
533
533
534
534
This is a concern for Swift because of the following construct, which attempts to invoke a generic `f` in a situation where the concrete instance clearly conforms to `P` but is represented as a `P` existential:
535
-
```
535
+
```swift
536
536
funcf<T:P>(t: T) { .. use t .. }
537
537
let a : P = something
538
538
f(a)
539
539
```
540
540
This construct is valid only if `T` conforms to `P` when `T = P`; that is, if `P` self-conforms.
541
541
542
542
A similar situation arises with generic types:
543
-
```
543
+
```swift
544
544
structMyGenericType<T: P> {
545
545
init(_value: T) { ... }
546
546
}
@@ -591,7 +591,7 @@ These are some of the ways in which Swift 5.3 differs from the behavior describe
591
591
592
592
* Casts for which the target type is "more Optional" than the static source type previously produced errors. This disallowed all of the following: injecting an `Int` into an `Int?`, extracting an `Int?` from an opaque `Any` container, and casting an `Array<Int>` to an `Array<Int?>`. This document allows all of these.
593
593
594
-
```
594
+
```swift
595
595
let a =7
596
596
// Swift 5.3: error: cannot downcast to a more optional type
597
597
// Specification: returns true
@@ -609,7 +609,7 @@ c is Int?
609
609
610
610
* An instance of a CoreFoundation type could sometimes be cast to a protocol defined on the companion Obj-C type and sometimes not. To make the behavior consistent, we had to choose one; having such casts always succeed seems more consistent with the general dual nature of Obj-C/CF types.
611
611
612
-
```
612
+
```swift
613
613
importFoundation
614
614
protocolP {}
615
615
extensionNSString: P {}
@@ -625,7 +625,7 @@ print(b is P)
625
625
626
626
* The Swift 5.3 compiler asserts attempting to cast a struct to AnyObject
627
627
628
-
```
628
+
```swift
629
629
structS {}
630
630
let s =S()
631
631
// Swift 5.3: Compiler crash (in asserts build)
@@ -635,7 +635,7 @@ s as? AnyObject
635
635
636
636
*`NSNumber()` does not cast to itself via `as?` in unoptimized builds
637
637
638
-
```
638
+
```swift
639
639
importFoundation
640
640
let a =NSNumber()
641
641
// true in 5.3 for optimized builds; false for unoptimized builds
* Casting `NSNumber()` to `Any` crashes at runtime
659
659
660
-
```
660
+
```swift
661
661
importFoundation
662
662
let a =NSNumber()
663
663
// Swift 5.3: Runtime crash (both optimized and unoptimized builds)
664
664
// Specification: Succeeds
665
665
print(a isAny)
666
666
```
667
667
668
-
*SR-2289: CF types cannot be cast to protocol existentials
668
+
*[#44896](https://github.com/apple/swift/issues/44896): CF types cannot be cast to protocol existentials
669
669
670
-
```
670
+
```swift
671
671
importFoundation
672
672
protocolP {}
673
673
extensionCFBitVector : P {
@@ -680,9 +680,9 @@ extension CFBitVector : P {
680
680
print(CFBitVector.makeImmutable(from: [10,20]) is P)
681
681
```
682
682
683
-
*SR-4552: Cannot cast `Optional<T> as Any` to protocol type. Note that this is a particular problem for reflection with weak fields, since `Mirror` reflects those as `Any` containing an `Optional` value.
683
+
*[#47129](https://github.com/apple/swift/issues/47129): Cannot cast `Optional<T> as Any` to protocol type. Note that this is a particular problem for reflection with weak fields, since `Mirror` reflects those as `Any` containing an `Optional` value.
684
684
685
-
```
685
+
```swift
686
686
protocolP {}
687
687
classC: P {}
688
688
let c: C?=C()
@@ -692,9 +692,9 @@ let a = c as? Any
692
692
print(a is P)
693
693
```
694
694
695
-
*SR-8964: `Any` containing `Optional<Any>` cannot cast to `Error`
695
+
*[#51469](https://github.com/apple/swift/issues/51469): `Any` containing `Optional<Any>` cannot cast to `Error`
696
696
697
-
```
697
+
```swift
698
698
structMyError: Error{ }
699
699
let a: Any?=MyError()
700
700
let b: Any= a
@@ -703,10 +703,10 @@ let b: Any = a
703
703
print(b isError)
704
704
```
705
705
706
-
*SR-6126: Inconsistent results for nested optionals
706
+
*[#48681](https://github.com/apple/swift/issues/48681): Inconsistent results for nested optionals
707
707
708
-
```
709
-
// Note: SR-6126 includes many cases similar to the following
708
+
```swift
709
+
// Note: This issue includes many cases similar to the following
710
710
let x: Int?=nil
711
711
print(x asInt??) // ==> "Optional(nil)"
712
712
// Swift 5.3: prints "nil"
@@ -716,23 +716,23 @@ print((x as? Int??)!)
716
716
717
717
*`Error.self` does not fully self-conform
718
718
719
-
```
719
+
```swift
720
720
// Swift 5.3: Prints "false"
721
721
// Specification: prints "true"
722
722
print(Error.selfisError.Type)
723
723
```
724
724
725
725
* Objective-C protocol metatypes do not fully self-conform
726
726
727
-
```
727
+
```swift
728
728
importFoundation
729
729
let a = NSObjectProtocol.self
730
730
print(a is NSObjectProtocol.Type)
731
731
```
732
732
733
-
*SR-1999: Cannot cast `Any` contents to a protocol type
733
+
*[#44608](https://github.com/apple/swift/issues/44608): Cannot cast `Any` contents to a protocol type
Copy file name to clipboardExpand all lines: docs/GenericsManifesto.md
+4-4Lines changed: 4 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -27,7 +27,7 @@ There are a number of restrictions to the use of generics that fall out of the i
27
27
28
28
### Recursive protocol constraints (*)
29
29
30
-
*This feature has been accepted in [SE-0157](https://github.com/apple/swift-evolution/blob/main/proposals/0157-recursive-protocol-constraints.md) and is tracked by [SR-1445](https://bugs.swift.org/browse/SR-1445).*
30
+
*This feature has been accepted in [SE-0157](https://github.com/apple/swift-evolution/blob/main/proposals/0157-recursive-protocol-constraints.md) and is tracked by [#44054](https://github.com/apple/swift/issues/44054).*
31
31
32
32
Currently, an associated type cannot be required to conform to its enclosing protocol (or any protocol that inherits that protocol). For example, in the standard library `SubSequence` type of a `Sequence` should itself be a `Sequence`:
33
33
@@ -43,7 +43,7 @@ The compiler currently rejects this protocol, which is unfortunate: it effective
43
43
44
44
### Nested generics
45
45
46
-
*This feature was tracked by [SR-1446](https://bugs.swift.org/browse/SR-1446) and was released with Swift 3.1.*
46
+
*This feature was tracked by [#44055](https://github.com/apple/swift/issues/44055) and was released with Swift 3.1.*
47
47
48
48
Currently, a generic type cannot be nested within another generic type, e.g.
49
49
@@ -57,7 +57,7 @@ There isn't much to say about this: the compiler simply needs to be improved to
57
57
58
58
### Concrete same-type requirements
59
59
60
-
*This feature was tracked by [SR-1009](https://bugs.swift.org/browse/SR-1009) and was released with Swift 3.1.*
60
+
*This feature was tracked by [#43621](https://github.com/apple/swift/issues/43621) and was released with Swift 3.1.*
61
61
62
62
Currently, a constrained extension cannot use a same-type constraint to make a type parameter equivalent to a concrete type. For example:
63
63
@@ -114,7 +114,7 @@ Note: generic associatedtypes address many use cases also addressed by higher-ki
114
114
115
115
### Generic subscripts
116
116
117
-
*This feature has been accepted in [SE-0148](https://github.com/apple/swift-evolution/blob/main/proposals/0148-generic-subscripts.md), was tracked by [SR-115](https://bugs.swift.org/browse/SR-115) and was released with Swift 4.*
117
+
*This feature has been accepted in [SE-0148](https://github.com/apple/swift-evolution/blob/main/proposals/0148-generic-subscripts.md), was tracked by [#42737](https://github.com/apple/swift/issues/42737) and was released with Swift 4.*
118
118
119
119
Subscripts could be allowed to have generic parameters. For example, we could introduce a generic subscript on a `Collection` that allows us to pull out the values at an arbitrary set of indices:
Copy file name to clipboardExpand all lines: docs/HowToGuides/GettingStarted.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -85,7 +85,7 @@ toolchain as a one-off, there are a couple of differences:
85
85
**Note:** If you've already forked the project on GitHub at this stage,
86
86
**do not clone your fork** to start off. We describe
87
87
[how to setup your fork](#setting-up-your-fork) in a subsection below.
88
-
<!-- Recommending against cloning the fork due to SR-13476 and SR-13505. -->
88
+
<!-- Recommending against cloning the fork due to https://github.com/apple/swift/issues/55918 and https://github.com/apple/swift/issues/55947. -->
89
89
3. Double-check that `swift`'s sibling directories are present.
0 commit comments