File tree Expand file tree Collapse file tree 3 files changed +65
-0
lines changed Expand file tree Collapse file tree 3 files changed +65
-0
lines changed Original file line number Diff line number Diff line change @@ -1757,5 +1757,12 @@ bool LinkEntity::hasNonUniqueDefinition() const {
17571757 return true ;
17581758 }
17591759
1760+ // Always treat witness tables as having non-unique definitions.
1761+ if (getKind () == Kind::ProtocolWitnessTable) {
1762+ if (auto context = getDeclContextForEmission ())
1763+ if (context->getParentModule ()->getASTContext ().LangOpts .hasFeature (Feature::Embedded))
1764+ return true ;
1765+ }
1766+
17601767 return false ;
17611768}
Original file line number Diff line number Diff line change @@ -86,6 +86,25 @@ public func getPointOffsets() -> [Int] {
8686 enumerateByteOffsets ( Point . self)
8787}
8888
89+ public class PointClass {
90+ public var x , y : Int
91+
92+ public init ( x: Int , y: Int ) {
93+ self . x = x
94+ self . y = y
95+ }
96+ }
97+
98+ public protocol Reflectable : AnyObject {
99+ func reflect( )
100+ }
101+
102+ extension PointClass : Reflectable {
103+ public func reflect( ) {
104+ swap ( & x, & y)
105+ }
106+ }
107+
89108//--- ClientA.swift
90109import Root
91110
@@ -99,6 +118,10 @@ public func getPointAndColorOffsets() -> [Int] {
99118 getPointOffsets ( ) + enumerateByteOffsets( Color . self)
100119}
101120
121+ public func getReflectableA( ) -> any AnyObject & Reflectable {
122+ return PointClass ( x: 5 , y: 5 )
123+ }
124+
102125//--- ClientB.swift
103126import Root
104127
@@ -112,6 +135,10 @@ public func getExtraPoint3DOffsets() -> [Int] {
112135 return Array ( point3DOffsets [ pointOffsets. count... ] )
113136}
114137
138+ public func getReflectableB( ) -> any AnyObject & Reflectable {
139+ return PointClass ( x: 5 , y: 5 )
140+ }
141+
115142//--- Application.swift
116143import ClientA
117144import ClientB
@@ -124,6 +151,7 @@ struct Main {
124151 print ( pointAndColorOffsets. count)
125152 print ( extraColor3DOffsets. count)
126153
154+ let reflected = [ getReflectableA ( ) , getReflectableB ( ) ]
127155 // CHECK: DONE
128156 print ( " DONE " )
129157 }
Original file line number Diff line number Diff line change 2121
2222//--- Library.swift
2323
24+ // LIBRARY-IR: @"$e7Library10PointClassCN" = weak_odr {{.*}}global
25+
2426// Never referenced.
2527// LIBRARY-IR-NOT: @"$es23_swiftEmptyArrayStorageSi_S3itvp" = weak_odr {{(protected |dllexport )?}}global
2628
@@ -54,6 +56,34 @@ public func unnecessary() -> Int64 { 5 }
5456@_neverEmitIntoClient
5557public func unusedYetThere( ) -> Int64 { 5 }
5658
59+ public class PointClass {
60+ public var x , y : Int
61+
62+ public init ( x: Int , y: Int ) {
63+ self . x = x
64+ self . y = y
65+ }
66+ }
67+
68+ public protocol Reflectable : AnyObject {
69+ func reflect( )
70+ }
71+
72+ // LIBRARY-IR: define linkonce_odr hidden swiftcc void @"$es4swapyyxz_xztlFSi_Tg5"
73+ // LIBRARY-IR: define linkonce_odr hidden swiftcc void @"$e7Library10PointClassCAA11ReflectableA2aDP7reflectyyFTW"
74+
75+ extension PointClass : Reflectable {
76+ public func reflect( ) {
77+ swap ( & x, & y)
78+ }
79+ }
80+
81+ // LIBRARY-IR: define {{.*}} @"$e7Library18createsExistentialAA11Reflectable_pyF"()
82+ @_neverEmitIntoClient
83+ public func createsExistential( ) -> any Reflectable {
84+ return PointClass ( x: 5 , y: 5 )
85+ }
86+
5787// LIBRARY-IR-NOT: define swiftcc
5888// LIBRARY-IR-NOT: define hidden swiftcc
5989
You can’t perform that action at this time.
0 commit comments