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-6469] instantiating a generic in such a way that it references itself breaks compiler #49019

Closed
swift-ci opened this issue Nov 24, 2017 · 0 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@swift-ci
Copy link
Collaborator

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

swift-4.1-DEVELOPMENT-SNAPSHOT-2017-11-23-a.xctoolchain

also happens in XCode 9.1 as shipped by Apple

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

md5: 43720e4e0d59a2a27c29bbd196f287e2

duplicates:

  • SR-2549 [CRTP] Non-generic class inheriting from a generic class with Self as generic parameter locks execution

Issue Description:

Even in one source file (i.e. not across compilation boundaries,) inheriting from a generic and using the derived class as a generic parameter results in a runtime crash. See included test case. This looks like a contrived example but comes up in frameworks code where the generic needs to know the type of the final class for type safety.

import XCTest

// swiftlint:disable private_over_fileprivate

fileprivate class G<T> {
    func foo(test: T) {
        print("\(test)")
    }
}

fileprivate class C: G<C> {

}

class TestSwiftSR6469: XCTestCase {
    func testSelfReferentialGeneric() {
        // this test breaks with locking loop at runtime
        _ = C()
    }
}
@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
Projects
None yet
Development

No branches or pull requests

1 participant