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
Conversation
Signed-off-by: Alexandre Terrasa <alexandre.terrasa@shopify.com>
Signed-off-by: Alexandre Terrasa <alexandre.terrasa@shopify.com>
@@ -49,7 +49,6 @@ module Baz; end | |||
|
|||
class Baz::Role | |||
include ::SmartProperties | |||
|
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
There was a problem hiding this 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. :)
Motivation
My previous PR on RBI generation (#297) broke two things:
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.
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.