1// run 2 3// Copyright 2022 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 9type I interface{ M() } 10 11type T struct { 12 x int 13} 14 15func (T) M() {} 16 17var pt *T 18 19func f() (r int) { 20 defer func() { recover() }() 21 22 var i I = pt 23 defer i.M() 24 r = 1 25 return 26} 27 28func main() { 29 if got := f(); got != 1 { 30 panic(got) 31 } 32} 33