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-8210] Value of type does not conform to expected element type #50742

Closed
swift-ci opened this issue Jul 9, 2018 · 1 comment
Closed

[SR-8210] Value of type does not conform to expected element type #50742

swift-ci opened this issue Jul 9, 2018 · 1 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

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented Jul 9, 2018

Previous ID SR-8210
Radar None
Original Reporter trololo (JIRA User)
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, TypeChecker
Assignee None
Priority Medium

md5: c6953788307f0e67cd5c68f99057f75e

Issue Description:

protocol ModuleConfigurator { }
protocol ModuleProperties { }
final class BackupCardProperties { }
extension BackupCardProperties: ModuleProperties { }
 
class Configurator<T> where T: ModuleProperties {
 
    // MARK: - Properties
 
    var properties: T
 
    // MARK: - Initialization
 
    init(properties: T) {
        self.properties = properties
    }
 }
extension Configurator: ModuleConfigurator where T == BackupCardProperties { }
var list: [ModuleConfigurator] = [Configurator(properties: BackupCardProperties())]

Compilation error:

Value of type 'Configurator<BackupCardProperties>' does not conform to expected element type 'ModuleConfigurator'

It works if I use

class Configurator<T> where T: ModuleProperties { }
var list: [ModuleConfigurator] = [Configurator<BackupCardProperties>()]

or

class Configurator<T> where T: ModuleProperties {
 
    // MARK: - Properties
 
    var properties: T
 
    // MARK: - Initialization
 
    init(properties: T) {
        self.properties = properties
    }
 }
 
var list: [ModuleConfigurator] = [Configurator<BackupCardProperties>(properties: BackupCardProperties())]
@belkadan
Copy link
Contributor

belkadan commented Jul 9, 2018

Seems to be fixed in Swift 4.2!

@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