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

Implementation: allow to lookup class and module implementations #7742

Conversation

makenowjust
Copy link
Contributor

Fixed #4941

Image:

2019-05-06 8:39:32

I think it is totally useful, however this implementation cannot work on some corner case. One corner case, method argument restriction:

def foo(x : ‸Foo)
end

foo

It is hard to implement for now. Another corner case, macro argument:

record Foo,
  x : ‸Bar

It is impossible.


@faustinoaq Sorry for the late. Is this okay?

@makenowjust
Copy link
Contributor Author

ping. Could anyone review this?

༓class Foo
end

alias Bar = Foo
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was there an explicit decision to not resolve to this line instead the Foo? What happens if the alias has a union?

@makenowjust
Copy link
Contributor Author

@bcardiff Thank you for reviewing!

I fixed crystal tool implementation to lookup alias name without resolve. For example:

foo.cr:

class Foo
end

class Bar
end

alias Baz = Foo | Bar

Baz
$ bin/crystal tool implementation -c foo.cr:9:1 foo.cr
1 implementation found
foo.cr:7:1

Unfortunately this doesn't work:

$ bin/crystal tool implementation -c foo.cr:7:15 foo.cr
no implementations or method call found

I think implementing this is hard for now...

Copy link
Member

@sdogruyol sdogruyol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @makenowjust 👍

Copy link
Member

@bcardiff bcardiff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was a bit worried about the introduction of target_type in Path it's actually similar to target_const.

Please, create an issue to track the left-over for the lookup from the alias definition.

Thanks!

@faustinoaq
Copy link
Contributor

Hi @makenowjust Yeah, this is a progress, Thank you! 👍

@bcardiff bcardiff merged commit aaf05d9 into crystal-lang:master May 15, 2019
@makenowjust makenowjust deleted the fix/4941-crystal-tool-implementation-class branch May 15, 2019 15:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow to find modules and classes using crystal tool
7 participants