...
1[short] skip
2[!cgo] skip
3
4# Test that cgo rejects attempts to declare methods
5# on the types C.T or *C.T; see issue #57926.
6
7! go build
8stderr 'cannot define new methods on non-local type C.T'
9stderr 'cannot define new methods on non-local type \*C.T'
10! stderr 'Alias'
11
12-- go.mod --
13module example.com
14go 1.12
15
16-- a.go --
17package a
18
19/*
20typedef int T;
21*/
22import "C"
23
24func (C.T) f() {}
25func (recv *C.T) g() {}
26
27// The check is more education than enforcement,
28// and is easily defeated using a type alias.
29type Alias = C.T
30func (Alias) h() {}
31func (*Alias) i() {}
View as plain text