ssa: fix typeAssert for Nil

This commit is contained in:
visualfc
2024-06-11 20:50:01 +08:00
parent f33796797d
commit 3f0c65ebb2
7 changed files with 2557 additions and 72 deletions

View File

@@ -238,11 +238,7 @@ func (b Builder) TypeAssert(x Expr, assertedTyp Type, commaOk bool) Expr {
var eq Expr
var val func() Expr
if rawIntf, ok := assertedTyp.raw.Type.Underlying().(*types.Interface); ok {
if rawIntf.Empty() {
eq = b.Prog.BoolVal(true)
} else {
eq = b.InlineCall(b.Pkg.rtFunc("Implements"), tabi, tx)
}
eq = b.InlineCall(b.Pkg.rtFunc("Implements"), tabi, tx)
val = func() Expr { return Expr{b.unsafeInterface(rawIntf, tx, b.faceData(x.impl)), assertedTyp} }
} else {
eq = b.BinOp(token.EQL, tx, tabi)