Skip to content

Commit a48b893

Browse files
authored
Merge pull request #10588 from asgerf/rb/rbi-instantiated-type
Ruby: add RbiInstantiatedType
2 parents 6cb26d5 + 182d7d3 commit a48b893

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

ruby/ql/lib/codeql/ruby/experimental/Rbi.qll

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ module Rbi {
132132
}
133133
}
134134

135+
/**
136+
* A use of `T::Hash`.
137+
*/
135138
class RbiHashType extends RbiType, ConstantReadAccessFromT {
136139
RbiHashType() { this.getName() = "Hash" }
137140

@@ -144,6 +147,11 @@ module Rbi {
144147
Expr getValueType() { result = this.getRefNode().getArgument(1) }
145148
}
146149

150+
/** A type instantiated with type arguments, such as `T::Array[String]`. */
151+
class RbiInstantiatedType extends RbiType, ElementReference {
152+
RbiInstantiatedType() { this.getReceiver() instanceof RbiType }
153+
}
154+
147155
/**
148156
* A call to `T.proc`. This defines a type signature for a proc or block
149157
*/

ruby/ql/test/library-tests/experimental/Rbi.expected

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,14 @@ rbiTypes
2626
| test_types.rb:38:48:38:53 | String |
2727
| test_types.rb:43:22:43:22 | T |
2828
| test_types.rb:43:22:43:28 | Hash |
29+
| test_types.rb:43:22:43:50 | ...[...] |
2930
| test_types.rb:43:30:43:30 | T |
3031
| test_types.rb:43:30:43:38 | call to untyped |
3132
| test_types.rb:43:41:43:41 | T |
3233
| test_types.rb:43:41:43:49 | call to untyped |
3334
| test_types.rb:46:21:46:21 | T |
3435
| test_types.rb:46:21:46:28 | Array |
36+
| test_types.rb:46:21:46:36 | ...[...] |
3537
| test_types.rb:46:30:46:35 | Symbol |
3638
| test_types.rb:49:26:49:26 | T |
3739
| test_types.rb:49:26:49:46 | call to any |
@@ -100,6 +102,8 @@ parameterTypes
100102
| test_types.rb:30:7:30:54 | Pair | test_types.rb:33:29:33:34 | &block | test_types.rb:30:14:30:54 | call to nilable |
101103
| test_types.rb:37:7:37:15 | Pair | test_types.rb:41:18:41:18 | a | test_types.rb:37:10:37:15 | String |
102104
| test_types.rb:38:7:38:54 | Pair | test_types.rb:41:21:41:26 | &block | test_types.rb:38:14:38:54 | call to returns |
105+
| test_types.rb:43:16:43:50 | Pair | test_types.rb:44:17:44:22 | **hash | test_types.rb:43:22:43:50 | ...[...] |
106+
| test_types.rb:46:16:46:36 | Pair | test_types.rb:47:25:47:28 | *arr | test_types.rb:46:21:46:36 | ...[...] |
103107
| test_types.rb:49:16:49:46 | Pair | test_types.rb:50:14:50:21 | new_name | test_types.rb:49:26:49:46 | call to any |
104108
| test_types.rb:52:16:52:32 | Pair | test_types.rb:53:24:53:28 | value | test_types.rb:52:23:52:32 | Boolean |
105109
procParameterTypes

0 commit comments

Comments
 (0)