diff --git a/src/internal/reflectlite/type.go b/src/internal/reflectlite/type.go index 9dd1455dc..5ced5d357 100644 --- a/src/internal/reflectlite/type.go +++ b/src/internal/reflectlite/type.go @@ -754,8 +754,7 @@ func (t *RawType) FieldAlign() int { return t.Align() } -// ConvertibleTo returns wheather a value of type t can be converted to a variable of of type u - +// ConvertibleTo returns whether a value of type t can be converted to a variable of type u func (r *RawType) ConvertibleTo(u *RawType) bool { // This logic is mostly copied from Value.CanConvert diff --git a/src/internal/reflectlite/value.go b/src/internal/reflectlite/value.go index a2acac401..5909a3f05 100644 --- a/src/internal/reflectlite/value.go +++ b/src/internal/reflectlite/value.go @@ -1494,9 +1494,9 @@ func convertOp(src Value, typ Type) (Value, bool) { } case Complex64, Complex128: - switch src.Kind() { + switch rtype := typ.(*RawType); rtype.Kind() { case Complex64, Complex128: - return cvtComplex(src, typ.(*RawType)), true + return cvtComplex(src, rtype), true } case Slice: @@ -1543,7 +1543,7 @@ func convertOp(src Value, typ Type) (Value, bool) { case Pointer: rtype := typ.(*RawType) - if rtype.Kind() == Pointer && !rtype.isNamed() { + if rtype.Kind() == Pointer && !src.typecode.isNamed() && !rtype.isNamed() && src.typecode.elem().underlying() == rtype.elem().underlying() { return cvtDirect(src, rtype), true } } @@ -1708,9 +1708,6 @@ func makeComplex(flags valueFlags, f complex128, t *RawType) Value { return v } -//go:linkname stringFromUnicode runtime.stringFromUnicode -func stringFromUnicode(x rune) string - func cvtIntString(v Value, t *RawType) Value { s := "\uFFFD" if x := v.Int(); int64(rune(x)) == x {