]> Cypherpunks.ru repositories - gostls13.git/blob - test/typeswitch2.go
runtime, type switch: eliminate package global name space assumption
[gostls13.git] / test / typeswitch2.go
1 // errchk $G -e $D/$F.go
2
3 // Copyright 2009 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
7 package main
8
9 import "io"
10
11 func whatis(x interface{}) string {
12         switch x.(type) {
13         case int:
14                 return "int"
15         case int: // ERROR "duplicate"
16                 return "int8"
17         case io.Reader:
18                 return "Reader1"
19         case io.Reader: // ERROR "duplicate"
20                 return "Reader2"
21         case interface { r(); w() }:
22                 return "rw"
23         case interface { w(); r() }:    // ERROR "duplicate"
24                 return "wr"
25         
26         }
27         return ""
28 }