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-6940] Type checker bug with corelib's testCase overloads #49488

Closed
ankitspd opened this issue Feb 7, 2018 · 6 comments
Closed

[SR-6940] Type checker bug with corelib's testCase overloads #49488

ankitspd opened this issue Feb 7, 2018 · 6 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

@ankitspd
Copy link
Member

ankitspd commented Feb 7, 2018

Previous ID SR-6940
Radar rdar://problem/37303482
Original Reporter @aciidb0mb3r
Type Bug
Status Resolved
Resolution Done
Environment

swift-DEVELOPMENT-SNAPSHOT-2018-02-06-a-ubuntu16.04

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

md5: e0a5230b305f3d30c7d4742a8f313b01

Issue Description:

import XCTest

class Foo: XCTestCase {
    func testFoo() {
    }

    static let allTests = [
        ("testFoo", testFoo),
    ]
}

class Bar: XCTestCase {
    func testBar() throws {
    }

    static let allTests = [
        ("testBar", testBar),
    ]
}

var tests = [XCTestCaseEntry]()

#if Bug 
tests.append(testCase([ ("testFoo", Foo.testFoo) ]))
tests.append(testCase([ ("testBar", Bar.testBar) ]))
#else
tests.append(testCase(Foo.allTests))
tests.append(testCase(Bar.allTests))
#endif
$ swift main.swift # Works!
$ swift -DBug main.swift
main.swift:25:14: error: cannot invoke 'testCase' with an argument list of type '([(String, (Bar) -> () throws -> ())])'
tests.append(testCase([ ("testBar", Bar.testBar) ]))
^
main.swift:25:14: note: overloads for 'testCase' exist with these partially matching parameter lists: ([(String, (T) -> () throws -> Void)]), ([(String, (T) -> () -> Void)])
tests.append(testCase([ ("testBar", Bar.testBar) ]))
^
@ankitspd
Copy link
Member Author

ankitspd commented Feb 7, 2018

@swift-ci create

@rudkx
Copy link
Member

rudkx commented Feb 7, 2018

Ankit, is this a regression in Swift 4.1, or just something you noticed wasn't working as expected?

@ankitspd
Copy link
Member Author

ankitspd commented Feb 7, 2018

Just something I noticed, I don't know if this is a regression.

@xedin
Copy link
Member

xedin commented Mar 29, 2018

@aciidb0mb3r Is this only reproducible on Linux?

@xedin
Copy link
Member

xedin commented Mar 29, 2018

Here is the reduced test-case which fails on 4.1 branch but works fine on master:

class P {}
class A : P {
  func foo() throws {}
}

class B : P {
  func foo() throws {}
}

typealias C = (P) throws -> Void
typealias E = (c: P.Type, arr: [(String, C)])

func foo<T: P>(_: [(String, (T) -> () throws -> Void)]) -> E { fatalError() }
func foo<T: P>(_: [(String, (T) -> () -> Void)]) -> E { fatalError() }

var arr = [E]()
arr.append(foo([("a", A.foo)]))
arr.append(foo([("b", B.foo)]))

I think got fixed by one of my changes type variable binding inference, will try more tomorrow.

@xedin
Copy link
Member

xedin commented Mar 29, 2018

I'm going to add test case for this via #15603 since it has been fixed on master. @aciidb0mb3r please verify and resolve.

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

No branches or pull requests

3 participants