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-13005] (B as? D).unsafelyUnwrapped should optimize better #55450

Open
dabrahams opened this issue Jun 13, 2020 · 0 comments
Open

[SR-13005] (B as? D).unsafelyUnwrapped should optimize better #55450

dabrahams opened this issue Jun 13, 2020 · 0 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior.

Comments

@dabrahams
Copy link
Collaborator

Previous ID SR-13005
Radar None
Original Reporter @dabrahams
Type Bug
Additional Detail from JIRA
Votes 0
Component/s
Labels Bug
Assignee None
Priority Medium

md5: 2f380b001bafaf01faf84d26648497b3

Issue Description:

testMe2 should generate equivalent code to testMe1, but instead it generates something that includes the call to _swift_dynamicCastClass.

class B {  }

class D: B {  }

func testMe1(b: B) -> D {
  unsafeDowncast(b, to: D.self)
}

func testMe2(b: B) -> D {
  (b as? D).unsafelyUnwrapped
}
@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
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.
Projects
None yet
Development

No branches or pull requests

1 participant