mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
There's still work left to do. In terms of next steps, there's still rdar://problem/22126141, which covers removing the 'workaround' overloads for print (that prevent bogus overload resolution failures), as well as providing a decent diagnostic when users invoke print with 'appendNewline'. Swift SVN r30976
41 lines
734 B
Swift
41 lines
734 B
Swift
// RUN: %target-run-simple-swift | FileCheck %s
|
|
// REQUIRES: executable_test
|
|
|
|
protocol MyPrintable {
|
|
func print()
|
|
}
|
|
|
|
struct PrintableValue : MyPrintable {
|
|
init(_ value: String) {
|
|
self.value = value
|
|
}
|
|
|
|
func print() {
|
|
Swift.print(value, terminator: "")
|
|
}
|
|
|
|
var value: String
|
|
}
|
|
|
|
class Foo<T : MyPrintable> {
|
|
init<U : MyPrintable>(_ t: T, _ u: U) {
|
|
print("init ", terminator: "")
|
|
t.print()
|
|
print(" ", terminator: "")
|
|
u.print()
|
|
print("")
|
|
}
|
|
|
|
func bar<U : MyPrintable>(u: U) {
|
|
print("bar ", terminator: "")
|
|
u.print()
|
|
print("")
|
|
}
|
|
}
|
|
|
|
// CHECK: init 1 two
|
|
var foo = Foo<PrintableValue>(PrintableValue("1"), PrintableValue("two"))
|
|
// CHECK: bar 3
|
|
var c = PrintableValue("3")
|
|
foo.bar(c)
|