aboutsummaryrefslogtreecommitdiff
path: root/src/runtime
diff options
context:
space:
mode:
Diffstat (limited to 'src/runtime')
-rw-r--r--src/runtime/iface.go28
-rw-r--r--src/runtime/mfinal.go4
2 files changed, 11 insertions, 21 deletions
diff --git a/src/runtime/iface.go b/src/runtime/iface.go
index 0504b89363..02b18dabff 100644
--- a/src/runtime/iface.go
+++ b/src/runtime/iface.go
@@ -447,23 +447,18 @@ func convI2I(inter *interfacetype, i iface) (r iface) {
return
}
-func assertI2I(inter *interfacetype, i iface) (r iface) {
- tab := i.tab
+func assertI2I(inter *interfacetype, tab *itab) *itab {
if tab == nil {
// explicit conversions require non-nil interface value.
panic(&TypeAssertionError{nil, nil, &inter.typ, ""})
}
if tab.inter == inter {
- r.tab = tab
- r.data = i.data
- return
+ return tab
}
- r.tab = getitab(inter, tab._type, false)
- r.data = i.data
- return
+ return getitab(inter, tab._type, false)
}
-func assertI2I2(inter *interfacetype, i iface) (r iface, b bool) {
+func assertI2I2(inter *interfacetype, i iface) (r iface) {
tab := i.tab
if tab == nil {
return
@@ -476,22 +471,18 @@ func assertI2I2(inter *interfacetype, i iface) (r iface, b bool) {
}
r.tab = tab
r.data = i.data
- b = true
return
}
-func assertE2I(inter *interfacetype, e eface) (r iface) {
- t := e._type
+func assertE2I(inter *interfacetype, t *_type) *itab {
if t == nil {
// explicit conversions require non-nil interface value.
panic(&TypeAssertionError{nil, nil, &inter.typ, ""})
}
- r.tab = getitab(inter, t, false)
- r.data = e.data
- return
+ return getitab(inter, t, false)
}
-func assertE2I2(inter *interfacetype, e eface) (r iface, b bool) {
+func assertE2I2(inter *interfacetype, e eface) (r iface) {
t := e._type
if t == nil {
return
@@ -502,18 +493,17 @@ func assertE2I2(inter *interfacetype, e eface) (r iface, b bool) {
}
r.tab = tab
r.data = e.data
- b = true
return
}
//go:linkname reflect_ifaceE2I reflect.ifaceE2I
func reflect_ifaceE2I(inter *interfacetype, e eface, dst *iface) {
- *dst = assertE2I(inter, e)
+ *dst = iface{assertE2I(inter, e._type), e.data}
}
//go:linkname reflectlite_ifaceE2I internal/reflectlite.ifaceE2I
func reflectlite_ifaceE2I(inter *interfacetype, e eface, dst *iface) {
- *dst = assertE2I(inter, e)
+ *dst = iface{assertE2I(inter, e._type), e.data}
}
func iterate_itabs(fn func(*itab)) {
diff --git a/src/runtime/mfinal.go b/src/runtime/mfinal.go
index 7d0313be12..e92ec80e3c 100644
--- a/src/runtime/mfinal.go
+++ b/src/runtime/mfinal.go
@@ -214,7 +214,7 @@ func runfinq() {
if len(ityp.mhdr) != 0 {
// convert to interface with methods
// this conversion is guaranteed to succeed - we checked in SetFinalizer
- *(*iface)(frame) = assertE2I(ityp, *(*eface)(frame))
+ (*iface)(frame).tab = assertE2I(ityp, (*eface)(frame)._type)
}
default:
throw("bad kind in runfinq")
@@ -403,7 +403,7 @@ func SetFinalizer(obj interface{}, finalizer interface{}) {
// ok - satisfies empty interface
goto okarg
}
- if _, ok := assertE2I2(ityp, *efaceOf(&obj)); ok {
+ if iface := assertE2I2(ityp, *efaceOf(&obj)); iface.tab != nil {
goto okarg
}
}