Xcode-Beta (6D520o): Cannot override ObjC subscripts in Swift

Originator:segiddins
Number:rdar://19772357 Date Originated:09-Feb-2015
Status:Open Resolved:
Product:Xcode Product Version:6.3 Beta
Classification: Reproducible:Always
 
Summary:
In Swift 1.1, you could override the subscripting methods in Swift, even if they were declared on an Objective-C superclass. This is no longer possible in Swift 1.2, no matter where the `override` keyword is placed.

Steps to Reproduce:
1) Create Objective-C Class as follows
@interface Model : NSObject
- (id)objectForKeyedSubscript:(NSString *)subscript;
- (void)setObject:(id)object forKeyedSubscript:(NSString *)key;
@end

@implementation Model
- (id)objectForKeyedSubscript:(NSString *)subscript { return nil; }
- (void)setObject:(id)object forKeyedSubscript:(NSString *)key { }
@end

2) Import the above interface in a bridging header

3) Create the following subclass

class ModelSubclass: Model {
    subscript(key: String) -> String {
        get { return "hi" }
        set(value) { println(value) }
    }
}

Expected Results:
The code sample should compile.

Actual Results:
There are two compilation errors, subscript getter overrides Objective-C method 'objectForKeyedSubscript:' from superclass 'Model' and subscript setter overrides Objective-C method 'setObject:forKeyedSubscript:' from superclass 'Model'

Regression:
This is a regression in Xcode 6.3 Beta 1 from Xcode 6.1.1 and Xcode 6.2 Betas, coinciding with Swift 1.2.

Comments

Now I get the error Cannot override mutable subscript of type '(String) -> AnyObject?' with covariant type '(String!) -> AnyObject!'


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!