2012-02-17 04:50:37 +00:00
|
|
|
// run
|
2009-05-07 20:43:00 +00:00
|
|
|
|
|
|
|
// 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.
|
|
|
|
|
2012-02-19 06:33:41 +00:00
|
|
|
// Test methods derived from embedded interface values.
|
2009-05-12 23:09:47 +00:00
|
|
|
|
2009-05-07 20:43:00 +00:00
|
|
|
package main
|
|
|
|
|
2009-05-08 22:21:41 +00:00
|
|
|
import "os"
|
|
|
|
|
2009-05-07 20:43:00 +00:00
|
|
|
const Value = 1e12
|
|
|
|
|
|
|
|
type Inter interface { M() int64 }
|
|
|
|
|
|
|
|
type T int64
|
2009-05-08 22:40:14 +00:00
|
|
|
func (t T) M() int64 { return int64(t) }
|
2009-05-07 20:43:00 +00:00
|
|
|
var t = T(Value)
|
|
|
|
var pt = &t
|
|
|
|
var ti Inter = t
|
|
|
|
|
|
|
|
type S struct { Inter }
|
|
|
|
var s = S{ ti }
|
|
|
|
var ps = &s
|
|
|
|
|
|
|
|
var i Inter
|
|
|
|
|
|
|
|
var ok = true
|
|
|
|
|
2009-10-20 02:27:40 +00:00
|
|
|
func check(s string, v int64) {
|
2009-05-07 20:43:00 +00:00
|
|
|
if v != Value {
|
2010-09-04 00:36:13 +00:00
|
|
|
println(s, v)
|
|
|
|
ok = false
|
2009-05-07 20:43:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func main() {
|
2010-09-04 00:36:13 +00:00
|
|
|
check("t.M()", t.M())
|
|
|
|
check("pt.M()", pt.M())
|
|
|
|
check("ti.M()", ti.M())
|
|
|
|
check("s.M()", s.M())
|
|
|
|
check("ps.M()", ps.M())
|
|
|
|
|
|
|
|
i = t
|
|
|
|
check("i = t; i.M()", i.M())
|
|
|
|
|
|
|
|
i = pt
|
|
|
|
check("i = pt; i.M()", i.M())
|
|
|
|
|
|
|
|
i = s
|
|
|
|
check("i = s; i.M()", i.M())
|
|
|
|
|
|
|
|
i = ps
|
|
|
|
check("i = ps; i.M()", i.M())
|
2009-05-07 20:43:00 +00:00
|
|
|
|
|
|
|
if !ok {
|
2010-09-04 00:36:13 +00:00
|
|
|
println("BUG: interface10")
|
2009-05-08 22:21:41 +00:00
|
|
|
os.Exit(1)
|
2009-05-07 20:43:00 +00:00
|
|
|
}
|
|
|
|
}
|