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

Make some macro methods more uniform #7970

merged 4 commits into from Jul 18, 2019


Copy link

commented Jul 17, 2019

Related issue:

This PR does these things (you can check each commit too):

  • Add Union#resolve and Union#resolve?: this was missing. For example this code doesn't compile but it should (if you replace decl.type.nilable? with decl.type.resolve.nilable?).
  • Add TypeNode#resolve and TypeNode#resolve?: so in case you either get a Path, Union, Generic or an already resolved TypeNode you can always call resolve on it and get a TypeNode
  • Add Path#types and Generic#types: there's already Union#types which returns a union's types. Instead of casing on it we can define types in these two other types two so you can always call types on something that looks like a type and work with that in a uniform way
  • Let TypeNode#union_types also work for non-union types: same reason as before to make it easier to work uniformly with unions and non-unions by providing a way to convert a type to a list of types it holds (for a non-union it's just that type).

These are small improvements that, I believe, will make the life of macro users a bit more simple.

Copy link

left a comment

This is amazing! This will clean up so many macros in Lucky ❤

Show resolved Hide resolved src/compiler/crystal/ Outdated

@bcardiff bcardiff added this to the 0.30.0 milestone Jul 17, 2019

@asterite asterite force-pushed the macro-methods branch from 2a4e6b6 to ca18cdb Jul 18, 2019

@bcardiff bcardiff merged commit 68af19d into master Jul 18, 2019

5 checks passed

ci/circleci: check_format Your tests passed on CircleCI!
ci/circleci: test_darwin Your tests passed on CircleCI!
ci/circleci: test_linux Your tests passed on CircleCI!
ci/circleci: test_linux32 Your tests passed on CircleCI!
continuous-integration/travis-ci/pr The Travis CI build passed

@bcardiff bcardiff deleted the macro-methods branch Jul 18, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
4 participants
You can’t perform that action at this time.