1// run
2
3// Copyright 2016 The Go Authors. All rights reserved.
4// Use of this source code is governed by a BSD-style
5// license that can be found in the LICENSE file.
6
7package main
8
9var fail bool
10
11type Closer interface {
12	Close()
13}
14
15func nilInterfaceDeferCall() {
16	var x Closer
17	defer x.Close()
18	// if it panics when evaluating x.Close, it should not reach here
19	fail = true
20}
21
22func shouldPanic(f func()) {
23	defer func() {
24		if recover() == nil {
25			panic("did not panic")
26		}
27	}()
28	f()
29}
30
31func main() {
32	shouldPanic(nilInterfaceDeferCall)
33	if fail {
34		panic("fail")
35	}
36}
37