summaryrefslogtreecommitdiffstats
path: root/llgo/test/execution/interfaces/i2i_conversion.go
blob: b55d8404a12647b8fad98d936cc62b94a74e945c (plain)
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
// RUN: llgo -o %t %s
// RUN: %t 2>&1 | FileCheck %s

// CHECK: 666
// CHECK-NEXT: The Beast

package main

type Numbered interface {
	Number() int
}

type Named interface {
	Name() string
}

type Beast struct{}

func (b *Beast) Number() int {
	return 666
}

func (b *Beast) Name() string {
	return "The Beast"
}

func main() {
	var b Beast
	var numbered Numbered = &b
	var named Named = numbered.(Named)
	println(numbered.Number())
	println(named.Name())
}
OpenPOWER on IntegriCloud