Files
swift-mirror/test/Interpreter/recursive_generics.swift
John McCall c1b03784df Instead of passing type metadata to swift_initClassMetadata,
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
2014-08-28 01:27:53 +00:00

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