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-7899] [4.2 regression] type checker chooses different type than it used to #50434

Closed
mayoff opened this issue Jun 6, 2018 · 5 comments
Closed
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself regression swift 4.2 type checker Area → compiler: Semantic analysis

Comments

@mayoff
Copy link

mayoff commented Jun 6, 2018

Previous ID SR-7899
Radar rdar://problem/40861661
Original Reporter @mayoff
Type Bug
Status Closed
Resolution Duplicate
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, 4.2Regression, TypeChecker
Assignee @xedin
Priority Medium

md5: c99cb2692d79d008f46d452212e842cb

duplicates:

  • SR-7884 Overload resolution picks optional variant even when value is not optional

Issue Description:

Consider the following program:

import Foundation

let sequence: NSArray? = nil
if let url = sequence?.lazy.compactMap({ $0 as? NSURL }).first {
    print(url)
}

The swiftc that comes with Xcode 9.4 chooses type NSURL for the url variable.

The swiftc that comes with Xcode 10 beta chooses type ((NSURL) throws -> Bool) throws -> NSURL? for the url variable. (It's using the type of the first(where: ) method instead of the first property.)

@mayoff
Copy link
Author

mayoff commented Jun 6, 2018

cc @xedin @rudkx @moiseev

@xedin
Copy link
Member

xedin commented Jun 6, 2018

This seems like an artifact of the `compactMap`, @moiseev?

@xedin
Copy link
Member

xedin commented Jun 6, 2018

Oh, huh, this is related to the optimization @DougGregor added which tries to compare declarations in disjunction with two choices to determine which one is going to be better even before we try to solve, in effort to speed up type-checker, but it seems like in this case it's mis-firing.

@xedin
Copy link
Member

xedin commented Jun 6, 2018

@swift-ci create

@rudkx
Copy link
Member

rudkx commented Jun 7, 2018

This has the same underlying issue as the linked-to bug.

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

No branches or pull requests

4 participants