Debian Codegraph @

test/typeparam/issue54765.go

raw
1 // errorcheck
2
3 // Copyright 2022 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 // Test that not-in-heap types cannot be used as type
8 // arguments. (pointer-to-nih types are okay though.)
9
10 //go:build cgo
11
12 package p
13
14 import (
15 "runtime/cgo"
16 "sync/atomic"
17 )
18
19 var _ atomic.Pointer[cgo.Incomplete] // ERROR "cannot use incomplete \(or unallocatable\) type as a type argument: runtime/cgo\.Incomplete"
20 var _ atomic.Pointer[*cgo.Incomplete] // ok
21
22 func implicit(ptr *cgo.Incomplete) {
23 g(ptr) // ERROR "cannot use incomplete \(or unallocatable\) type as a type argument: runtime/cgo\.Incomplete"
24 g(&ptr) // ok
25 }
26
27 func g[T any](_ *T) {}