| 1 |
// Copyright 2019 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 |
|
| 5 |
package main |
| 6 |
|
| 7 |
import "./embed0" |
| 8 |
|
| 9 |
type X1 struct{} |
| 10 |
|
| 11 |
func (X1) Foo() {} |
| 12 |
|
| 13 |
type X2 struct{} |
| 14 |
|
| 15 |
func (X2) foo() {} |
| 16 |
|
| 17 |
type X3 struct{} |
| 18 |
|
| 19 |
func (X3) foo(int) {} |
| 20 |
|
| 21 |
type X4 struct{ p.M1 } |
| 22 |
|
| 23 |
type X5 struct{ p.M1 } |
| 24 |
|
| 25 |
func (X5) foo(int) {} |
| 26 |
|
| 27 |
type X6 struct{ p.M2 } |
| 28 |
|
| 29 |
type X7 struct{ p.M2 } |
| 30 |
|
| 31 |
func (X7) foo() {} |
| 32 |
|
| 33 |
type X8 struct{ p.M2 } |
| 34 |
|
| 35 |
func (X8) foo(int) {} |
| 36 |
|
| 37 |
func main() { |
| 38 |
var i1 interface{} = X1{} |
| 39 |
check(func() { _ = i1.(p.I1) }, "interface conversion: main.X1 is not p.I1: missing method Foo") |
| 40 |
|
| 41 |
var i2 interface{} = X2{} |
| 42 |
check(func() { _ = i2.(p.I2) }, "interface conversion: main.X2 is not p.I2: missing method foo") |
| 43 |
|
| 44 |
var i3 interface{} = X3{} |
| 45 |
check(func() { _ = i3.(p.I2) }, "interface conversion: main.X3 is not p.I2: missing method foo") |
| 46 |
|
| 47 |
var i4 interface{} = X4{} |
| 48 |
check(func() { _ = i4.(p.I2) }, "interface conversion: main.X4 is not p.I2: missing method foo") |
| 49 |
|
| 50 |
var i5 interface{} = X5{} |
| 51 |
check(func() { _ = i5.(p.I2) }, "interface conversion: main.X5 is not p.I2: missing method foo") |
| 52 |
|
| 53 |
var i6 interface{} = X6{} |
| 54 |
check(func() { _ = i6.(p.I2) }, "") |
| 55 |
|
| 56 |
var i7 interface{} = X7{} |
| 57 |
check(func() { _ = i7.(p.I2) }, "") |
| 58 |
|
| 59 |
var i8 interface{} = X8{} |
| 60 |
check(func() { _ = i8.(p.I2) }, "") |
| 61 |
} |
| 62 |
|
| 63 |
func check(f func(), msg string) { |
| 64 |
defer func() { |
| 65 |
v := recover() |
| 66 |
if v == nil { |
| 67 |
if msg == "" { |
| 68 |
return |
| 69 |
} |
| 70 |
panic("did not panic") |
| 71 |
} |
| 72 |
got := v.(error).Error() |
| 73 |
if msg != got { |
| 74 |
panic("want '" + msg + "', got '" + got + "'") |
| 75 |
} |
| 76 |
}() |
| 77 |
f() |
| 78 |
} |