Skip to content

Commit c04caec

Browse files
committed
Enhance scenario/rbs/param8.rb
1 parent c663795 commit c04caec

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

scenario/rbs/param8.rb

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,33 @@
11
## update: test.rbs
22
class Foo[X]
3+
def initialize: (X) -> void
34
@x: X
5+
# TODO: Currently, handling a type variable is immature.
6+
# Unless the explicit declaration of get_x, a bare type variable X is leaked.
7+
# A naive fix will bring huge performance penalties, so we need a good solution.
8+
def get_x: -> X
9+
end
10+
11+
## update: test.rb
12+
class Foo
13+
def initialize(x)
14+
@x = x
15+
end
16+
17+
def get_x
18+
@x
19+
end
20+
end
21+
22+
def check
23+
Foo.new(1).get_x
24+
end
25+
26+
## assert
27+
class Foo
28+
def initialize: (var[X]) -> (Object | var[X])
29+
def get_x: -> var[X]
30+
end
31+
class Object
32+
def check: -> Integer
433
end

0 commit comments

Comments
 (0)