Skip to content

[cxx-interop][IRGen] Emit type metadata accessors correctly #74208

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
merged 1 commit into from
Jun 7, 2024
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
3 changes: 0 additions & 3 deletions lib/IRGen/MetadataRequest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1102,9 +1102,6 @@ MetadataAccessStrategy irgen::getTypeMetadataAccessStrategy(CanType type) {
assert(type->hasUnboundGenericType());
}

if (type->isForeignReferenceType())
return MetadataAccessStrategy::PublicUniqueAccessor;

if (requiresForeignTypeMetadata(nominal))
return MetadataAccessStrategy::ForeignAccessor;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is what needs to be returned for a C++ reference type.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. We were lazily emitting the type metadata when we first referenced in, but we were emitting it with strong linkage? Yes, this is the right fix, then.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's right


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// RUN: %empty-directory(%t)
// RUN: split-file %s %t
// RUN: %target-build-swift -I %S/Inputs %t/main.swift %t/second.swift -cxx-interoperability-mode=default -Xfrontend -disable-availability-checking

// XFAIL: OS=windows-msvc

//--- main.swift
import ReferenceCounted

protocol P1 {}
extension GlobalCount : P1 {}

//--- second.swift
import ReferenceCounted

protocol P2 {}
extension GlobalCount : P2 {}