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-8207] Error on incorrect parameter #50739

Open
swift-ci opened this issue Jul 9, 2018 · 1 comment
Open

[SR-8207] Error on incorrect parameter #50739

swift-ci opened this issue Jul 9, 2018 · 1 comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself diagnostics QoI Bug: Diagnostics Quality of Implementation type checker Area → compiler: Semantic analysis

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented Jul 9, 2018

Previous ID SR-8207
Radar None
Original Reporter vincent (JIRA User)
Type Bug
Environment

macOS 10.13.5

Xcode 9.4.1, Xcode 10.0 beta 3

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

md5: 922ee3326077438a16219fdf90842455

Issue Description:

Compiling the following code:

import Foundation

class A {}
struct B {}
protocol P {
    associatedtype C
    associatedtype D
}

class E<T: P> where T.C == A {
    enum Hoge {
        case a
    }

    func foo(completion: @escaping (A) -> Void) {
        bar(hoge: .a, completion: completion)
    }

    func bar(hoge: Hoge, completion: @escaping (T.D) -> Void) {
    }
}

Gives the following error:

x.swift:16:20: error: member 'a' in 'E<_>.Hoge' produces result of type 'E<T>.Hoge', but context expects 'E<_>.Hoge'
        bar(hoge: .a, completion: completion)
                   ^

The parameter that is incorrect is the 2nd one, but the error is on the 1st one (which is correct).
Note that the error is correct if you remove the where clause on the class definition.

@belkadan
Copy link
Contributor

belkadan commented Jul 9, 2018

Why is the second parameter more incorrect than the first parameter? In neither case is there an obvious way to change foo to make it work.

@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. compiler The Swift compiler in itself diagnostics QoI Bug: Diagnostics Quality of Implementation type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

2 participants