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-8098] Compiler segfault on instantiating object from protocol Type that requires base class #50631

Closed
swift-ci opened this issue Jun 25, 2018 · 4 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself crash Bug: A crash, i.e., an abnormal termination of software

Comments

@swift-ci
Copy link
Collaborator

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

macOS: 10.13.5

Swift: Apple Swift version 4.1.2 (swiftlang-902.0.54 clang-902.0.39.2)
Target: x86_64-apple-darwin17.6.0

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, CompilerCrash
Assignee @slavapestov
Priority Medium

md5: d4a3fd75322d73c1c0ed2a36e947e475

duplicates:

  • SR-6816 Let protocols inherit from class types

Issue Description:

Simply trying to compile the following code will crash the compiler.

class Base {}

protocol Proto where Self: Base {
    init()
}

final class Derived: Base, Proto {
    override init() {}
}

func returnsProtoType() -> Proto.Type {
    return Derived.self
}

func returnsProto() -> Proto {
    return returnsProtoType().init()
}
@belkadan
Copy link
Contributor

Still crashes. This looks different from SR-7452; since the Derived class initializer wasn't marked required, it shouldn't be allowed to conform to Proto.

cc @slavapestov

@swift-ci
Copy link
Collaborator Author

Comment by Rob Agnese (JIRA)

It doesn't need to be marked required when it's a final class, IIRC.

You can take out final and mark the init required and it still crashes.

EDIT: So, yes- this does seem to be a duplicate. I tried searching and didn't find that other one. Apologies.

@belkadan
Copy link
Contributor

Whoops, sorry. Missed the final.

@slavapestov
Copy link
Member

"protocol Proto where Self: Base" is not supported yet, sorry. It's on my list.

@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 in itself crash Bug: A crash, i.e., an abnormal termination of software
Projects
None yet
Development

No branches or pull requests

4 participants