Skip to content

Commit c6284f4

Browse files
authored
Merge pull request #26249 from jckarter/opaque-associated-type-witness-protocol-refinement
IRGen: Use correct archetype conformance code path for opaque associated types.
2 parents 7c6816f + e12f935 commit c6284f4

File tree

3 files changed

+22
-13
lines changed

3 files changed

+22
-13
lines changed

lib/IRGen/GenMeta.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1690,8 +1690,6 @@ namespace {
16901690
auto opaqueType = O->getDeclaredInterfaceType()
16911691
->castTo<OpaqueTypeArchetypeType>();
16921692

1693-
1694-
16951693
for (auto proto : opaqueType->getConformsTo()) {
16961694
auto conformance = ProtocolConformanceRef(proto);
16971695
auto underlyingConformance = conformance

lib/IRGen/GenProto.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1566,17 +1566,6 @@ void WitnessTableBuilder::defineAssociatedTypeWitnessTableAccessFunction(
15661566
IGF.bindLocalTypeDataFromTypeMetadata(ConcreteType, IsExact, self,
15671567
MetadataState::Abstract);
15681568

1569-
// If the associated type is opaque, use the runtime to fetch the conformance.
1570-
if (associatedRootOpaqueType) {
1571-
assert(associatedType == CanType(associatedRootOpaqueType)
1572-
&& "associated type is nested type of opaque type?! not implemented");
1573-
auto wtable = emitOpaqueTypeWitnessTableRef(IGF,
1574-
CanOpaqueTypeArchetypeType(associatedRootOpaqueType),
1575-
associatedProtocol);
1576-
IGF.Builder.CreateRet(wtable);
1577-
return;
1578-
}
1579-
15801569
// Find abstract conformances.
15811570
// TODO: provide an API to find the best metadata path to the conformance
15821571
// and decide whether it's expensive enough to be worth caching.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// RUN: %target-swift-frontend -disable-availability-checking -emit-ir %s | %FileCheck %s
2+
3+
protocol Butt { }
4+
5+
protocol Tubb: Butt { }
6+
7+
protocol P {
8+
associatedtype A: Butt
9+
associatedtype B: Butt
10+
func foo(_ x: A) -> B
11+
}
12+
13+
struct Foo<T: Tubb>: P {
14+
func foo(_ x: T) -> some Tubb { return x }
15+
}
16+
17+
// CHECK-LABEL: define {{.*}} @"$s030opaque_result_type_associated_C17_conformance_path3FooVyxGAA1PAA1B_AA4ButtPWT"
18+
// CHECK: [[TUBB_CONFORMANCE:%.*]] = call swiftcc i8** @swift_getOpaqueTypeConformance({{.*}}, i{{.*}} 1)
19+
// CHECK: [[BUTT_CONFORMANCE_ADDR:%.*]] = getelementptr {{.*}} [[TUBB_CONFORMANCE]], i32 1
20+
// CHECK: [[BUTT_CONFORMANCE_LOAD:%.*]] = load {{.*}} [[BUTT_CONFORMANCE_ADDR]]
21+
// CHECK: [[BUTT_CONFORMANCE:%.*]] = bitcast {{.*}} [[BUTT_CONFORMANCE_LOAD]]
22+
// CHECK: ret {{.*}} [[BUTT_CONFORMANCE]]

0 commit comments

Comments
 (0)