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-4624] Can't cast between generic superclass and generic subclass where subclass has constraints #47201

Closed
swift-ci opened this issue Apr 19, 2017 · 4 comments
Assignees

Comments

@swift-ci
Copy link
Collaborator

@swift-ci swift-ci commented Apr 19, 2017

Previous ID SR-4624
Radar rdar://problem/31708992
Original Reporter keefmoon (JIRA User)
Type Bug
Status Resolved
Resolution Done

Attachment: Download

Environment

Xcode 8.3.1
Toolchain Swift 3.1

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

md5: 87cd2fc021e331aaba3cd65d473be5ae

duplicates:

  • SR-4315 Xcode 8.3 compiler crashes on generic subclass init

Issue Description:

When you have a generics class inheriting from another generics class, and there is a where constraint on the subclass, the compiler prevents casting between subclass and superclass.

Eg. a class signature like this:
class Processor<U: Input, T>: Provider<T> where T == U.OutputType
You can no longer cast between Provider and Processor

This is different from the behaviour in Swift 3.0.

Attached project that compiles and runs in Xcode 8.2.1 using Swift 3.0, but fails in Xcode 8.3.1 using Swift 3.1. Comments in the sample project describe the errors seen.

@swift-ci
Copy link
Collaborator Author

@swift-ci swift-ci commented Apr 19, 2017

Comment by Keith Moon (JIRA)

Issue still exists in Xcode 8.3.2

@belkadan
Copy link
Contributor

@belkadan belkadan commented Apr 19, 2017

@swift-ci create

@belkadan
Copy link
Contributor

@belkadan belkadan commented Apr 19, 2017

@slavapestov, did we change anything here?

@slavapestov
Copy link
Member

@slavapestov slavapestov commented Apr 20, 2017

The bug is fixed on master.

In Swift 3.1, a workaround is to replace

class Processor<U: Input, T>: Provider<T> where T == U.OutputType {

with

class Processor<U: Input>: Provider<U.OutputType> {

@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
Projects
None yet
Development

No branches or pull requests

3 participants