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-3532] Can't access metatype of an array of nested types using square-bracket syntactic sugar #46120

Closed
swift-ci opened this issue Jan 3, 2017 · 0 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself parser Area → compiler: The legacy C++ parser

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented Jan 3, 2017

Previous ID SR-3532
Radar None
Original Reporter philippe (JIRA User)
Type Bug
Status Resolved
Resolution Duplicate
Environment

Apple Swift version 3.0.2 (swiftlang-800.0.63 clang-800.0.42.1)

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, Parser
Assignee None
Priority Medium

md5: da00fcd99d2bb587f7729bf7294b6de2

duplicates:

  • SR-349 Cannot use nested enums in definition of arrays or as dictionary

Issue Description:

If you declare a struct, enum or class inside another struct, enum or class, it is not possible to refer to the metatype of an array type containing it using square bracket array literals. So [SomeClass.SomeEnum].type doesn't work, and one must instead use Array<SomeClass.SomeEnum>.type

Examples

Let's set up some types and a generic function that takes a metatype as a parameter.

func decode<T>(type: [T].Type) {
    print("decode [T]")
}

class OuterClass{
    enum InnerEnum {
        case Food
        case Bard
    }
}
Example 1

The first example shows that the compiler parsed the parameter to the function completely wrong:

@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 parser Area → compiler: The legacy C++ parser
Projects
None yet
Development

No branches or pull requests

1 participant