2013-08-07 15:03:50 -06:00
|
|
|
// run
|
|
|
|
|
|
|
|
// Copyright 2013 The Go Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
2013-08-09 16:27:45 -06:00
|
|
|
import "runtime"
|
|
|
|
|
2013-08-07 15:03:50 -06:00
|
|
|
type Closer interface {
|
|
|
|
Close()
|
|
|
|
}
|
|
|
|
|
|
|
|
func nilInterfaceDeferCall() {
|
2013-08-09 16:27:45 -06:00
|
|
|
defer func() {
|
|
|
|
// make sure a traceback happens with jmpdefer on the stack
|
|
|
|
runtime.GC()
|
|
|
|
}()
|
2013-08-07 15:03:50 -06:00
|
|
|
var x Closer
|
|
|
|
defer x.Close()
|
|
|
|
}
|
|
|
|
|
|
|
|
func shouldPanic(f func()) {
|
|
|
|
defer func() {
|
|
|
|
if recover() == nil {
|
|
|
|
panic("did not panic")
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
f()
|
|
|
|
}
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
shouldPanic(nilInterfaceDeferCall)
|
|
|
|
}
|