Giant blob of minor changes
[dotfiles/.git] / .config / coc / extensions / coc-go-data / tools / pkg / mod / golang.org / x / tools@v0.0.0-20201028153306-37f0764111ff / go / analysis / passes / ifaceassert / testdata / src / a / a.go
1 // Copyright 2020 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 // This file contains tests for the ifaceassert checker.
6
7 package a
8
9 import "io"
10
11 func InterfaceAssertionTest() {
12         var (
13                 a io.ReadWriteSeeker
14                 b interface {
15                         Read()
16                         Write()
17                 }
18         )
19         _ = a.(io.Reader)
20         _ = a.(io.ReadWriter)
21         _ = b.(io.Reader)  // want `^impossible type assertion: no type can implement both interface{Read\(\); Write\(\)} and io.Reader \(conflicting types for Read method\)$`
22         _ = b.(interface { // want `^impossible type assertion: no type can implement both interface{Read\(\); Write\(\)} and interface{Read\(p \[\]byte\) \(n int, err error\)} \(conflicting types for Read method\)$`
23                 Read(p []byte) (n int, err error)
24         })
25
26         switch a.(type) {
27         case io.ReadWriter:
28         case interface { // want `^impossible type assertion: no type can implement both io.ReadWriteSeeker and interface{Write\(\)} \(conflicting types for Write method\)$`
29                 Write()
30         }:
31         default:
32         }
33
34         switch b := b.(type) {
35         case io.ReadWriter, interface{ Read() }: // want `^impossible type assertion: no type can implement both interface{Read\(\); Write\(\)} and io.ReadWriter \(conflicting types for Read method\)$`
36         case io.Writer: // want `^impossible type assertion: no type can implement both interface{Read\(\); Write\(\)} and io.Writer \(conflicting types for Write method\)$`
37         default:
38                 _ = b
39         }
40 }