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-14795] Unable to conform to Comparable protocol when nested #57144

Closed
swift-ci opened this issue Jun 20, 2021 · 1 comment
Closed

[SR-14795] Unable to conform to Comparable protocol when nested #57144

swift-ci opened this issue Jun 20, 2021 · 1 comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself conformances Feature → protocol: protocol conformances duplicate Resolution: Duplicates another issue nested types Feature: nested types operators Feature: operators swift 5.4 type checker Area → compiler: Semantic analysis unexpected error Bug: Unexpected error

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented Jun 20, 2021

Previous ID SR-14795
Radar None
Original Reporter robdashnash (JIRA User)
Type Bug
Status Resolved
Resolution Duplicate
Environment

Xcode 12.5 (12E262)
Swift 5.4
MacOS 11.4

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

md5: a83094320601a7e3537a07f9a2558473

relates to:

  • SR-3092 Function-level nested types cannot conform to Equatable

Issue Description:

Attempts to conform to comparable fail, when the class declaration is nested within a test.

func testA() throws {
        
        final class Property: Comparable {
            
            let id: UUID
            let address: String
            let date: Date
                        
            static func < (lhs: Property, rhs: Property) -> Bool {
                lhs.date > rhs.date
            }
            
            static func == (lhs: Property, rhs: Property) -> Bool {
                lhs.id == rhs.id
            }
        }

        // test stuff here
}
Type 'Property' does not conform to protocol 'Equatable'.  
Type 'Property' does not conform to protocol 'Comparable'.

If I cut and paste the property class code to a global scope, it works fine.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis closed this as not planned Won't fix, can't repro, duplicate, stale Jun 3, 2022
@AnthonyLatsis
Copy link
Collaborator

Fixed by #59246

@AnthonyLatsis AnthonyLatsis added duplicate Resolution: Duplicates another issue compiler The Swift compiler in itself type checker Area → compiler: Semantic analysis conformances Feature → protocol: protocol conformances operators Feature: operators nested types Feature: nested types unexpected error Bug: Unexpected error swift 5.4 labels Feb 22, 2023
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 conformances Feature → protocol: protocol conformances duplicate Resolution: Duplicates another issue nested types Feature: nested types operators Feature: operators swift 5.4 type checker Area → compiler: Semantic analysis unexpected error Bug: Unexpected error
Projects
None yet
Development

No branches or pull requests

2 participants