-
Notifications
You must be signed in to change notification settings - Fork 10.4k
/
Copy pathgeneric-classes.swift
37 lines (29 loc) · 1.05 KB
/
generic-classes.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// RUN: %target-run-simple-swift(-enable-experimental-feature Embedded -parse-as-library -runtime-compatibility-version none -wmo -Xfrontend -disable-objc-interop) | %FileCheck %s
// RUN: %target-run-simple-swift(-Osize -enable-experimental-feature Embedded -parse-as-library -runtime-compatibility-version none -wmo -Xfrontend -disable-objc-interop) | %FileCheck %s
// REQUIRES: swift_in_compiler
// REQUIRES: executable_test
// REQUIRES: optimized_stdlib
// REQUIRES: OS=macosx || OS=linux-gnu
protocol Fooable {
func foo()
}
class GenericFooableClass<T>: Fooable {
func foo() { print("GenericFooableClass<T>.foo") }
}
class GenericFooableSubClass<T>: GenericFooableClass<T> {
override func foo() { print("GenericFooableSubClass<T>.foo") }
}
func makeItFoo<F: Fooable>(f: F) {
f.foo()
}
@main
struct Main {
static func main() {
let f = GenericFooableClass<Int>()
makeItFoo(f: f)
let g: GenericFooableClass = GenericFooableSubClass<Int>()
makeItFoo(f: g)
}
}
// CHECK: GenericFooableClass<T>.foo
// CHECK: GenericFooableSubClass<T>.foo