Skip to content

Commit 5b88b5f

Browse files
committed
[Embeddedd] Protocol conformance tables have nonunique definitions
Fixes rdar://162071487.
1 parent cc519a0 commit 5b88b5f

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

lib/IRGen/Linking.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1757,5 +1757,10 @@ 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+
return true;
1763+
}
1764+
17601765
return false;
17611766
}

test/embedded/linkage/diamond.swift

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff 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
90109
import 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
103126
import 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
116143
import ClientA
117144
import 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
}

0 commit comments

Comments
 (0)