Debian Codegraph @

_test/switch19.go

raw symbols SCIP
1 package main
2
3 import "fmt"
4
5 type fii interface {
6 Hello()
7 }
8
9 type Bir struct{}
10
11 func (b Bir) Yo() {
12 fmt.Println("Yo", b)
13 }
14
15 func (b Bir) Hello() {
16 fmt.Println("Hello", b)
17 }
18
19 type Boo struct {
20 Name string
21 }
22
23 func (b Boo) Hello() {
24 fmt.Println("Hello", b)
25 fmt.Println(b.Name)
26 }
27
28 type Bar struct{}
29
30 func (b Bar) Hello() { fmt.Println("b:", b) }
31
32 func inCall(foo fii) {
33 fmt.Println("inCall")
34 switch a := foo.(type) {
35 case Boo, Bir:
36 a.Hello()
37 case Bir:
38 a.Yo()
39 default:
40 fmt.Println("a:", a)
41 }
42 }
43
44 func main() {
45 boo := Bir{}
46 inCall(boo)
47 inCall(Bar{})
48 }
49
50 // Error:
51 // 37:2: duplicate case Bir in type switch