Skip to content

[SR-12750] [C++] Assertion failure when trying to make imported C++ class conform to protocol #55195

Open
@swift-ci

Description

@swift-ci
Previous ID SR-12750
Radar rdar://problem/83465935
Original Reporter martinboehme (JIRA User)
Type Bug
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, CxxInterop
Assignee None
Priority Medium

md5: 3311c4baf107e33900dc7b73b1b24d14

Issue Description:

When declaring a protocol conformance for an imported C++ class, SILGen aborts with an assertion failure in getParameterTypes().

To reproduce, import a C++ module containing the following:

struct ConformsToProtocol {
 int return42() { return 42; }
};

And declare the following protocol conformance:

protocol HasReturn42 {
  mutating func return42() -> CInt
}

extension ConformsToProtocol : HasReturn42 {}

#31617 contains a test that demonstrates this.

The failing assertion is

assert(!param.isInOut() && !param.isVariadic());

in getParameterTypes().

I'm not exactly sure what this assertion is checking. It seems to have been introduced here, when getParameterTypes() was still called expandTupleTypes():

dffa29f

expandTupleTypes() was renamed to getParameterTypes() here (and changed so that it no longer expands tuples):

50b1bae

Is this assertion still required?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.c++ interopFeature: Interoperability with C++compilerThe Swift compiler itself

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions