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-6187] Swift does not infer the signature automatically #48739

Closed
swift-ci opened this issue Oct 19, 2017 · 1 comment
Closed

[SR-6187] Swift does not infer the signature automatically #48739

swift-ci opened this issue Oct 19, 2017 · 1 comment
Labels
compiler The Swift compiler in itself conformances Feature → protocol: protocol conformances duplicate Resolution: Duplicates another issue feature A feature request or implementation improvement protocol Feature → type declarations: Protocol declarations type checker Area → compiler: Semantic analysis

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented Oct 19, 2017

Previous ID SR-6187
Radar None
Original Reporter aabbcc.double (JIRA User)
Type Bug
Status Resolved
Resolution Duplicate
Environment

Xcode - Version - Version 9.0 (9A235)
Xcode - Build Settings - Swift Version 4.0
Used third party library - RxSwift 4.0.0

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug
Assignee None
Priority Medium

md5: 11405a150226f93b1af09eff1ef5778c

duplicates:

  • SR-522 Protocol funcs cannot have covariant returns

Issue Description:

This simple class won't compile.

import Foundation
import RxSwift
public protocol DeviceType {
    var name: String{ get } 
    var identifier: UUID { get }
    var buttonPressed: Observable<Bool>{ get }
}

public class Device: DeviceType { 
    public let name: String 
    public let identifier: UUID
    public let buttonPressed: ReplaySubject<Bool>

    init(device orig:NMBRDevice) {
        name = orig.name ?? "" 
        identifier = orig.identifier 
        buttonPressed = ReplaySubject.create(bufferSize: 1) 
    }
}

However, ReplaySubject is subclass of Observable

@belkadan
Copy link
Contributor

You'll have to match the static type exactly for now, sorry. You can work around this by making a computed property with one type and a stored property with the other.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added duplicate Resolution: Duplicates another issue feature A feature request or implementation type checker Area → compiler: Semantic analysis conformances Feature → protocol: protocol conformances protocol Feature → type declarations: Protocol declarations improvement and removed bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. labels Jan 27, 2023
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler The Swift compiler in itself conformances Feature → protocol: protocol conformances duplicate Resolution: Duplicates another issue feature A feature request or implementation improvement protocol Feature → type declarations: Protocol declarations type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

3 participants