1// Copyright 2020 The Go Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE file.
4
5package a
6
7type I interface{ M() }
8type T int
9
10func (T) M() {} // ERROR "can inline T.M"
11
12func E() I { // ERROR "can inline E"
13	return T(0) // ERROR "T\(0\) escapes to heap"
14}
15
16func F(i I) I { // ERROR "can inline F" "leaking param: i to result ~r0 level=0"
17	i = nil
18	return i
19}
20
21func g() {
22	h := E() // ERROR "inlining call to E" "T\(0\) does not escape"
23	h.M()    // ERROR "devirtualizing h.M to T" "inlining call to T.M"
24
25	// BAD: T(0) could be stack allocated.
26	i := F(T(0)) // ERROR "inlining call to F" "T\(0\) escapes to heap"
27
28	// Testing that we do NOT devirtualize here:
29	i.M()
30}
31