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-7701] Apparently incorrect compiler error on static property with same name as instance property #50241

Closed
swift-ci opened this issue May 16, 2018 · 2 comments
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

Previous ID SR-7701
Radar rdar://problem/40295667
Original Reporter marcpalmer (JIRA User)
Type Bug
Status Resolved
Resolution Cannot Reproduce
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, TypeChecker
Assignee None
Priority Medium

md5: cf827d8092123ff25e9988a5693636a4

Issue Description:

The following code results in an error:

Playground execution failed:

error: StaticPropTest.playground:13:37: error: instance member 'reuseIdentifier' cannot be used on type 'ListHeaderFooterView' (aka 'UICollectionReusableView & ListCollectionHeaderFooterViewType')
case .view(let type): print(type.reuseIdentifier)
^~~~ ~~~~~~~~~~~~~~~

This would appear to be incorrect as the type is clearly a metatype and not an instance, so it is odd that the compiler would complain about an instance property being accessed here. It is of course true that `UICollectionReusableView` has an instance property with that name.

import UIKit

public protocol ListCollectionHeaderFooterViewType {
    static var reuseIdentifier: String { get }
}

public typealias ListHeaderFooterView = UICollectionReusableView & ListCollectionHeaderFooterViewType

public enum SectionAccessory {
    case title(String)
    case view(ListHeaderFooterView.Type)
}

func doEeet(accessory: SectionAccessory) {
    switch accessory {
        case .title(let s): print(s)
        case .view(let type): print(type.reuseIdentifier)
    }
}
@belkadan
Copy link
Contributor

@swift-ci create

@xedin
Copy link
Member

xedin commented Jan 10, 2020

I have testing the example from description with Version 11.3 (11C29) and it compiles just fine. marcpalmer (JIRA User) Could you please verify?

@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

3 participants