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// Test that basic operations on named types are valid
8// and preserve the type.
9// Does not compile.
10
11package main
12
13type Bool bool
14
15type Map map[int]int
16
17func (Map) M() {}
18
19type Slice []byte
20
21var slice Slice
22
23func asBool(Bool)     {}
24func asString(String) {}
25
26type String string
27
28func main() {
29	var (
30		b    Bool = true
31		i, j int
32		c    = make(chan int)
33		m    = make(Map)
34	)
35
36	asBool(b)
37	asBool(!b)
38	asBool(true)
39	asBool(*&b)
40	asBool(Bool(true))
41	asBool(1 != 2) // ok now
42	asBool(i < j)  // ok now
43
44	_, b = m[2]
45
46	var inter interface{}
47	_, b = inter.(Map)
48	_ = b
49
50	var minter interface {
51		M()
52	}
53	_, b = minter.(Map)
54	_ = b
55
56	_, bb := <-c
57	asBool(bb) // ERROR "cannot use.*type bool.*as type Bool"
58	_, b = <-c
59	_ = b
60
61	asString(String(slice)) // ok
62}
63