Swift: Overload of method taking T -> () misinterpreted as override of @objc superclass method taking (() -> ())!

Originator:rix.rob
Number:rdar://19525294 Date Originated:19-Jan-2015 07:01 PM
Status:Open Resolved:
Product:Developer Tools Product Version:Xcode 6.1.1 (6A2008a)
Classification:Other Bug Reproducible:Always
 
Summary:
I’m trying to overload but Swift thinks I’m trying to override.

My use case: XCTestCase has a method named measureBlock taking (() -> ())!. My XCTestCase subclass has a method named measureBlock taking Int -> () which calls the () -> () one passing in { block(n) } with some n.


Steps to Reproduce:
Write this code:

@objc class A {
	func f(x: () -> ()) {}
}

class B: A {
	func f(x: Int -> ()) {}
}



Expected Results:
I expected this to work.


Actual Results:
Error:

./overload-ride.swift:8:7: error: overriding method with selector 'f:' has incompatible type '(Int -> ()) -> ()'
./overload-ride.swift:4:7: note: overridden declaration here has type '((() -> ())) -> ()'


Regression:
Only occurs if the superclass is @objc; pure Swift classes are fine.


Notes:
Have a lovely day! <3

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!