swift class as parameter without .self

前端 未结 1 1508
挽巷
挽巷 2020-12-12 04:14

I\'ve wrote some functions (Swift 2.1, XCode 7.1.1):

public func test1(type: T.Type) -> T {
    print(type.dynamicType)
    return type.in         


        
相关标签:
1条回答
  • 2020-12-12 05:04

    Coincidentally, this just came up on swift-evolution. The ability to omit .self when the Type is the only argument, has been reported as a bug in Swift.

    The relevant quote from Apple:

    It's a bug. .self is supposed to be required everywhere. Unfortunately, we've had the bug for a while, so I'm not sure how much code we'd break by changing it. If we wanted to remove the requirement, that would be considered a language change and would have to go through the Swift Evolution Process.

    0 讨论(0)
提交回复
热议问题