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-3849] Combined class and protocol constraints aren't propagated correctly #46434

Closed
swift-ci opened this issue Feb 3, 2017 · 2 comments
Closed
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself type checker Area → compiler: Semantic analysis

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented Feb 3, 2017

Previous ID SR-3849
Radar rdar://problem/38535743
Original Reporter otbivnoe (JIRA User)
Type Bug
Status Resolved
Resolution Done
Environment

Xcode 8.2.1

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

md5: 8100285ab48c0c97e0d3c3418171fe8c

relates to:

  • SR-3837 init provided by protocol constraint not found when generic func requires subclass

Issue Description:

There is strange generic behaviour:

protocol Textable {}

class Test {
    init<T: NSObject>(values: [T]) where T: Textable {}
}

func test<T: NSObject>(value: T) where T: Textable {
    let values = [value]
    Test(values: [value]) // Cannot convert value of type '[T]' to expected argument type '[_]'
}

But if I write

Test(values: values)

it works fine.

Also the similar problem with this code:

func test<T: NSObject>(ts: [T]) where T: Textable {}

func test<T1: NSObject, T2: NSObject>(t1: T1, t2: T2) where T1: Textable, T2: Textable {
    
    test(ts: [t1, t2]) //Cannot convert value of type '[NSObject]' to expected argument type '[_]'
}
@slavapestov
Copy link
Member

@swift-ci create

@slavapestov
Copy link
Member

#15489

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
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 type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

2 participants