1// run 2 3// Copyright 2013 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 9import "runtime" 10 11type Closer interface { 12 Close() 13} 14 15func nilInterfaceDeferCall() { 16 defer func() { 17 // make sure a traceback happens with jmpdefer on the stack 18 runtime.GC() 19 }() 20 var x Closer 21 defer x.Close() 22} 23 24func shouldPanic(f func()) { 25 defer func() { 26 if recover() == nil { 27 panic("did not panic") 28 } 29 }() 30 f() 31} 32 33func main() { 34 shouldPanic(nilInterfaceDeferCall) 35} 36