mirror of
https://github.com/golang/go
synced 2024-11-19 01:24:39 -07:00
go.tools/ssa/interp: make typeAssert robust against nil types
R=adonovan CC=golang-dev https://golang.org/cl/16180043
This commit is contained in:
parent
a1886cc6ef
commit
c8f4d650c8
@ -881,13 +881,12 @@ func unop(instr *ssa.UnOp, x value) value {
|
|||||||
func typeAssert(i *interpreter, instr *ssa.TypeAssert, itf iface) value {
|
func typeAssert(i *interpreter, instr *ssa.TypeAssert, itf iface) value {
|
||||||
var v value
|
var v value
|
||||||
err := ""
|
err := ""
|
||||||
if idst, ok := instr.AssertedType.Underlying().(*types.Interface); ok {
|
if itf.t == nil {
|
||||||
if itf.t == nil {
|
err = fmt.Sprintf("interface conversion: interface is nil, not %s", instr.AssertedType)
|
||||||
err = fmt.Sprintf("interface conversion: interface is nil, not %s", instr.AssertedType)
|
|
||||||
} else {
|
} else if idst, ok := instr.AssertedType.Underlying().(*types.Interface); ok {
|
||||||
v = itf
|
v = itf
|
||||||
err = checkInterface(i, idst, itf)
|
err = checkInterface(i, idst, itf)
|
||||||
}
|
|
||||||
|
|
||||||
} else if types.IsIdentical(itf.t, instr.AssertedType) {
|
} else if types.IsIdentical(itf.t, instr.AssertedType) {
|
||||||
v = copyVal(itf.v) // extract value
|
v = copyVal(itf.v) // extract value
|
||||||
|
Loading…
Reference in New Issue
Block a user