if stmt.Op != syntax.Shl && stmt.Op != syntax.Shr {
typ = w.p.typeOf(stmt.Lhs)
}
- w.implicitConvExpr(stmt, typ, stmt.Rhs)
+ w.implicitConvExpr(typ, stmt.Rhs)
default:
w.assignStmt(stmt, stmt.Lhs, stmt.Rhs)
w.Code(stmtSend)
w.pos(stmt)
w.expr(stmt.Chan)
- w.implicitConvExpr(stmt, chanType.Elem(), stmt.Value)
+ w.implicitConvExpr(chanType.Elem(), stmt.Value)
case *syntax.SwitchStmt:
w.Code(stmtSwitch)
}
if w.Bool(tag != nil) {
- w.implicitConvExpr(tag, tagType, tag)
+ w.implicitConvExpr(tagType, tag)
}
}
w.Sync(pkgbits.SyncExprs)
w.Len(len(cases))
for _, cas := range cases {
- w.implicitConvExpr(cas, tagType, cas)
+ w.implicitConvExpr(tagType, cas)
}
}
w.Code(exprIndex)
w.expr(expr.X)
w.pos(expr)
- w.implicitConvExpr(expr, keyType, expr.Index)
+ w.implicitConvExpr(keyType, expr.Index)
if keyType != nil {
w.rtype(xtyp)
}
w.Code(exprBinaryOp)
w.op(binOps[expr.Op])
- w.implicitConvExpr(expr, commonType, expr.X)
+ w.implicitConvExpr(commonType, expr.X)
w.pos(expr)
- w.implicitConvExpr(expr, commonType, expr.Y)
+ w.implicitConvExpr(commonType, expr.Y)
case *syntax.CallExpr:
tv, ok := w.p.info.Types[expr.Fun]
w.Bool(false) // N:N assignment
w.Len(len(exprs))
for i, expr := range exprs {
- w.implicitConvExpr(pos, dstType(i), expr)
+ w.implicitConvExpr(dstType(i), expr)
}
}
-// implicitConvExpr is like expr, but if dst is non-nil and different from
-// expr's type, then an implicit conversion operation is inserted at
-// pos.
-func (w *writer) implicitConvExpr(pos poser, dst types2.Type, expr syntax.Expr) {
+// implicitConvExpr is like expr, but if dst is non-nil and different
+// from expr's type, then an implicit conversion operation is inserted
+// at expr's position.
+func (w *writer) implicitConvExpr(dst types2.Type, expr syntax.Expr) {
src := w.p.typeOf(expr)
if dst != nil && !types2.Identical(src, dst) {
if !types2.AssignableTo(src, dst) {
- w.p.fatalf(pos, "%v is not assignable to %v", src, dst)
+ w.p.fatalf(expr.Pos(), "%v is not assignable to %v", src, dst)
}
w.Code(exprConvert)
w.Bool(true) // implicit
w.typ(dst)
- w.pos(pos)
+ w.pos(expr)
w.convRTTI(src, dst)
w.Bool(isTypeParam(dst))
// fallthrough
if kv, ok := elem.(*syntax.KeyValueExpr); w.Bool(ok) {
// use position of expr.Key rather than of elem (which has position of ':')
w.pos(kv.Key)
- w.implicitConvExpr(kv.Key, keyType, kv.Key)
+ w.implicitConvExpr(keyType, kv.Key)
elem = kv.Value
}
}
w.pos(elem)
- w.implicitConvExpr(elem, elemType, elem)
+ w.implicitConvExpr(elemType, elem)
}
}