public class Empty {} @swift3_migration(renamed="DosInts", message="because I can") public class TwoInts { public var x, y : Int required public init(a : Int, b : Int) { x = a y = b } } public class ComputedProperty { @swift3_migration(renamed="theValue", message="because I can") public var value : Int { get { var result = 0 return result } set(newVal) { // completely ignore it! } } @swift3_migration(message="something else") public var readOnly : Int { return 42 } public init() {} } // Generics public class Pair { public var first : A public var second : B public init(a : A, b : B) { first = a second = b } } public class GenericCtor { public init(_ t : T) {} public func doSomething(t : T) {} } // Protocols public protocol Resettable { func reset() } public extension Resettable { final func doReset() { self.reset() } } public class ResettableIntWrapper : Resettable { public var value : Int public init() { value = 0 } public func reset() { var zero = 0 value = zero } } public protocol Computable { func compute() } public typealias Cacheable = protocol public protocol SpecialResettable : Resettable, Computable {} public protocol PairLike { typealias FirstType typealias SecondType func getFirst() -> FirstType func getSecond() -> SecondType } public extension PairLike where FirstType : Cacheable { final func cacheFirst() { } } public protocol ClassProto : class {} @objc public protocol ObjCProtoWithOptional { optional func optionalMethod() optional var optionalVar: Int { get } optional subscript (i: Int) -> Int { get } } public class OptionalImplementer : ObjCProtoWithOptional { public func unrelated() {} public init() {} } // Inheritance public class StillEmpty : Empty, Resettable { public func reset() {} public override init() {} } public class BoolPair : Pair, PairLike { public init() { super.init(a: false, b: false) } public func bothTrue() -> Bool { return first && second } public func getFirst() -> Bool { return first } public func getSecond() -> Bool { return second } } public class SpecialPair : Pair, Computable { public func compute() {} } public class OtherPair : PairLike { public var first : A public var second : B public init(a : A, b : B) { first = a second = b } public typealias FirstType = Bool public typealias SecondType = Bool public func getFirst() -> Bool { return true } public func getSecond() -> Bool { return true } } public class OtherBoolPair : OtherPair { } public class RequiresPairLike

{ } public func getReqPairLike() -> RequiresPairLike> { return RequiresPairLike>() } // Subscripts public class ReadonlySimpleSubscript { public subscript(x : Int) -> Bool { return true } public init() {} } public class ComplexSubscript { public subscript(x : Int, y : Bool) -> Int { set(newValue) { // do nothing! } get { return 0 } } public init() {} } // Destructor public class Resource { public init() { } deinit {} } // Ownership public class ResourceSharer { // FIXME: Cannot perform in-class initialization here public unowned var alwaysPresent : Resource public weak var maybePresent : Resource? public init (res: Resource) { self.alwaysPresent = res self.maybePresent = nil } }