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 main
6
7import "./a"
8
9func main() {
10	// Test that inlined type switches without short variable
11	// declarations work correctly.
12	check(0, a.F(nil)) // ERROR "inlining call to a.F"
13	check(1, a.F(0))   // ERROR "inlining call to a.F" "does not escape"
14	check(2, a.F(0.0)) // ERROR "inlining call to a.F" "does not escape"
15	check(3, a.F(""))  // ERROR "inlining call to a.F" "does not escape"
16
17	// Test that inlined type switches with short variable
18	// declarations work correctly.
19	_ = a.G(nil).(*interface{})                       // ERROR "inlining call to a.G"
20	_ = a.G(1).(*int)                                 // ERROR "inlining call to a.G" "does not escape"
21	_ = a.G(2.0).(*float64)                           // ERROR "inlining call to a.G" "does not escape"
22	_ = (*a.G("").(*interface{})).(string)            // ERROR "inlining call to a.G" "does not escape"
23	_ = (*a.G(([]byte)(nil)).(*interface{})).([]byte) // ERROR "inlining call to a.G" "does not escape"
24	_ = (*a.G(true).(*interface{})).(bool)            // ERROR "inlining call to a.G" "does not escape"
25}
26
27//go:noinline
28func check(want, got int) {
29	if want != got {
30		println("want", want, "but got", got)
31	}
32}
33