Skip to content

IRGen: Use correct archetype conformance code path for opaque associated types. #26249

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions lib/IRGen/GenMeta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1690,8 +1690,6 @@ namespace {
auto opaqueType = O->getDeclaredInterfaceType()
->castTo<OpaqueTypeArchetypeType>();



for (auto proto : opaqueType->getConformsTo()) {
auto conformance = ProtocolConformanceRef(proto);
auto underlyingConformance = conformance
Expand Down
11 changes: 0 additions & 11 deletions lib/IRGen/GenProto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1566,17 +1566,6 @@ void WitnessTableBuilder::defineAssociatedTypeWitnessTableAccessFunction(
IGF.bindLocalTypeDataFromTypeMetadata(ConcreteType, IsExact, self,
MetadataState::Abstract);

// If the associated type is opaque, use the runtime to fetch the conformance.
if (associatedRootOpaqueType) {
assert(associatedType == CanType(associatedRootOpaqueType)
&& "associated type is nested type of opaque type?! not implemented");
auto wtable = emitOpaqueTypeWitnessTableRef(IGF,
CanOpaqueTypeArchetypeType(associatedRootOpaqueType),
associatedProtocol);
IGF.Builder.CreateRet(wtable);
return;
}

// Find abstract conformances.
// TODO: provide an API to find the best metadata path to the conformance
// and decide whether it's expensive enough to be worth caching.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// RUN: %target-swift-frontend -disable-availability-checking -emit-ir %s | %FileCheck %s

protocol Butt { }

protocol Tubb: Butt { }

protocol P {
associatedtype A: Butt
associatedtype B: Butt
func foo(_ x: A) -> B
}

struct Foo<T: Tubb>: P {
func foo(_ x: T) -> some Tubb { return x }
}

// CHECK-LABEL: define {{.*}} @"$s030opaque_result_type_associated_C17_conformance_path3FooVyxGAA1PAA1B_AA4ButtPWT"
// CHECK: [[TUBB_CONFORMANCE:%.*]] = call swiftcc i8** @swift_getOpaqueTypeConformance({{.*}}, i{{.*}} 1)
// CHECK: [[BUTT_CONFORMANCE_ADDR:%.*]] = getelementptr {{.*}} [[TUBB_CONFORMANCE]], i32 1
// CHECK: [[BUTT_CONFORMANCE_LOAD:%.*]] = load {{.*}} [[BUTT_CONFORMANCE_ADDR]]
// CHECK: [[BUTT_CONFORMANCE:%.*]] = bitcast {{.*}} [[BUTT_CONFORMANCE_LOAD]]
// CHECK: ret {{.*}} [[BUTT_CONFORMANCE]]