Skip to content

Commit aa5f56d

Browse files
committed
Merge remote-tracking branch 'origin/main' into rebranch
2 parents b6378a9 + 087eba8 commit aa5f56d

File tree

8 files changed

+118
-13
lines changed

8 files changed

+118
-13
lines changed

test/Interpreter/SDK/CoreFoundation_casting.swift

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,38 @@ func testCFStringAnyObjectType() {
8585
print("done")
8686
}
8787
testCFStringAnyObjectType()
88+
89+
// https://github.com/apple/swift/issues/43022
90+
func testOptionalCFStringToStringAndNSString() {
91+
let optCFStr: CFString? = "Swift" as CFString
92+
93+
// CHECK: {{^}}Optional(Swift){{$}}
94+
print(optCFStr)
95+
96+
let swiftStr1 = optCFStr as? String
97+
let swiftStr2 = optCFStr as String?
98+
99+
let nsStr1 = optCFStr as? NSString
100+
let nsStr2 = optCFStr as NSString?
101+
102+
if let unwrapped = swiftStr1 {
103+
// CHECK-NEXT: {{^}}Swift{{$}}
104+
print(unwrapped)
105+
}
106+
if let unwrapped = swiftStr2 {
107+
// CHECK-NEXT: {{^}}Swift{{$}}
108+
print(unwrapped)
109+
}
110+
if let unwrapped = nsStr1 {
111+
// CHECK-NEXT: {{^}}Swift{{$}}
112+
print(unwrapped)
113+
}
114+
if let unwrapped = nsStr2 {
115+
// CHECK-NEXT: {{^}}Swift{{$}}
116+
print(unwrapped)
117+
}
118+
119+
// CHECK-NEXT: {{^}}done{{$}}
120+
print("done")
121+
}
122+
testOptionalCFStringToStringAndNSString()

test/Parse/switch.swift

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ func enumElementSyntaxOnTuple() {
314314
}
315315
}
316316

317-
// sr-176
317+
// https://github.com/apple/swift/issues/42798
318318
enum Whatever { case Thing }
319319
func f0(values: [Whatever]) { // expected-note {{'values' declared here}}
320320
switch value { // expected-error {{cannot find 'value' in scope; did you mean 'values'?}}
@@ -323,7 +323,8 @@ func f0(values: [Whatever]) { // expected-note {{'values' declared here}}
323323
}
324324
}
325325

326-
// sr-720
326+
// https://github.com/apple/swift/issues/43334
327+
// https://github.com/apple/swift/issues/43335
327328
enum Whichever {
328329
case Thing
329330
static let title = "title"
@@ -348,6 +349,12 @@ func f1(x: String, y: Whichever) {
348349
case Whichever.title: // expected-error {{expression pattern of type 'String' cannot match values of type 'Whichever'}}
349350
break
350351
}
352+
switch y {
353+
case .alias:
354+
break
355+
default:
356+
break
357+
}
351358
}
352359

353360

test/stdlib/Inputs/Mirror/Mirror.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,7 @@
2727
@interface FooMoreDerivedObjCClass : FooDerivedObjCClass
2828
@end
2929

30+
@interface StringConvertibleInDebugAndOtherwise_ObjC : NSObject
31+
@end
32+
3033
#endif

test/stdlib/Inputs/Mirror/Mirror.mm

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,14 @@ @implementation FooDerivedObjCClass : FooObjCClass
3131
@implementation FooMoreDerivedObjCClass : FooDerivedObjCClass
3232
@end
3333

34+
@implementation StringConvertibleInDebugAndOtherwise_ObjC : NSObject
35+
36+
-(NSString *) description {
37+
return @"description";
38+
}
39+
40+
-(NSString *) debugDescription {
41+
return @"debugDescription";
42+
}
43+
44+
@end

test/stdlib/Mirror.swift

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -558,14 +558,12 @@ func verifyWeakUnownedReflection
558558
expectEqual(child.label, name)
559559
expectNotNil(child.value)
560560

561-
// FIXME: These casts are currently broken (Dec 2019)
562-
// Once they are fixed, enable additional checks:
563-
//let vp1 = child.value as? WeakUnownedTestsP1
564-
//expectNotNil(vp1)
565-
//expectEqual(vp1!.f1(), 2)
566-
//let vp2 = child.value as? WeakUnownedTestsP2
567-
//expectNotNil(vp2)
568-
//expectEqual(vp2!.f2(), "b")
561+
let vp1 = child.value as? WeakUnownedTestsP1
562+
expectNotNil(vp1)
563+
expectEqual(vp1!.f1(), 2)
564+
let vp2 = child.value as? WeakUnownedTestsP2
565+
expectNotNil(vp2)
566+
expectEqual(vp2!.f2(), "b")
569567

570568
let v = child.value as? ExpectedClass
571569
expectNotNil(v)
@@ -1554,6 +1552,7 @@ mirrors.test("CustomMirrorIsInherited") {
15541552
//===----------------------------------------------------------------------===//
15551553

15561554
protocol SomeNativeProto {}
1555+
protocol SomeOtherNativeProto {}
15571556
extension Int: SomeNativeProto {}
15581557

15591558
class SomeClass {}
@@ -1588,6 +1587,14 @@ mirrors.test("MetatypeMirror") {
15881587
output = ""
15891588
dump(nativeProtocolConcreteMetatype, to: &output)
15901589
expectEqual(expectedNativeProtocolConcrete, output)
1590+
1591+
let nativeProtocolCompositionMetatype =
1592+
(SomeNativeProto & SomeOtherNativeProto).self
1593+
output = ""
1594+
dump(nativeProtocolCompositionMetatype, to: &output)
1595+
expectEqual(
1596+
"- Mirror.SomeNativeProto & Mirror.SomeOtherNativeProto #0\n",
1597+
output)
15911598
}
15921599
}
15931600

test/stdlib/Reflection.swift

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,5 +194,40 @@ sanePointerString.deallocate()
194194
var rawPointer = unsafeBitCast(0 as Int, to: Builtin.RawPointer.self)
195195
dump(rawPointer)
196196

197+
// https://github.com/apple/swift/issues/43211
198+
// CHECK-LABEL: {{^}}weak with dynamic value{{$}}
199+
print("weak with dynamic value")
200+
do {
201+
class Child {}
202+
class Example {
203+
weak var value: Child?
204+
}
205+
206+
var c: Child? = Child()
207+
let e = Example()
208+
e.value = c
209+
210+
// CHECK-NEXT: c1: Optional(Reflection.{{.*}}.Child)
211+
// CHECK-NEXT: some: Reflection.{{.*}}.Child #0
212+
dump(c, name: "c1")
213+
// CHECK-NEXT: e1: Reflection.{{.*}}.Example #0
214+
// CHECK-NEXT: value: Optional(Reflection.{{.*}}.Child)
215+
// CHECK-NEXT: some: Reflection.{{.*}}.Child #1
216+
dump(e, name: "e1")
217+
// CHECK-NEXT: value1: Optional(Reflection.{{.*}}.Child)
218+
// CHECK-NEXT: some: Reflection.{{.*}}.Child #0
219+
dump(e.value, name: "value1")
220+
221+
c = nil
222+
223+
// CHECK-NEXT: c2: nil
224+
dump(c, name: "c2")
225+
// CHECK-NEXT: e2: Reflection.{{.*}}.Example #0
226+
// CHECK-NEXT: value: nil
227+
dump(e, name: "e2")
228+
// CHECK-NEXT: value2: nil
229+
dump(e.value, name: "value2")
230+
}
231+
197232
// CHECK-LABEL: and now our song is done
198233
print("and now our song is done")

test/stdlib/RuntimeObjC.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -740,14 +740,17 @@ Reflection.test("Name of metatype of artificial subclass") {
740740
expectEqual(String(reflecting: type(of: obj)), "a.TestArtificialSubclass")
741741
}
742742

743-
@objc class StringConvertibleInDebugAndOtherwise : NSObject {
743+
@objc class StringConvertibleInDebugAndOtherwise_Native : NSObject {
744744
override var description: String { return "description" }
745745
override var debugDescription: String { return "debugDescription" }
746746
}
747747

748748
Reflection.test("NSObject is properly CustomDebugStringConvertible") {
749-
let object = StringConvertibleInDebugAndOtherwise()
750-
expectEqual(String(reflecting: object), object.debugDescription)
749+
let objectNative = StringConvertibleInDebugAndOtherwise_Native()
750+
let objectObjC = StringConvertibleInDebugAndOtherwise_ObjC()
751+
752+
expectEqual(String(reflecting: objectNative), objectNative.debugDescription)
753+
expectEqual(String(reflecting: objectObjC), objectObjC.debugDescription)
751754
}
752755

753756
Reflection.test("NSRange QuickLook") {

validation-test/compiler_crashers_fixed/26018-swift-parser-skipsingle.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
77

88
// RUN: not %target-swift-frontend %s -typecheck
9+
10+
// https://github.com/apple/swift/issues/43187
11+
// RUN: %target-swift-ide-test -structure -source-filename=%s
12+
913
for
1014
{({{{class
1115
case,

0 commit comments

Comments
 (0)