Skip to content
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

[SR-3529] Invoking method on a bridged Objective-C lightweight generic subclass of non-generic base class results in "ambiguous use of method" #46117

Open
erichoracek opened this issue Jan 2, 2017 · 0 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@erichoracek
Copy link

Previous ID SR-3529
Radar None
Original Reporter @erichoracek
Type Bug
Environment

OSX 10.12.2, Xcode 8.2 (8C38)

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, ClangImporter
Assignee @slavapestov
Priority Medium

md5: c9c3f541b061abc3c8aa22c3bb8079cf

Issue Description:

When the following Objective-C is bridged to Swift:

@interface BaseClass : NSObject
- (void)method;
@end

@interface Subclass<T> : BaseClass
- (void)method;
@end

And used as follows from Swift:

let subclass: Subclass<NSNumber> = Subclass()
subclass.method()

It results in the following compiler error:

Ambiguous.swift:: error: ambiguous use of 'method()'
    subclass.method()
    ^
__ObjC.Subclass:3:15: note: found this candidate
    open func method()
              ^
__ObjC.BaseClass:3:15: note: found this candidate
    open func method()
              ^

The generated header looks as follows:

open class BaseClass : NSObject {

    
    open func method()
}

open class Subclass<T : AnyObject> : BaseClass {

    
    open func method()
}

However, if you implement code identical to the generated header in Swift:

open class BaseClass : NSObject {
    open func method() {}
}

open class Subclass<T : AnyObject> : BaseClass {
    open override func method() {}
}

There is no compiler error emitted when invoking `method` as follows:

let subclass: Subclass<NSNumber> = Subclass()
subclass.method()
@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself
Projects
None yet
Development

No branches or pull requests

1 participant