swiftlang / swift

The Swift Programming Language
https://swift.org
Apache License 2.0
67.58k stars 10.36k forks source link

[SR-6894] An imported convenience initializer that overloads a designated initializer with the same NS_SWIFT_NAME cannot be called #49443

Open swift-ci opened 6 years ago

swift-ci commented 6 years ago
Previous ID SR-6894
Radar rdar://problem/37160678
Original Reporter stephan (JIRA User)
Type Bug

Attachment: Download

Additional Detail from JIRA | | | |------------------|-----------------| |Votes | 0 | |Component/s | Compiler | |Labels | Bug, ClangImporter | |Assignee | None | |Priority | Medium | md5: f61cc860be9ec93c3135bcfbdc3f0f1c

Issue Description:

In the attached sample project the line `MyClass({builder in })` in ViewController.swift compiles, but `MyClass2({builder in })` does not, although both classes have almost the same interface. The bridged convenience initializer of `MyClass2` doesn't seem to be available

belkadan commented 6 years ago

Very strange! Thanks, Stephen.

@swift-ci create

swift-ci commented 5 years ago

Comment by Stephan Tolksdorf (JIRA)

This bug is caused by recordShadowedDecls in NameLookup.cpp assuming that all Objective-C initializers with the same name shadow each other, which seems to ignore that Objective-C initializers can be overloaded via the swift_name attribute.

@belkadan @DougGregor Do you maybe have a suggestion how best to fix this issue? I wonder why it's possible to 'shadow' initializers at all. I would have expected constructors with identical overload signatures to cause an ambiguity error.