reject_duplicate_method.mx raw
1 // expected: method T.M already declared
2 //
3 // A method declared twice is a redeclaration, the same error go/types reports.
4 // The top-level check landed first and covered functions only: stage4 compiled
5 // the second body away and answered 1 where legacy refuses the package.
6 package main
7
8 type T struct{ n int32 }
9
10 func (t *T) M() (r int32) { return 1 }
11
12 func (t *T) M() (r int32) { return 2 }
13
14 func main() {
15 x := &T{}
16 println(x.M())
17 }
18