- if (oi && (s = oi->pos)) {
- sv = sv_2mortal(newSVpvn(oi->buf, oi->len));
- line = oi->line; /* Keep the old line so that we really point to the first */
- } else {
- sv = cSVOPx_sv(op);
- if (!SvPOK(sv) || (SvTYPE(sv) < SVt_PV))
- goto done;
- sv = sv_mortalcopy(sv);
- s = indirect_find(sv, PL_oldbufptr);
- line = CopLINE(&PL_compiling);
- }
+ /* Indirect method call is only possible when the method is a bareword, so
+ * don't trip up on $obj->$meth. */
+ if (op && op->op_type == OP_CONST) {
+ const indirect_op_info_t *oi = indirect_map_fetch(op);
+ const char *s = NULL;
+ line_t line;
+ SV *sv;
+
+ if (oi && (s = oi->pos)) {
+ sv = sv_2mortal(newSVpvn(oi->buf, oi->len));
+ /* Keep the old line so that we really point to the first line of the
+ * expression. */
+ line = oi->line;
+ } else {
+ sv = cSVOPx_sv(op);
+ if (!SvPOK(sv) || (SvTYPE(sv) < SVt_PV))
+ goto done;
+ sv = sv_mortalcopy(sv);
+ s = indirect_find(sv, PL_oldbufptr);
+ line = CopLINE(&PL_compiling);
+ }