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-7185] Spurious "cast from ... to unrelated type ..." warnings when casting tuples #49733

Closed
hamishknight opened this issue Mar 13, 2018 · 4 comments
Assignees
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

@hamishknight
Copy link
Collaborator

Previous ID SR-7185
Radar None
Original Reporter @hamishknight
Type Bug
Status Closed
Resolution Done
Environment

Apple Swift version 4.2-dev (LLVM c4ec2ab808, Clang af436f313e, Swift 347ff6a)
Target: x86_64-apple-darwin17.4.0

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

md5: ab0425117a1ff6a5b67d32a09389ec50

Issue Description:

The following code raises warnings that the casts will always fail despite them actually succeeding:

protocol P {}
class C {}
class D : C, P {}

let x: (C, C) = (D(), D())

// warning: Cast from '(C, C)' to unrelated type '(P, P)' always fails
print(x is (P, P)) // true

// warning: Cast from '(C, C)' to unrelated type '(P, P)' always fails
print(x as? (P, P) as Any) // Optional((D, D))
@belkadan
Copy link
Contributor

Oof, we have lots of problems with tuples. cc @rudkx, @xedin, @slavapestov

@slavapestov
Copy link
Member

I've been collecting spurious cast warning bugs. They're harmless but annoying. I will de-dupe them (and try to fix) at some point.

@LucianoPAlmeida
Copy link
Collaborator

Just verify this seems to be fixed on master.
@hamishknight Can you try to verify? 🙂

@hamishknight
Copy link
Collaborator Author

Thanks for checking @LucianoPAlmeida! This appears to have been fixed by #28910

@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

4 participants