Skip to content

Conversation

@egorzhdan
Copy link
Contributor

If an overloaded operator returns auto, and the implementation of it returns an instance of a type declared within the operator, Swift was crashing when trying to import the internal type. Instead of crashing, let's not import those overloads.

rdar://159271202 / resolves #83942

…as `auto`

If an overloaded operator returns `auto`, and the implementation of it returns an instance of a type declared within the operator, Swift was crashing when trying to import the internal type. Instead of crashing, let's not import those overloads.

rdar://159271202 / resolves swiftlang#83942
@egorzhdan egorzhdan added the c++ interop Feature: Interoperability with C++ label Jan 19, 2026
@egorzhdan
Copy link
Contributor Author

@swift-ci please test

@egorzhdan egorzhdan marked this pull request as ready for review January 19, 2026 19:06
@egorzhdan
Copy link
Contributor Author

@swift-ci please test Linux


auto decl = dyn_cast<clang::NamedDecl>(dc);
if (!decl)
if (!decl || !decl->getDeclName().isIdentifier())
Copy link
Contributor

Choose a reason for hiding this comment

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

Would this also prevent us importing types from unnamed structs like:

struct S {
  struct {
    struct Inner {
      int a, b;
    } c;
    auto f() {
        return Inner{1, 2};
    }
  } d;
};

?

And if it would, is that intentional?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ interop Feature: Interoperability with C++

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Assertion failure when importing C++ struct defined within an overloaded operator

2 participants