mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
pass the size and alignment of each field. Take advantage of this to pass a constant size and alignment when possible. This avoids the need to recursively find type metadata for every field type, allowing generic recursively-structured classes to be built. There are a number of more complicated cases that this approach isn't good enough for, but this is good enough for now to fix rdar://18067671. Also make an effort to properly support generic subclasses of Objective-C classes. Swift SVN r21506
31 lines
538 B
Swift
31 lines
538 B
Swift
// RUN: %target-run-simple-swift | FileCheck %s
|
|
|
|
// rdar://18067671
|
|
class List<T> {
|
|
var value: T
|
|
var next: List<T>?
|
|
|
|
init(value: T) {
|
|
self.value = value
|
|
}
|
|
init(value: T, next: List<T>) {
|
|
self.value = value
|
|
self.next = next
|
|
}
|
|
}
|
|
|
|
let a = List(value: 0.0)
|
|
let b = List(value: 1.0, next: a)
|
|
let c = List(value: 2.0, next: b)
|
|
b.value = 4.0
|
|
a.value = 8.0
|
|
|
|
println("begin")
|
|
println(c.value)
|
|
println(c.next!.value)
|
|
println(c.next!.next!.value)
|
|
// CHECK: begin
|
|
// CHECK-NEXT: 2.0
|
|
// CHECK-NEXT: 4.0
|
|
// CHECK-NEXT: 8.0
|