Files
swift-mirror/test/Serialization/Inputs/def_class.swift
Jordan Rose 9a67bc597e [serialization] Add support for classes.
Classes are exactly like structs except that they may have a base class.
However, this type will show up in the inheritance list. That means we
don't actually need to serialize it twice; we can just grab the base class
from the inheritance list.

Swift SVN r6133
2013-07-10 23:25:34 +00:00

74 lines
1006 B
Swift

class Empty {}
class TwoInts {
var x, y : Int
constructor(a : Int, b : Int) {
x = a
y = b
}
}
class ComputedProperty {
var value : Int {
get:
var result : Int
return result
}
}
// Generics
class Pair<A, B> {
var first : A
var second : B
constructor(a : A, b : B) {
first = a
second = b
}
}
class GenericCtor<U> {
constructor<T>(t : T) {}
func doSomething<T>(t : T) {}
}
// Protocols
protocol Resettable {
func reset()
}
class ResettableIntWrapper : Resettable {
var value : Int
func reset() {
var zero : Int
value = zero
}
}
protocol Computable {
func compute()
}
typealias Cacheable = protocol<Resettable, Computable>
protocol SpecialResettable : Resettable, Computable {}
// Inheritance
class StillEmpty : Empty, Resettable {
func reset() {}
}
class BoolPair : Pair<Bool, Bool> {
func bothTrue() -> Bool {
return first && second
}
}
class SpecialPair<A> : Computable, Pair<Int, Int> {
func compute() {}
}