blob: 18f45931c4bba3d165b73f8bb85b6dc503450f78 [file] [log] [blame]
Russ Cox4c0de302010-07-15 16:42:32 -07001// $G $D/$F.go && $L $F.$A && ./$A.out
2
3// Copyright 2010 The Go Authors. All rights reserved.
4// Use of this source code is governed by a BSD-style
5// license that can be found in the LICENSE file.
6
7// http://code.google.com/p/go/issues/detail?id=800
8
9package main
10
11var log string
12
13type T int
14
15func (t T) a(s string) T {
16 log += "a(" + s + ")"
17 return t
18}
19
20func (T) b(s string) string {
21 log += "b"
22 return s
23}
24
25type F func(s string) F
26
27func a(s string) F {
28 log += "a(" + s + ")"
29 return F(a)
30}
31
32func b(s string) string {
33 log += "b"
34 return s
35}
36
37type I interface {
38 a(s string) I
39 b(s string) string
40}
41
42type T1 int
43
44func (t T1) a(s string) I {
45 log += "a(" + s + ")"
46 return t
47}
48
49func (T1) b(s string) string {
50 log += "b"
51 return s
52}
53
54var ok = true
55
56func bad() {
57 if !ok {
58 println("BUG")
59 ok = false
60 }
61 println(log)
62}
63
64func main() {
65 var t T
66 if t.a("1").a(t.b("2")); log != "a(1)ba(2)" {
67 bad()
68 }
69 log = ""
70 if a("3")(b("4"))(b("5")); log != "a(3)ba(4)ba(5)" {
71 bad()
72 }
73 log = ""
74 var i I = T1(0)
75 if i.a("6").a(i.b("7")).a(i.b("8")).a(i.b("9")); log != "a(6)ba(7)ba(8)ba(9)" {
76 bad()
77 }
78}
79