Skip to content

Commit 656fe89

Browse files
authored
Merge pull request swiftlang#26936 from mikeash/null-was-a-mistake
2 parents 5ad5305 + 5decec2 commit 656fe89

File tree

3 files changed

+48
-0
lines changed

3 files changed

+48
-0
lines changed

stdlib/public/runtime/MetadataLookup.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2011,6 +2011,8 @@ void swift::gatherWrittenGenericArgs(
20112011
const TypeContextDescriptor *description,
20122012
SmallVectorImpl<const Metadata *> &allGenericArgs,
20132013
Demangler &BorrowFrom) {
2014+
if (!description)
2015+
return;
20142016
auto generics = description->getGenericContext();
20152017
if (!generics)
20162018
return;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import Foundation
2+
3+
extension NSString {
4+
class _Inner1<T> where T: NSObject {}
5+
}
6+
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: cp %s %t/main.swift
3+
// RUN: %target-build-swift -module-name test %t/main.swift %S/inputs/generic-nested-in-extension-on-objc-class.swift -o %t/a.out
4+
// RUN: %target-codesign %t/a.out
5+
// RUN: %target-run %t/a.out | %FileCheck %s
6+
7+
// REQUIRES: objc_interop
8+
9+
import Foundation
10+
11+
// Test the fix for a crash when instantiating the metadata for a generic type
12+
// nested in an extension on an ObjC class in a different file.
13+
// https://bugs.swift.org/browse/SR-11374
14+
15+
extension NSString {
16+
class _Inner2<T> where T: NSObject {}
17+
}
18+
19+
extension NSArray {
20+
class Inner1: NSString._Inner1<NSArray> {
21+
override init() {
22+
super.init()
23+
print("Inner1")
24+
}
25+
}
26+
class Inner2: NSString._Inner2<NSArray> {
27+
override init() {
28+
super.init()
29+
print("Inner2")
30+
}
31+
}
32+
}
33+
34+
// CHECK: Inner1
35+
_ = NSArray.Inner1()
36+
37+
// CHECK: Inner2
38+
_ = NSArray.Inner2()
39+
40+

0 commit comments

Comments
 (0)