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-6353] Cast from to unrelated type always fails but doesn't fail #48903

Closed
swift-ci opened this issue Nov 10, 2017 · 1 comment
Closed

[SR-6353] Cast from to unrelated type always fails but doesn't fail #48903

swift-ci opened this issue Nov 10, 2017 · 1 comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself type checker Area → compiler: Semantic analysis

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-6353
Radar rdar://problem/35469176
Original Reporter Sylvain (JIRA User)
Type Bug
Status Resolved
Resolution Duplicate

Attachment: Download

Environment

Xcode 9.1, Swift 4.0

Additional Detail from JIRA
Votes 1
Component/s Compiler
Labels Bug, TypeChecker
Assignee None
Priority Medium

md5: 40e13a864e7b03441494cf14b00df9c1

duplicates:

  • SR-5252 Warning: Cast from … to unrelated type false positive?

is duplicated by:

  • SR-6771 "Cast always fails" false positive warning when casting to a generic subclass

Issue Description:

Trying to cast a UITableViewCell inherited class containing a generic shows a warning that casting from UITableViewCell back to this class will always fail when it doesn't.

Better open the Playground to understand the problem.

@belkadan
Copy link
Contributor

class SharedSuperClass { }
protocol MyProtocol { }
class MyView: SharedSuperClass, MyProtocol { }
class MyGenericClass<View: MyProtocol>: SharedSuperClass { }

class ThisWarningLies<View: SharedSuperClass & MyProtocol> {
 func doStuff() {
     let cell: SharedSuperClass = MyGenericClass<View>()
     if cell is MyGenericClass<View> {
         print("Never say never")
     }
 }
}

ThisWarningLies<MyView>().doStuff()

Might be the same as something else we have, might not. Thanks for the report!

@swift-ci create

@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 type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

2 participants