|
15 | 15 | // ===----------------------------------------------------------------------===//
|
16 | 16 | module Classes
|
17 | 17 |
|
18 |
| -animals: Listing<Animal> = new { |
19 |
| - new { name = "Uni" } |
20 |
| - new { name = "Wally" } |
21 |
| - new { name = "Mouse" } |
| 18 | +bug: Bug |
| 19 | + |
| 20 | +蚊子: Bug |
| 21 | + |
| 22 | +thisPerson: ThisPerson |
| 23 | + |
| 24 | +d: D |
| 25 | + |
| 26 | +hidden myHiddenProp: String |
| 27 | + |
| 28 | +class Wheel { |
| 29 | + hasSpokes: Boolean |
| 30 | +} |
| 31 | + |
| 32 | +class Bike { |
| 33 | + isFixie: Boolean |
| 34 | + |
| 35 | + /// Wheels are the front and back wheels. |
| 36 | + /// |
| 37 | + /// There are typically two of them. |
| 38 | + wheels: List<Wheel> |
| 39 | +} |
| 40 | + |
| 41 | +abstract class Being { |
| 42 | + isAlive: Boolean |
| 43 | +} |
| 44 | + |
| 45 | +/// A Person! |
| 46 | +open class Person extends Being { |
| 47 | + isAlive = true |
| 48 | + |
| 49 | + bike: Bike |
| 50 | + |
| 51 | + /// The person's first name |
| 52 | + firstName: UInt16? |
| 53 | + |
| 54 | + /// The person's last name |
| 55 | + lastName: Mapping<String, UInt32?> |
| 56 | + |
| 57 | + things: Set<Int> |
| 58 | +} |
| 59 | + |
| 60 | +class ThisPerson extends Person { |
| 61 | + myself: ThisPerson |
| 62 | + someoneElse: Person |
| 63 | +} |
| 64 | + |
| 65 | +typealias BugKind = "butterfly"|"beetle\""|"beetle one" |
| 66 | + |
| 67 | +// `nothing` is allowed as a string literal |
| 68 | +typealias BugKindTwo = nothing|"butterfly"|"beetle\""|"beetle one" |
| 69 | + |
| 70 | +// should turn into just a string type because of a conflict; "bettle one" and "bettle_one" would |
| 71 | +// turn into the same Swift identifier. |
| 72 | +typealias BugKindThree = "butterfly"|"beetle\""|"beetle one"|"beetle_one" |
| 73 | + |
| 74 | +// should also turn into just a string type because there no way to generate valid swift symols; "*" and "!!" would |
| 75 | +// turn into invalid Swift symbols. |
| 76 | +typealias BugKindFour = "*"|"!!" |
| 77 | + |
| 78 | +class Bug { |
| 79 | + /// The owner of this bug. |
| 80 | + owner: Person? |
| 81 | + |
| 82 | + /// The age of this bug |
| 83 | + age: Int? |
| 84 | + |
| 85 | + /// How long the bug holds its breath for |
| 86 | + holdsBreathFor: Duration |
| 87 | + |
| 88 | + size: DataSize |
| 89 | + |
| 90 | + kind: BugKind |
| 91 | + |
| 92 | + kind2: BugKindTwo |
| 93 | + |
| 94 | + kind3: BugKindThree |
| 95 | + |
| 96 | + kind4: BugKindFour |
| 97 | + |
| 98 | + bagOfStuff: Dynamic |
| 99 | + |
| 100 | + bugClass: Class |
| 101 | + |
| 102 | + bugTypeAlias: TypeAlias |
| 103 | +} |
| 104 | + |
| 105 | +abstract class A { |
| 106 | + a: "a" |
| 107 | +} |
| 108 | + |
| 109 | +open class B extends A { |
| 110 | + b: "b" |
| 111 | +} |
| 112 | + |
| 113 | +open class C extends B { |
| 114 | + c: "c" |
22 | 115 | }
|
23 | 116 |
|
24 |
| -open class Animal { |
25 |
| - name: String |
| 117 | +class D extends C { |
| 118 | + d: "d" |
26 | 119 | }
|
0 commit comments