diff --git a/src/cmd/compile/internal/types2/instantiate.go b/src/cmd/compile/internal/types2/instantiate.go
index 3c4044e..fb7c553 100644
--- a/src/cmd/compile/internal/types2/instantiate.go
+++ b/src/cmd/compile/internal/types2/instantiate.go
@@ -245,7 +245,7 @@
if cause != nil {
var detail string
if isInterfacePtr(Tu) {
- detail = check.sprintf("type %s is pointer to interface, not interface", T)
+ detail = check.interfacePtrError(T)
} else {
detail = check.sprintf("%s is not an interface", T)
}
diff --git a/src/cmd/compile/internal/types2/lookup.go b/src/cmd/compile/internal/types2/lookup.go
index 107101f..b9744b4 100644
--- a/src/cmd/compile/internal/types2/lookup.go
+++ b/src/cmd/compile/internal/types2/lookup.go
@@ -564,6 +564,11 @@
return p != nil && IsInterface(p.base)
}
+func isNonTypeParamInterfacePtr(T Type) bool {
+ p, _ := T.Underlying().(*Pointer)
+ return p != nil && isNonTypeParamInterface(p.base)
+}
+
// check may be nil.
func (check *Checker) interfacePtrError(T Type) string {
assert(isInterfacePtr(T))
diff --git a/src/cmd/compile/internal/types2/operand.go b/src/cmd/compile/internal/types2/operand.go
index 0e8aa24..26598c0 100644
--- a/src/cmd/compile/internal/types2/operand.go
+++ b/src/cmd/compile/internal/types2/operand.go
@@ -370,9 +370,9 @@
}
// T is an interface type, but not a type parameter, and V implements T.
- // Also handle the case where T is a pointer to an interface so that we get
- // the Checker.implements error cause.
- if _, ok := Tu.(*Interface); ok && Tp == nil || isInterfacePtr(Tu) {
+ // Also handle the case where T is a pointer to a non-type-parameter
+ // interface so that we get the Checker.implements error cause.
+ if _, ok := Tu.(*Interface); ok && Tp == nil || isNonTypeParamInterfacePtr(Tu) {
if check.implements(V, T, false, cause) {
return true, 0
}
diff --git a/src/go/types/instantiate.go b/src/go/types/instantiate.go
index 6488494..b0df7b9 100644
--- a/src/go/types/instantiate.go
+++ b/src/go/types/instantiate.go
@@ -248,7 +248,7 @@
if cause != nil {
var detail string
if isInterfacePtr(Tu) {
- detail = check.sprintf("type %s is pointer to interface, not interface", T)
+ detail = check.interfacePtrError(T)
} else {
detail = check.sprintf("%s is not an interface", T)
}
diff --git a/src/go/types/lookup.go b/src/go/types/lookup.go
index 0d056e7..5f9b54b 100644
--- a/src/go/types/lookup.go
+++ b/src/go/types/lookup.go
@@ -567,6 +567,11 @@
return p != nil && IsInterface(p.base)
}
+func isNonTypeParamInterfacePtr(T Type) bool {
+ p, _ := T.Underlying().(*Pointer)
+ return p != nil && isNonTypeParamInterface(p.base)
+}
+
// check may be nil.
func (check *Checker) interfacePtrError(T Type) string {
assert(isInterfacePtr(T))
diff --git a/src/go/types/operand.go b/src/go/types/operand.go
index 860611a..7386b64 100644
--- a/src/go/types/operand.go
+++ b/src/go/types/operand.go
@@ -374,9 +374,9 @@
}
// T is an interface type, but not a type parameter, and V implements T.
- // Also handle the case where T is a pointer to an interface so that we get
- // the Checker.implements error cause.
- if _, ok := Tu.(*Interface); ok && Tp == nil || isInterfacePtr(Tu) {
+ // Also handle the case where T is a pointer to a non-type-parameter
+ // interface so that we get the Checker.implements error cause.
+ if _, ok := Tu.(*Interface); ok && Tp == nil || isNonTypeParamInterfacePtr(Tu) {
if check.implements(V, T, false, cause) {
return true, 0
}
diff --git a/src/internal/types/testdata/fixedbugs/issue79883.go b/src/internal/types/testdata/fixedbugs/issue79883.go
new file mode 100644
index 0000000..fe97955
--- /dev/null
+++ b/src/internal/types/testdata/fixedbugs/issue79883.go
@@ -0,0 +1,14 @@
+// Copyright 2026 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 p
+
+func _[A [1]int]() {
+ var s string
+ _ = (*A)(s /* ERRORx `^cannot convert s \(variable of type string\) to type \*A$` */)
+}
+
+func _[A [1]int](p *[1]int) {
+ _ = (*A)(p /* ERRORx `^cannot convert p \(variable of type \*\[1\]int\) to type \*A$` */)
+}