Compiler Error when instantiating an empty array of a nested class using initialiser syntax
| Originator: | gothick.fysh | ||
| Number: | rdar://18243054 | Date Originated: | 5 Sep 2014 |
| Status: | Closed | Resolved: | |
| Product: | Xcode/Swift compiler | Product Version: | Xcode 6 beta 7 |
| Classification: | Reproducible: | Yes |
Closed as duplicate of: 18305718
Summary:
If I try to declare an empty array of objects of a class that's declared within another class like this:
var foo = [OutsideClass.NestedClass]()
I get the compiler error "Invalid use of '()' to call a value of non-function type"
Steps to Reproduce:
Attempt to instantiate an empty array using initialiser syntax (i.e. [foo]()) of a class that's declared "nested" inside another class:
class OutsideClass {
class InsideClass {
}
}
var bar = [OutsideClass.InsideClass]() // Error
Expected Results:
I believe this syntax should be valid, and so:
var bar = [OutsideClass.InsideClass]()
...should produce the same result as it would with a non-nested class, e.g. be equivalent to:
var bar:[OutsideClass.InsideClass] = []
Actual Results:
Compiler error: "Invalid use of '()' to call a value of non-function type '[OutsideClass.InsideClass.Type]'"
Version:
Xcode 6 beta 7 (6A280n) / OS X 10.9.5 (13F24)
Notes:
Configuration:
Attachments:
'NestedClass.playground.zip' was successfully uploaded.
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!