...
Run Format

Source file test/fixedbugs/bug294.go

Documentation: test/fixedbugs

     1  // run
     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  // https://golang.org/issue/800
     8  
     9  package main
    10  
    11  var log string
    12  
    13  type T int
    14  
    15  func (t T) a(s string) T {
    16  	log += "a(" + s + ")"
    17  	return t
    18  }
    19  
    20  func (T) b(s string) string {
    21  	log += "b"
    22  	return s
    23  }
    24  
    25  type F func(s string) F
    26  
    27  func a(s string) F {
    28  	log += "a(" + s + ")"
    29  	return F(a)
    30  }
    31  
    32  func b(s string) string {
    33  	log += "b"
    34  	return s
    35  }
    36  
    37  type I interface {
    38  	a(s string) I
    39  	b(s string) string
    40  }
    41  
    42  type T1 int
    43  
    44  func (t T1) a(s string) I {
    45  	log += "a(" + s + ")"
    46  	return t
    47  }
    48  
    49  func (T1) b(s string) string {
    50  	log += "b"
    51  	return s
    52  }
    53  
    54  var ok = true
    55  
    56  func bad() {
    57  	if !ok {
    58  		println("BUG")
    59  		ok = false
    60  	}
    61  	println(log)
    62  }
    63  
    64  func 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  
    80  

View as plain text