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-7450] Conditional Conformances: Runtime crash when reference self type. #49993

Closed
swift-ci opened this issue Apr 17, 2018 · 5 comments
Closed
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler itself conditional conformances Feature → protocol → conformances: conditional conformances crash Bug: A crash, i.e., an abnormal termination of software run-time crash Bug → crash: Swift code crashed during execution

Comments

@swift-ci
Copy link
Contributor

Previous ID SR-7450
Radar rdar://problem/37170296
Original Reporter tarunon (JIRA User)
Type Bug
Status Resolved
Resolution Done
Environment

Xcode Version 9.3 (9E145)
Apple Swift version 4.1 (swiftlang-902.0.48 clang-902.0.37.1)
Target: x86_64-apple-darwin17.5.0

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

md5: 5a9372b126515a64965caf844fecb76b

Issue Description:

protocol DictionaryType {
    associatedtype Key
    associatedtype Value

}

protocol A: DictionaryType where Key == Value {
    static func foo()
}

extension A {
    static func foo() {
        print(type(of: self))
    }
}

extension Dictionary: DictionaryType {}

extension Dictionary: A where Key == Value {
    
}

extension Array where Element: A {
    static func foo() {
        Element.foo()
    }
}

[String: String].foo() // Dictionary<String, String>
[[String: String]].foo() // Crash

1. Make protocol that extends other protocol equivement 2 associatedtypes.
2. Implement 2 protocols at 1 generics type.
3. Reference type in other generics extension function.

Maybe same bug of https://bugs.swift.org/browse/SR-7449

@belkadan
Copy link
Contributor

@jckarter, @DougGregor, we were just talking about the possibility of something like this yesterday, right?

@jckarter
Copy link
Contributor

Yeah, this looks like it could be what we're tracking as rdar://problem/37170296 internally. Our type-by-mangled-name runtime code doesn't yet handle all same-type-constrained contexts.

@DougGregor
Copy link
Member

Yes, this is precisely what @jckarter was working on yesterday. I suspect that it'll be fixed by #15960

@jckarter
Copy link
Contributor

That fix alone might not address this problem, since it doesn't include the runtime work to demangle types in contexts with same-type constraints.

@slavapestov
Copy link
Contributor

Doug merged #19571 to master already

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added the crash Bug: A crash, i.e., an abnormal termination of software label Dec 12, 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 itself conditional conformances Feature → protocol → conformances: conditional conformances crash Bug: A crash, i.e., an abnormal termination of software run-time crash Bug → crash: Swift code crashed during execution
Projects
None yet
Development

No branches or pull requests

6 participants