1// errorcheck -0 -d=ssa/opt/debug=1
2
3package main
4
5// Trivial interface call devirtualization test.
6
7type real struct {
8	value int
9}
10
11func (r *real) Value() int { return r.value }
12
13type Valuer interface {
14	Value() int
15}
16
17type indirectiface struct {
18	a, b, c int
19}
20
21func (i indirectiface) Value() int {
22	return i.a + i.b + i.c
23}
24
25func main() {
26	var r Valuer
27	rptr := &real{value: 3}
28	r = rptr
29
30	if r.Value() != 3 { // ERROR "de-virtualizing call$"
31		panic("not 3")
32	}
33
34	r = indirectiface{3, 4, 5}
35	if r.Value() != 12 { // ERROR "de-virtualizing call$"
36		panic("not 12")
37	}
38}
39