Revision 42e827e6e7247224c068a9dce8f6eabd2ab892ba authored by Devin Coughlin on 21 January 2016, 00:12:56 UTC, committed by Devin Coughlin on 21 January 2016, 01:22:15 UTC
This reverts commit f6dd24bb68b35292c3663c92c74508e97f247e53.
1 parent ac1f5a6
objc_override.swift
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -emit-sil -I %S/Inputs/custom-modules %s -verify
// REQUIRES: objc_interop
import Foundation
import ObjCParseExtras
class MyArray : DummyClass {
func setBoolProperty(x: Bool) { } // expected-error{{method 'setBoolProperty' with Objective-C selector 'setBoolProperty:' conflicts with setter for 'boolProperty' from superclass 'DummyClass' with the same Objective-C selector}}
@objc(objectAtIndexedSubscript:)
func getObjectAt(i: Int) { } // expected-error{{method 'getObjectAt' with Objective-C selector 'objectAtIndexedSubscript:' conflicts with method 'objectAtIndexedSubscript' from superclass 'DummyClass' with the same Objective-C selector}}
}
class SomeCellSub1 : SomeCell {
init(string: String) { super.init(string: string) } // expected-error{{overriding declaration requires an 'override' keyword}}{{3-3=override }}
// okay: should not conflict
func initWithString(string: String) { }
var enabled: Bool { // expected-error{{overriding declaration requires an 'override' keyword}}
get { return super.enabled }
}
@objc(enabled)
func otherIsEnabled() { } // should not conflict
}
class SomeCellSub2 : SomeCell {
override init(string: String) { super.init(string: string) }
// okay: should not conflict
func initWithString(string: String) { }
override var enabled: Bool {
get { return super.enabled }
}
@objc(enabled)
func otherIsEnabled() { } // should not conflict
}
class SomeCellSub3 : SomeCell {
@objc(initString:)
override init(string: String) { super.init(string: string) }
// okay: should not conflict
func initWithString(string: String) { }
override var enabled: Bool {
@objc(isEnabled) get { return super.enabled }
}
@objc(enabled)
func otherIsEnabled() { } // should not conflict
}
class SomeCellSub4 : SomeCell {
@objc
override init(string: String) { super.init(string: string) }
// okay: should not conflict
func initWithString(string: String) { }
override var enabled: Bool {
@objc get { return super.enabled }
}
@objc(enabled)
func otherIsEnabled() { } // should not conflict
}
class SomeCellSub5 : SomeCell {
@objc(initWithString:) // expected-error{{Objective-C method has a different selector from the method it overrides ('initWithString:' vs. 'initString:')}}{{9-24=initString:}}
override init(string: String) { super.init(string: string) }
override var enabled: Bool {
@objc(wasEnabled) get { return super.enabled }
// expected-error@-1{{Objective-C method has a different selector from the method it overrides ('wasEnabled' vs. 'isEnabled')}}{{11-21=isEnabled}}
}
@objc(enabled)
func otherIsEnabled() { } // should not conflict
}
class FailSub : FailBase {
override init(value: Int) { try! super.init(value: value) } // expected-error {{overriding a throwing @objc initializer with a non-throwing initializer is not supported}}
override class func processValue() {} // expected-error {{overriding a throwing @objc method with a non-throwing method is not supported}}
}
Computing file changes ...