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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix RBI generation for gems #303

Merged
merged 2 commits into from May 6, 2021
Merged

Fix RBI generation for gems #303

merged 2 commits into from May 6, 2021

Conversation

Morriar
Copy link
Collaborator

@Morriar Morriar commented May 5, 2021

Motivation

My previous PR on RBI generation (#297) broke two things:

  1. Grouping the include and extend in separate groups meant I changed the order in which they were generated and includes were always printed before extends which is actually incorrect. So the first commit (2bb2a7e) groups them together to get the right order again.

  2. Both params types and return types need to be sanitized for weird types such as <VOID>. It was done on the whole signature string before and I forgot to do it on parameters types. The second commit (86b2982) fixes this and adds a related test.

With these fixes we can generate the RBIs for Shopify's core without any error! 馃帀

Tests

See included tests.

Signed-off-by: Alexandre Terrasa <alexandre.terrasa@shopify.com>
Signed-off-by: Alexandre Terrasa <alexandre.terrasa@shopify.com>
@Morriar Morriar requested a review from a team May 5, 2021 20:06
@@ -49,7 +49,6 @@ module Baz; end

class Baz::Role
include ::SmartProperties

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No more newline here since it's in the same group now.

@@ -431,8 +431,8 @@ def self.m2; end
rbi << RBI::Class.new("S2")
rbi << RBI::Method.new("m1")
rbi << RBI::Method.new("m2", is_singleton: true)
rbi << RBI::Include.new("I")
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Just changed the order in a few tests to show that we keep it when compiling.

.gsub("<NOT-TYPED>", "T.untyped")
.gsub(".params()", "")

type = sanitize_signature_types(parameter_types[name.to_sym].to_s)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Factorized the sanitization so both params and return types are handled the same.

@Morriar Morriar changed the title Fix RBI generation for tests Fix RBI generation for gems May 5, 2021
Copy link
Member

@paracycle paracycle left a comment

Choose a reason for hiding this comment

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

Yeah, the include/extend ordering is tricky. My first implementation had also completely messed it up. :)

@Morriar Morriar merged commit 75cfc09 into master May 6, 2021
@Morriar Morriar deleted the at-fix-rbi-gems-gen branch May 6, 2021 14:29
@shopify-shipit shopify-shipit bot temporarily deployed to production May 19, 2021 17:37 Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants