Skip to content

Any.Type issue with @Test #76637

@Kyle-Ye

Description

@Kyle-Ye

Description

I'm using name2 pattern at first. But then I thought I should refactor to use name1 pattern. But it will give me a strange compiler error.

Is this an expected unsupported feature like swiftlang/swift-testing#202 or a bug here.

struct DemoKitTests {
    @Test(
        arguments: [
            (type: Int.self, nominalName: "Int"),
            (type: String.self, nominalName: "String"),
        ]
    )
    func name1(type: Any.Type, nominalName: String) {
        #expect(API.name(type) == nominalName)
    }

    @Test
    func name2() {
        #expect(API.name(Int.self) == "Int")
        #expect(API.name(String.self) == "String")
    }
}

Expected behavior

Compile and test successfully.

Actual behavior

Compile error on language mode v5. (On v6 it is Any is not conform to Sendable)

xx.swift:17:4 Static method '__function(named:in:xcTestCompatibleSelector:displayName:traits:arguments:sourceLocation:parameters:testFunction:)' requires the types 'Any' and '(any Any.Type, String)' be equivalent

Steps to reproduce

See description field.

Or use the following demokit package

DemoKit.zip

swift-testing version/commit hash

Xcode 16.0.0

Swift & OS version (output of swift --version ; uname -a)

Swift 6 compiler with Swift 5 language mode

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.swift macroFeature → declarations: Swift `macro` declarations

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy