rbs 4.0.3 → 4.1.0.pre.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +34 -6
  3. data/.github/workflows/rust.yml +0 -2
  4. data/.github/workflows/windows.yml +0 -3
  5. data/CHANGELOG.md +0 -8
  6. data/Rakefile +2 -2
  7. data/config.yml +24 -0
  8. data/core/builtin.rbs +1 -0
  9. data/core/class.rbs +5 -3
  10. data/core/kernel.rbs +26 -11
  11. data/core/ruby_vm.rbs +40 -0
  12. data/docs/inline.md +29 -1
  13. data/ext/rbs_extension/ast_translation.c +21 -0
  14. data/ext/rbs_extension/class_constants.c +2 -0
  15. data/ext/rbs_extension/class_constants.h +1 -0
  16. data/ext/rbs_extension/extconf.rb +1 -0
  17. data/include/rbs/ast.h +314 -297
  18. data/include/rbs/defines.h +13 -0
  19. data/include/rbs/lexer.h +1 -0
  20. data/lib/rbs/annotate/rdoc_annotator.rb +27 -31
  21. data/lib/rbs/ast/ruby/annotations.rb +42 -0
  22. data/lib/rbs/ast/ruby/declarations.rb +11 -1
  23. data/lib/rbs/ast/ruby/members.rb +28 -0
  24. data/lib/rbs/cli.rb +3 -5
  25. data/lib/rbs/collection/config/lockfile_generator.rb +14 -1
  26. data/lib/rbs/environment.rb +6 -0
  27. data/lib/rbs/inline_parser.rb +49 -25
  28. data/lib/rbs/rewriter.rb +70 -0
  29. data/lib/rbs/test/type_check.rb +6 -1
  30. data/lib/rbs/version.rb +1 -1
  31. data/lib/rbs.rb +1 -0
  32. data/sig/annotate/rdoc_annotater.rbs +12 -9
  33. data/sig/ast/ruby/annotations.rbs +49 -0
  34. data/sig/ast/ruby/members.rbs +15 -0
  35. data/sig/collection/config/lockfile_generator.rbs +2 -0
  36. data/sig/inline_parser.rbs +2 -0
  37. data/sig/manifest.yaml +0 -1
  38. data/sig/rewriter.rbs +45 -0
  39. data/src/ast.c +109 -85
  40. data/src/lexer.c +137 -114
  41. data/src/lexer.re +1 -0
  42. data/src/lexstate.c +1 -0
  43. data/src/parser.c +55 -5
  44. data/stdlib/openssl/0/openssl.rbs +2 -2
  45. metadata +3 -1
data/src/lexer.re CHANGED
@@ -83,6 +83,7 @@ rbs_token_t rbs_lexer_next_token(rbs_lexer_t *lexer) {
83
83
  "interface" { return rbs_next_token(lexer, kINTERFACE); }
84
84
  "module" { return rbs_next_token(lexer, kMODULE); }
85
85
  "module-alias" { return rbs_next_token(lexer, kMODULEALIAS); }
86
+ "module-self" { return rbs_next_token(lexer, kMODULESELF); }
86
87
  "nil" { return rbs_next_token(lexer, kNIL); }
87
88
  "out" { return rbs_next_token(lexer, kOUT); }
88
89
  "prepend" { return rbs_next_token(lexer, kPREPEND); }
data/src/lexstate.c CHANGED
@@ -68,6 +68,7 @@ static const char *RBS_TOKENTYPE_NAMES[] = {
68
68
  "kATRBS", /* @rbs */
69
69
  "kSKIP", /* skip */
70
70
  "kRETURN", /* return */
71
+ "kMODULESELF", /* module-self */
71
72
 
72
73
  "tLIDENT", /* Identifiers starting with lower case */
73
74
  "tUIDENT", /* Identifiers starting with upper case */
data/src/parser.c CHANGED
@@ -3324,11 +3324,7 @@ bool rbs_parse_signature(rbs_parser_t *parser, rbs_signature_t **signature) {
3324
3324
  rbs_ast_directives_use_t *use_node;
3325
3325
  CHECK_PARSE(parse_use_directive(parser, &use_node));
3326
3326
 
3327
- if (use_node == NULL) {
3328
- rbs_node_list_append(dirs, NULL);
3329
- } else {
3330
- rbs_node_list_append(dirs, (rbs_node_t *) use_node);
3331
- }
3327
+ rbs_node_list_append(dirs, (rbs_node_t *) use_node);
3332
3328
  }
3333
3329
 
3334
3330
  while (parser->next_token.type != pEOF) {
@@ -4052,6 +4048,60 @@ static bool parse_inline_leading_annotation(rbs_parser_t *parser, rbs_ast_ruby_a
4052
4048
  );
4053
4049
  return true;
4054
4050
  }
4051
+ case kMODULESELF: {
4052
+ rbs_parser_advance(parser);
4053
+ rbs_range_t keyword_range = parser->current_token.range;
4054
+
4055
+ ADVANCE_ASSERT(parser, pCOLON);
4056
+ rbs_range_t colon_range = parser->current_token.range;
4057
+
4058
+ rbs_parser_advance(parser);
4059
+
4060
+ rbs_range_t name_range;
4061
+ rbs_type_name_t *type_name = NULL;
4062
+ if (!parse_type_name(parser, (TypeNameKind) (CLASS_NAME | INTERFACE_NAME), &name_range, &type_name)) {
4063
+ return false;
4064
+ }
4065
+
4066
+ rbs_node_list_t *args = rbs_node_list_new(ALLOCATOR());
4067
+ rbs_location_range open_bracket_loc = RBS_LOCATION_NULL_RANGE;
4068
+ rbs_location_range close_bracket_loc = RBS_LOCATION_NULL_RANGE;
4069
+ rbs_location_range_list_t *args_comma_locations = rbs_location_range_list_new(ALLOCATOR());
4070
+ if (parser->next_token.type == pLBRACKET) {
4071
+ rbs_parser_advance(parser);
4072
+ open_bracket_loc = RBS_RANGE_LEX2AST(parser->current_token.range);
4073
+ CHECK_PARSE(parse_type_list_with_commas(parser, pRBRACKET, args, args_comma_locations, true, false, false));
4074
+ rbs_parser_advance(parser);
4075
+ close_bracket_loc = RBS_RANGE_LEX2AST(parser->current_token.range);
4076
+ }
4077
+
4078
+ rbs_location_range comment_loc = RBS_LOCATION_NULL_RANGE;
4079
+ if (!parse_inline_comment(parser, &comment_loc)) {
4080
+ return false;
4081
+ }
4082
+
4083
+ rbs_range_t full_range = {
4084
+ .start = rbs_range.start,
4085
+ .end = parser->current_token.range.end
4086
+ };
4087
+
4088
+ rbs_location_range full_loc = RBS_RANGE_LEX2AST(full_range);
4089
+
4090
+ *annotation = (rbs_ast_ruby_annotations_t *) rbs_ast_ruby_annotations_module_self_annotation_new(
4091
+ ALLOCATOR(),
4092
+ full_loc,
4093
+ RBS_RANGE_LEX2AST(rbs_range),
4094
+ RBS_RANGE_LEX2AST(keyword_range),
4095
+ RBS_RANGE_LEX2AST(colon_range),
4096
+ type_name,
4097
+ args,
4098
+ open_bracket_loc,
4099
+ close_bracket_loc,
4100
+ args_comma_locations,
4101
+ comment_loc
4102
+ );
4103
+ return true;
4104
+ }
4055
4105
  default: {
4056
4106
  rbs_parser_set_error(parser, parser->next_token, true, "unexpected token for @rbs annotation");
4057
4107
  return false;
@@ -8570,7 +8570,7 @@ module OpenSSL
8570
8570
  # The callback is invoked with an SSLSocket. If `false` is returned the session
8571
8571
  # will be removed from the internal cache.
8572
8572
  #
8573
- def session_new_cb: () -> (^(SSLSocket) -> untyped | nil)
8573
+ def session_new_cb: () -> (^(SSLSocket, Session) -> untyped | nil)
8574
8574
 
8575
8575
  # <!-- rdoc-file=ext/openssl/ossl_ssl.c -->
8576
8576
  # A callback invoked when a new session was negotiated.
@@ -8578,7 +8578,7 @@ module OpenSSL
8578
8578
  # The callback is invoked with an SSLSocket. If `false` is returned the session
8579
8579
  # will be removed from the internal cache.
8580
8580
  #
8581
- def session_new_cb=: (^(SSLSocket) -> untyped) -> ^(SSLSocket) -> untyped
8581
+ def session_new_cb=: (^(SSLSocket, Session) -> untyped) -> ^(SSLSocket, Session) -> untyped
8582
8582
 
8583
8583
  # <!--
8584
8584
  # rdoc-file=ext/openssl/ossl_ssl.c
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbs
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.3
4
+ version: 4.1.0.pre.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Soutaro Matsumoto
@@ -287,6 +287,7 @@ files:
287
287
  - lib/rbs/repository.rb
288
288
  - lib/rbs/resolver/constant_resolver.rb
289
289
  - lib/rbs/resolver/type_name_resolver.rb
290
+ - lib/rbs/rewriter.rb
290
291
  - lib/rbs/sorter.rb
291
292
  - lib/rbs/source.rb
292
293
  - lib/rbs/substitution.rb
@@ -388,6 +389,7 @@ files:
388
389
  - sig/resolver/constant_resolver.rbs
389
390
  - sig/resolver/context.rbs
390
391
  - sig/resolver/type_name_resolver.rbs
392
+ - sig/rewriter.rbs
391
393
  - sig/shims/bundler.rbs
392
394
  - sig/shims/enumerable.rbs
393
395
  - sig/shims/rubygems.rbs