github.com/JimmyHuang454/JLS-go@v0.0.0-20230831150107-90d536585ba0/internal/types/testdata/fixedbugs/issue28251.go (about) 1 // Copyright 2018 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 // This file contains test cases for various forms of 6 // method receiver declarations, per the spec clarification 7 // https://golang.org/cl/142757. 8 9 package issue28251 10 11 // test case from issue28251 12 type T struct{} 13 14 type T0 = *T 15 16 func (T0) m() {} 17 18 func _() { (&T{}).m() } 19 20 // various alternative forms 21 type ( 22 T1 = (((T))) 23 ) 24 25 func ((*(T1))) m1() {} 26 func _() { (T{}).m2() } 27 func _() { (&T{}).m2() } 28 29 type ( 30 T2 = (((T3))) 31 T3 = T 32 ) 33 34 func (T2) m2() {} 35 func _() { (T{}).m2() } 36 func _() { (&T{}).m2() } 37 38 type ( 39 T4 = ((*(T5))) 40 T5 = T 41 ) 42 43 func (T4) m4() {} 44 func _() { (T{}).m4 /* ERROR "cannot call pointer method m4 on T" */ () } 45 func _() { (&T{}).m4() } 46 47 type ( 48 T6 = (((T7))) 49 T7 = (*(T8)) 50 T8 = T 51 ) 52 53 func (T6) m6() {} 54 func _() { (T{}).m6 /* ERROR "cannot call pointer method m6 on T" */ () } 55 func _() { (&T{}).m6() } 56 57 type ( 58 T9 = *T10 59 T10 = *T11 60 T11 = T 61 ) 62 63 func (T9 /* ERROR invalid receiver type \*\*T */ ) m9() {} 64 func _() { (T{}).m9 /* ERROR has no field or method m9 */ () } 65 func _() { (&T{}).m9 /* ERROR has no field or method m9 */ () }