File tree Expand file tree Collapse file tree 3 files changed +36
-2
lines changed Expand file tree Collapse file tree 3 files changed +36
-2
lines changed Original file line number Diff line number Diff line change @@ -856,7 +856,17 @@ SerializedKind_t SILDeclRef::getSerializedKind() const {
856
856
// marked as @frozen.
857
857
if (isStoredPropertyInitializer () || (isPropertyWrapperBackingInitializer () &&
858
858
d->getDeclContext ()->isTypeContext ())) {
859
- auto *nominal = cast<NominalTypeDecl>(d->getDeclContext ()->getImplementedObjCContext ());
859
+ auto *nominal = dyn_cast<NominalTypeDecl>(d->getDeclContext ());
860
+
861
+ // If this isn't in a nominal, it must be in an @objc @implementation
862
+ // extension. We don't serialize those since clients outside the module
863
+ // don't think of these as Swift classes.
864
+ if (!nominal) {
865
+ ASSERT (isa<ExtensionDecl>(d->getDeclContext ()) &&
866
+ cast<ExtensionDecl>(d->getDeclContext ())->isObjCImplementation ());
867
+ return IsNotSerialized;
868
+ }
869
+
860
870
auto scope =
861
871
nominal->getFormalAccessScope (/* useDC=*/ nullptr ,
862
872
/* treatUsableFromInlineAsPublic=*/ true );
Original file line number Diff line number Diff line change @@ -9,4 +9,12 @@ NS_ASSUME_NONNULL_BEGIN
9
9
10
10
@end
11
11
12
+ @interface Rdar114874429 : NSObject
13
+
14
+ - (instancetype )init ;
15
+
16
+ @property (readonly ) NSInteger prop;
17
+
18
+ @end
19
+
12
20
NS_ASSUME_NONNULL_END
Original file line number Diff line number Diff line change 1
- // RUN: %target-swift-frontend -emit-silgen -import-objc-header %S/Inputs/objc_implementation.h -swift-version 5 %s -target %target-stable-abi-triple | %FileCheck %s
1
+ // RUN: %target-swift-frontend -emit-silgen -import-objc-header %S/Inputs/objc_implementation.h -swift-version 5 %s -target %target-stable-abi-triple > %t
2
+ // RUN: %FileCheck --input-file %t %s
3
+ // RUN: %FileCheck --input-file %t --check-prefix NEGATIVE %s
2
4
3
5
// REQUIRES: objc_interop
4
6
11
13
// CHECK: function_ref @$ss25_unimplementedInitializer9className04initD04file4line6columns5NeverOs12StaticStringV_A2JS2utF
12
14
// CHECK: } // end sil function '$sSo9ImplClassC19objc_implementationEABycfc'
13
15
}
16
+
17
+ //
18
+ // objcImpl class with an initial value expression referencing a nonpublic
19
+ // function (rdar://114874429)
20
+ //
21
+
22
+ internal func internalFunc( ) -> Int { 42 }
23
+
24
+ @objc @implementation extension Rdar114874429 {
25
+ let prop : Int = internalFunc ( )
26
+
27
+ // CHECK-LABEL : sil{{.*}}@$sSo13Rdar114874429C19objc_implementationE4propSivpfi :
28
+ // NEGATIVE-NOT: sil{{.*}} [serialized] {{.*}}@$sSo13Rdar114874429C19objc_implementationE4propSivpfi :
29
+ }
You can’t perform that action at this time.
0 commit comments