[swift-evolution] Problems with generics - should be fixed for Xcode 9?

Félix Cloutier felixcloutier at icloud.com
Sun Sep 17 16:58:59 CDT 2017


I always thought that this was a bug, but I can't find it on bugs.swift.org, so I'd love to know if it's meant to stay this way or not.

> Le 16 sept. 2017 à 06:32, Joanna Carter via swift-evolution <swift-evolution at swift.org> a écrit :
> 
> Greetings
> 
> Old chestnut, sort of partially solved but still problems.
> 
> Now we can nest types in generic types, what I want is :
> 
> class Event<typeT>
> {
>  class Args
>  {
>    public static let empty = Args() // error : Static stored properties not supported in generic types
>  }
> }
> 
> But the static let is not directly in the generic class.
> 
> So, I end up doing another convoluted workaround in the shape of :
> 
> class Event<typeT>
> {
>  class Args
>  {
>    public static var empty: Args
>    {
>      return Args()
>    }
>  }
> }
> 
> The main difference is that I have to create a new instance on every call to Args.empty instead of returning the same one.
> 
> Is this an oversight or as intended, with the hope of fixing it in a future version
> 
> Joanna
> 
> --
> Joanna Carter
> Carter Consulting
> 
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution



More information about the swift-evolution mailing list