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-10091] Generic typealias extension bug #52493

Open
Agarunov opened this issue Mar 12, 2019 · 2 comments
Open

[SR-10091] Generic typealias extension bug #52493

Agarunov opened this issue Mar 12, 2019 · 2 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

@Agarunov
Copy link

Previous ID SR-10091
Radar None
Original Reporter @Agarunov
Type Bug
Environment

Swift 5.0 Xcode 10.2 beta 4 (10P107d)

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

md5: 559564f7fb973cbd0cabcf2ce7505244

Issue Description:

Compiler can not infer generic type from typealias.

For example, this code is not compile:

enum MyResult<D, E> {
    case data(D)
    case error(E)
}


enum MyError {
    case invalidRequest
}


typealias MyErrorResult<D> = MyResult<D, MyError>


extension MyErrorResult where D == Int {
    func update(with value: Int) -> MyErrorResult<Int> {
        return self // error: Cannot convert return expression of type 'MyResult<Int, E>' to return type 'MyErrorResult<Int>' (aka 'MyResult<Int, MyError>')
    }
}

But if we add additional constraint to extension, everything is ok:

extension MyErrorResult where D == Int, E == MyError {
    func update(with value: Int) -> MyErrorResult<Int> {
        return self
    }
}
@belkadan
Copy link
Contributor

cc @xedin, @slavapestov

@slavapestov
Copy link
Member

This needs to be diagnosed for now. To get it working we need to implement "parametrized extensions".

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

No branches or pull requests

3 participants