]> Cypherpunks repositories - gostls13.git/commitdiff
test: add inherited interface test to ddd.go
authorIan Lance Taylor <iant@golang.org>
Wed, 7 Mar 2012 16:24:10 +0000 (08:24 -0800)
committerIan Lance Taylor <iant@golang.org>
Wed, 7 Mar 2012 16:24:10 +0000 (08:24 -0800)
The gccgo compiler incorrectly gave an error for this code.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5767043

test/ddd.go

index f35836331b21d7bf0b7e1edd50831e9fe4326dea..3b595b5f8dafb6e81dff049b3ba98f55e482eccc 100644 (file)
@@ -60,6 +60,10 @@ type U struct {
        *T
 }
 
+type I interface {
+       Sum(...int) int
+}
+
 func main() {
        if x := sum(1, 2, 3); x != 6 {
                println("sum 6", x)
@@ -207,6 +211,14 @@ func main() {
                println("i(=u).Sum", x)
                panic("fail")
        }
+       var s struct {
+               I
+       }
+       s.I = &u
+       if x := s.Sum(2, 3, 5, 8); x != 18 {
+               println("s{&u}.Sum", x)
+               panic("fail")
+       }
        /* TODO(rsc): Enable once nested method expressions work.
        if x := (*U).Sum(&U{}, 1, 3, 5, 2); x != 11 {
                println("(*U).Sum", x)