Skip to content

Commit 26ae22b

Browse files
authored
Merge pull request #26251 from jckarter/opaque-associated-type-witness-protocol-refinement-5.1
[5.1] IRGen: Use correct archetype conformance code path for opaque associated types.
2 parents e50d21e + 41cac98 commit 26ae22b

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
@@ -1565,17 +1565,6 @@ void WitnessTableBuilder::defineAssociatedTypeWitnessTableAccessFunction(
15651565
IGF.bindLocalTypeDataFromTypeMetadata(ConcreteType, IsExact, self,
15661566
MetadataState::Abstract);
15671567

1568-
// If the associated type is opaque, use the runtime to fetch the conformance.
1569-
if (associatedRootOpaqueType) {
1570-
assert(associatedType == CanType(associatedRootOpaqueType)
1571-
&& "associated type is nested type of opaque type?! not implemented");
1572-
auto wtable = emitOpaqueTypeWitnessTableRef(IGF,
1573-
CanOpaqueTypeArchetypeType(associatedRootOpaqueType),
1574-
associatedProtocol);
1575-
IGF.Builder.CreateRet(wtable);
1576-
return;
1577-
}
1578-
15791568
// Find abstract conformances.
15801569
// TODO: provide an API to find the best metadata path to the conformance
15811570
// 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)