Skip to content

Commit 1330e34

Browse files
committed
[Distributed] IRGen: Drop marker protocol requirements from accessible function generic environments
Since marker protocol do not exist at runtime, it's harmful to keep them in a generic environment because they cannot be checked. Resolves: rdar://90293494
1 parent 2b6379d commit 1330e34

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

lib/IRGen/GenDecl.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4172,7 +4172,10 @@ void IRGenModule::emitAccessibleFunctions() {
41724172

41734173
GenericSignature signature;
41744174
if (auto *env = func->getGenericEnvironment()) {
4175-
signature = env->getGenericSignature();
4175+
// Drop all of the marker protocols because they are effect-less
4176+
// at runtime.
4177+
signature = env->getGenericSignature().withoutMarkerProtocols();
4178+
41764179
genericEnvironment =
41774180
getAddrOfGenericEnvironment(signature.getCanonicalSignature());
41784181
}

test/Distributed/Runtime/distributed_actor_remoteCallTarget_demanglingTargetNames.swift

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ import FakeDistributedActorSystems
1919

2020
typealias DefaultDistributedActorSystem = FakeRoundtripActorSystem
2121

22+
protocol SomeProtocol {}
23+
extension String: SomeProtocol {}
24+
2225
distributed actor Greeter {
2326
distributed func noParams() {}
2427
distributed func noParamsThrows() throws {}
@@ -28,9 +31,9 @@ distributed actor Greeter {
2831
distributed func oneLabel(value: String, _ value2: String, _ value3: String) {}
2932
distributed func parameterSingle(first: String) {}
3033
distributed func parameterPair(first: String, second: Int) {}
31-
// FIXME(distributed): rdar://90293494 fails to get
32-
// distributed func generic<A: Codable & Sendable>(first: A) {}
33-
// distributed func genericNoLabel<A: Codable & Sendable>(_ first: A) {}
34+
distributed func generic<A: Codable & Sendable>(first: A) {}
35+
distributed func genericThree<A: Codable & Sendable & SomeProtocol>(first: A) {}
36+
distributed func genericThreeTwo<A: Codable & Sendable, B: Codable & SomeProtocol>(first: A, second: B) {}
3437
}
3538
extension Greeter {
3639
distributed func parameterTriple(first: String, second: Int, third: Double) {}
@@ -65,16 +68,25 @@ func test() async throws {
6568
_ = try await greeter.parameterTriple(first: "X", second: 2, third: 3.0)
6669
// CHECK: >> remoteCallVoid: on:main.Greeter, target:main.Greeter.parameterTriple(first:second:third:)
6770

68-
// FIXME: rdar://90293494 seems to fail getting the substitutions?
69-
// _ = try await greeter.generic(first: "X")
70-
// // TODO: >> remoteCallVoid: on:main.Greeter, target:main.Greeter.parameterTriple(first:second:third:)
71+
_ = try await greeter.generic(first: "X")
72+
// CHECK: >> remoteCallVoid: on:main.Greeter, target:main.Greeter.generic(first:)
73+
74+
_ = try await greeter.genericThree(first: "X")
75+
// CHECK: >> remoteCallVoid: on:main.Greeter, target:main.Greeter.genericThree(first:)
76+
77+
_ = try await greeter.genericThreeTwo(first: "X", second: "SecondValue")
78+
// CHECK: >> remoteCallVoid: on:main.Greeter, target:main.Greeter.genericThreeTwo(first:second:)
7179

7280
print("done")
7381
// CHECK: done
7482
}
7583

7684
@main struct Main {
7785
static func main() async {
78-
try! await test()
86+
do {
87+
try await test()
88+
} catch {
89+
print("ERROR: \(error)")
90+
}
7991
}
8092
}

0 commit comments

Comments
 (0)