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 @@ -855,7 +855,17 @@ SerializedKind_t SILDeclRef::getSerializedKind() const {
855855 // marked as @frozen.
856856 if (isStoredPropertyInitializer () || (isPropertyWrapperBackingInitializer () &&
857857 d->getDeclContext ()->isTypeContext ())) {
858- auto *nominal = cast<NominalTypeDecl>(d->getDeclContext ()->getImplementedObjCContext ());
858+ auto *nominal = dyn_cast<NominalTypeDecl>(d->getDeclContext ());
859+
860+ // If this isn't in a nominal, it must be in an @objc @implementation
861+ // extension. We don't serialize those since clients outside the module
862+ // don't think of these as Swift classes.
863+ if (!nominal) {
864+ assert (isa<ExtensionDecl>(d->getDeclContext ()) &&
865+ cast<ExtensionDecl>(d->getDeclContext ())->isObjCImplementation ());
866+ return IsNotSerialized;
867+ }
868+
859869 auto scope =
860870 nominal->getFormalAccessScope (/* useDC=*/ nullptr ,
861871 /* treatUsableFromInlineAsPublic=*/ true );
Original file line number Diff line number Diff line change @@ -9,4 +9,12 @@ NS_ASSUME_NONNULL_BEGIN
99
1010@end
1111
12+ @interface Rdar114874429 : NSObject
13+
14+ - (instancetype )init ;
15+
16+ @property (readonly ) NSInteger prop;
17+
18+ @end
19+
1220NS_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 | %FileCheck %s
1+ // RUN: %target-swift-frontend -emit-silgen -import-objc-header %S/Inputs/objc_implementation.h -swift-version 5 %s > %t
2+ // RUN: %FileCheck --input-file %t %s
3+ // RUN: %FileCheck --input-file %t --check-prefix NEGATIVE %s
24
35// REQUIRES: objc_interop
46
1113 // CHECK: function_ref @$ss25_unimplementedInitializer9className04initD04file4line6columns5NeverOs12StaticStringV_A2JS2utF
1214 // CHECK: } // end sil function '$sSo9ImplClassC19objc_implementationEABycfc'
1315}
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+ @_objcImplementation 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