You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SR-2428 Cannot use the short Array constructor syntax when creating an Array of a nested Struct
SR-3532 Can't access metatype of an array of nested types using square-bracket syntactic sugar
SR-4300 Getting error when declare empty array of nested struct or classes.
Issue Description:
I'm not sure the correct terminology to use here, but I've been playing around with moving my related enumerated types into the types they classify (nested enumerations in classes). When you do this, you need to refer to the enumeration as "ClassName.EnumerationName.Case" which seems to break down when using those in an array or dictionary.
Specifically, this only effects initializing an Array with the shorthand syntax.
//Error: invalid use of '()' to call a value of non-function type '[Card.Suit.Type]'vara = [Card.Suit]()
//Works finevarb = Array<Card.Suit>()
b.append(.Spades)
//also finevarc : [Card.Suit] = Array<Card.Suit>()
FWIW, I ran into this issue as well, but with nested type aliases instead of enums. So it seems that this issue affects the array & dictionary literal sugar syntax for all nested types.
publicstructMyStruct {
publictypealiasMyTypeAlias = String
}
// ERROR: Invalid use of '()' to call a value of non-function type '[MyTypeAlias.Type]' (with fix-it to delete '()')_ = [MyStruct.MyTypeAlias]()
// ERROR: Cannot call value of non-function type '[MyTypeAlias.Type]' (without fix-it)let_: [String] = [MyStruct.MyTypeAlias]()
_ = [] as [MyStruct.MyTypeAlias] // OKlet_: [MyStruct.MyTypeAlias] = [] // OK_ = Array<MyStruct.MyTypeAlias>() // OK_ = [GlobalTypeAlias]() // OK_ = [String]() // OK
I ran into this while accessing the metatype of an array of enums nested in a class, like this: [SomeClass.SomeEnum].type. I wrote some examples in this (now marked duplicate) issue if it helps anyone: SR-3532
Environment
Xcode 7.2, Swift 2.1
Additional Detail from JIRA
md5: 12ab5d036e835351aaf6c2f0e01d2b6d
is duplicated by:
Issue Description:
I'm not sure the correct terminology to use here, but I've been playing around with moving my related enumerated types into the types they classify (nested enumerations in classes). When you do this, you need to refer to the enumeration as "ClassName.EnumerationName.Case" which seems to break down when using those in an array or dictionary.
I've been able to workaround this issue by using a typealias to the enumerated value, but that seems clumsy.
The text was updated successfully, but these errors were encountered: