2009-08-07 15:00:18 -06:00
|
|
|
// $G $D/$F.go && $L $F.$A && ./$A.out
|
|
|
|
|
|
|
|
// Copyright 2009 The Go Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import "fmt"
|
|
|
|
|
|
|
|
type Buffer int
|
|
|
|
|
2010-03-24 17:46:53 -06:00
|
|
|
func (*Buffer) Read() {}
|
2009-08-07 15:00:18 -06:00
|
|
|
|
2010-03-24 17:46:53 -06:00
|
|
|
type Reader interface {
|
|
|
|
Read()
|
2009-08-07 15:00:18 -06:00
|
|
|
}
|
|
|
|
|
2010-03-24 17:46:53 -06:00
|
|
|
func f() *Buffer { return nil }
|
|
|
|
|
2009-08-07 15:00:18 -06:00
|
|
|
func g() Reader {
|
|
|
|
// implicit interface conversion in assignment during return
|
|
|
|
return f()
|
|
|
|
}
|
|
|
|
|
2010-03-24 17:46:53 -06:00
|
|
|
func h() (b *Buffer, ok bool) { return }
|
2009-08-07 15:00:18 -06:00
|
|
|
|
|
|
|
func i() (r Reader, ok bool) {
|
|
|
|
// implicit interface conversion in multi-assignment during return
|
2010-03-24 17:46:53 -06:00
|
|
|
return h()
|
2009-08-07 15:00:18 -06:00
|
|
|
}
|
|
|
|
|
2010-03-24 17:46:53 -06:00
|
|
|
func fmter() (s string, i int, t string) { return "%#x %q", 100, "hello" }
|
2009-08-07 15:00:18 -06:00
|
|
|
|
|
|
|
func main() {
|
2010-03-24 17:46:53 -06:00
|
|
|
b := g()
|
|
|
|
bb, ok := b.(*Buffer)
|
|
|
|
_, _, _ = b, bb, ok
|
2009-08-07 15:00:18 -06:00
|
|
|
|
2010-03-24 17:46:53 -06:00
|
|
|
b, ok = i()
|
|
|
|
bb, ok = b.(*Buffer)
|
|
|
|
_, _, _ = b, bb, ok
|
2009-08-07 15:00:18 -06:00
|
|
|
|
2010-03-24 17:46:53 -06:00
|
|
|
s := fmt.Sprintf(fmter())
|
2009-08-07 15:00:18 -06:00
|
|
|
if s != "0x64 \"hello\"" {
|
2010-03-24 17:46:53 -06:00
|
|
|
println(s)
|
|
|
|
panic("fail")
|
2009-08-07 15:00:18 -06:00
|
|
|
}
|
|
|
|
}
|