URL
https://opencores.org/ocsvn/openrisc/openrisc/trunk
Subversion Repositories openrisc
[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [go.test/] [test/] [interface/] [receiver.go] - Rev 867
Go to most recent revision | Compare with Previous | Blame | View Log
// $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.// Implicit methods for embedded types.// Mixed pointer and non-pointer receivers.package maintype T intvar nv, np intfunc (t T) V() {if t != 42 {panic(t)}nv++}func (t *T) P() {if *t != 42 {println(t, *t)panic("fail")}np++}type V interface {V()}type P interface {P()V()}type S struct {T}type SP struct {*T}func main() {var t Tvar v Vvar p Pt = 42t.P()t.V()v = tv.V()p = &tp.P()p.V()v = &tv.V()// p = t // ERRORvar i interface{} = tif _, ok := i.(P); ok {println("dynamic i.(P) succeeded incorrectly")panic("fail")}// println("--struct--");var s Ss.T = 42s.P()s.V()v = ss.V()p = &sp.P()p.V()v = &sv.V()// p = s // ERRORvar j interface{} = sif _, ok := j.(P); ok {println("dynamic j.(P) succeeded incorrectly")panic("fail")}// println("--struct pointer--");var sp SPsp.T = &tsp.P()sp.V()v = spsp.V()p = &spp.P()p.V()v = &spv.V()p = sp // not errorp.P()p.V()if nv != 13 || np != 7 {println("bad count", nv, np)panic("fail")}}
Go to most recent revision | Compare with Previous | Blame | View Log
