Missing case types.TUNSAFEPTR in parameterizedBy().
Also realized there was the same missing case in the type substituter
(*Tsubster).Typ().
Fixes #48103
Change-Id: If71f1a6ef80932f0e2120d4c18b39a30189fd8fe
Reviewed-on: https://go-review.googlesource.com/c/go/+/346669
Reviewed-by: Keith Randall <khr@golang.org>
Trust: Dan Scales <danscales@google.com>
case types.TINT, types.TINT8, types.TINT16, types.TINT32, types.TINT64,
types.TUINT, types.TUINT8, types.TUINT16, types.TUINT32, types.TUINT64,
- types.TUINTPTR, types.TBOOL, types.TSTRING, types.TFLOAT32, types.TFLOAT64, types.TCOMPLEX64, types.TCOMPLEX128:
+ types.TUINTPTR, types.TBOOL, types.TSTRING, types.TFLOAT32, types.TFLOAT64, types.TCOMPLEX64, types.TCOMPLEX128, types.TUNSAFEPTR:
return true
case types.TUNION:
}
case types.TINT, types.TINT8, types.TINT16, types.TINT32, types.TINT64,
types.TUINT, types.TUINT8, types.TUINT16, types.TUINT32, types.TUINT64,
- types.TUINTPTR, types.TBOOL, types.TSTRING, types.TFLOAT32, types.TFLOAT64, types.TCOMPLEX64, types.TCOMPLEX128:
+ types.TUINTPTR, types.TBOOL, types.TSTRING, types.TFLOAT32, types.TFLOAT64, types.TCOMPLEX64, types.TCOMPLEX128, types.TUNSAFEPTR:
newt = t.Underlying()
case types.TUNION:
nt := t.NumTerms()
--- /dev/null
+// run -gcflags=-G=3
+
+// Copyright 2021 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package main
+
+import (
+ "fmt"
+ "unsafe"
+)
+
+type S[T any] struct {
+ val T
+}
+
+// Test type substitution where base type is unsafe.Pointer
+type U[T any] unsafe.Pointer
+
+func test[T any]() T {
+ var q U[T]
+ var v struct {
+ // Test derived type that contains an unsafe.Pointer
+ p unsafe.Pointer
+ val T
+ }
+ _ = q
+ return v.val
+}
+
+func main() {
+ want := 0
+ got := test[int]()
+ if got != want {
+ panic(fmt.Sprintf("got %f, want %f", got, want))
+ }
+
+}