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 {
1757
1757
return true ;
1758
1758
}
1759
1759
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
+
1760
1767
return false ;
1761
1768
}
Original file line number Diff line number Diff line change @@ -86,6 +86,25 @@ public func getPointOffsets() -> [Int] {
86
86
enumerateByteOffsets ( Point . self)
87
87
}
88
88
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
+
89
108
//--- ClientA.swift
90
109
import Root
91
110
@@ -99,6 +118,10 @@ public func getPointAndColorOffsets() -> [Int] {
99
118
getPointOffsets ( ) + enumerateByteOffsets( Color . self)
100
119
}
101
120
121
+ public func getReflectableA( ) -> any AnyObject & Reflectable {
122
+ return PointClass ( x: 5 , y: 5 )
123
+ }
124
+
102
125
//--- ClientB.swift
103
126
import Root
104
127
@@ -112,6 +135,10 @@ public func getExtraPoint3DOffsets() -> [Int] {
112
135
return Array ( point3DOffsets [ pointOffsets. count... ] )
113
136
}
114
137
138
+ public func getReflectableB( ) -> any AnyObject & Reflectable {
139
+ return PointClass ( x: 5 , y: 5 )
140
+ }
141
+
115
142
//--- Application.swift
116
143
import ClientA
117
144
import ClientB
@@ -124,6 +151,7 @@ struct Main {
124
151
print ( pointAndColorOffsets. count)
125
152
print ( extraColor3DOffsets. count)
126
153
154
+ let reflected = [ getReflectableA ( ) , getReflectableB ( ) ]
127
155
// CHECK: DONE
128
156
print ( " DONE " )
129
157
}
Original file line number Diff line number Diff line change 21
21
22
22
//--- Library.swift
23
23
24
+ // LIBRARY-IR: @"$e7Library10PointClassCN" = weak_odr global
25
+
24
26
// Never referenced.
25
27
// LIBRARY-IR-NOT: @"$es23_swiftEmptyArrayStorageSi_S3itvp" = weak_odr {{(protected |dllexport )?}}global
26
28
@@ -54,6 +56,34 @@ public func unnecessary() -> Int64 { 5 }
54
56
@_neverEmitIntoClient
55
57
public func unusedYetThere( ) -> Int64 { 5 }
56
58
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
+
57
87
// LIBRARY-IR-NOT: define swiftcc
58
88
// LIBRARY-IR-NOT: define hidden swiftcc
59
89
You can’t perform that action at this time.
0 commit comments