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-10460] Possible Swift 5 Compiler Regression w/Multiple Closure Arguments #52860

Closed
djehrlich opened this issue Apr 12, 2019 · 8 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 5.0

Comments

@djehrlich
Copy link

Previous ID SR-10460
Radar rdar://problem/49855177
Original Reporter @djehrlich
Type Bug
Status Closed
Resolution Done
Environment

Tested using a MacOS command line application in:

Xcode Version 10.1 (10B61)

Xcode Version 10.2 (10E125)

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

md5: c71b391047660b48b745fb84e9a12649

Issue Description:

This code compiles under Xcode 10.1, but fails to compile in 10.2 (in Swift 5 or Swift 4.2 Language Version). I suspect this can be reduced further.

struct R<V,Error> {}
struct Rsp<C> {}
protocol P {
    typealias PR<C> = R<Rsp<C>,Error>
    typealias AnyPR = PR<Any>
}
func f1<Value> (
    cl1: (R<Value,Error>) -> Void
){}
func f2 (
    cl2: (P.AnyPR) -> Void
){}
func f3<Value> (
    cl1: (R<Value,Error>) -> Void,
    cl2: (P.AnyPR) -> Void
){}


func callFs(
    cl1: (R<Void,Error>) -> Void,
    cl2: (P.AnyPR) -> Void
)
{
    f1(cl1: cl1) // Compiles
    f2(cl2: cl2) // Compiles

    // Since the calls to f1 & f2 compile, a call to f3 should also compile
    // First concern:  Xcode 10.2 provides the following (incorrect?)
    // completion for invoking "f3"
    // f3(cl1: <#T##(R<P, Error>) -> Void#>, cl2: <#T##(R<Rsp<Any>, Error>) -> Void#>)
    // And when I pass in the arguments to f3 the way I did to f1 & f2,
    // I get a compiler error
    f3(
        cl1: cl1, // Error: In argument type '(R<Void, Error>) -> Void', '()' does not conform to expected type 'P'
        cl2: cl2
    )
}
@belkadan
Copy link
Contributor

@slavapestov, what does it mean to put a typealias into a protocol like this?

@slavapestov
Copy link
Member

@belkadan A protocol typelias is like an ordinary type alias except it has an implicit "Self" generic parameter.

@belkadan
Copy link
Contributor

Right, but they're referring to it as P.AnyPR.

…oh, that's the existential P, and it doesn't matter because they don't reference Self.

@belkadan
Copy link
Contributor

Okay, yeah, this makes no sense. Thanks, David.

@slavapestov
Copy link
Member

I think the bug is that a generic type alias with an existential base doesn't check its constraints properly.

@xedin
Copy link
Member

xedin commented Apr 12, 2019

Hm, this is interesting, the argument gets a type of `(Self.PR<Any>) -> Void` after solver opens it.

@xedin
Copy link
Member

xedin commented Apr 3, 2021

Fixed on main branch. @djehrlich Please use the latest snapshot of main branch from swift.org to verify and close.

@djehrlich
Copy link
Author

I cannot replicate the issue in Xcode 12.4 with a main branch toolchain snapshot.

That said, I was also not able to replicate the issue with "stock" Xcode 12.4 either. I no longer have any Xcode 10 or 11 releases installed, so I cannot determine when the regression fixed.

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

No branches or pull requests

5 participants