Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Method hints do not work on objects returned by helpers #2142

Closed
Wmn opened this issue Apr 6, 2020 · 2 comments
Closed

Method hints do not work on objects returned by helpers #2142

Wmn opened this issue Apr 6, 2020 · 2 comments

Comments

@Wmn
Copy link

Wmn commented Apr 6, 2020

When you use Mojo helper returning an object and try to call a method on return of the helper, IDEA does not provde method hints for the package, only SUPER::....

Example script to reproduce the issue:

#!/usr/bin/env perl

package Test1;

use feature qw(signatures);
no warnings qw(experimental::signatures);

sub new($class) {
    return bless {}, $class;
}

sub test($self) {
    return 'works';
}

1;

package main;

use feature qw/say/;
use Mojolicious::Lite -signatures;
use Test1;

helper test => sub {
    state $pkg = Test1->new
};

get '/' => sub($c) {
    say $c->test->... # <- Hint is only SUPER here, while there should be the list of methods from Test1 package
};

app->start;

Environment info:

  • IntelliJ IDEA 2019.2.1 Build #IC-192.6262.58
  • Plugin version 2019.2.4
  • openjdk version "1.8.0_222"
  • FreeBSD 13.0-CURRENT
@hurricup
Copy link
Collaborator

Ok. there are two problems here:

  1. Plugin don't understand definition with helper, but understand with $self->helper
  2. Plugin don't understand the type of returned declaration. Meaning:
# Doesn't work
$self->helper test => sub {
    state $pkg = Test1->new
};

# Works
$self->helper test => sub {
    state $pkg = Test1->new;
    $pkg
};

Investigating

@hurricup
Copy link
Collaborator

I'm afraid this can be fixed only in the next major release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants