• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// errorcheck
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// Verify that various erroneous type switches are caught by the compiler.
8// Does not compile.
9
10package main
11
12import "io"
13
14func whatis(x interface{}) string {
15	switch x.(type) {
16	case int:
17		return "int"
18	case int: // ERROR "duplicate"
19		return "int8"
20	case io.Reader:
21		return "Reader1"
22	case io.Reader: // ERROR "duplicate"
23		return "Reader2"
24	case interface {
25		r()
26		w()
27	}:
28		return "rw"
29	case interface {	// ERROR "duplicate"
30		w()
31		r()
32	}:
33		return "wr"
34
35	}
36	return ""
37}
38