File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -330,7 +330,11 @@ def pop_ivar_narrowing(name)
330330
331331 def apply_ivar_narrowing ( genv , node , name , vtx )
332332 if @ivar_narrowings [ name ] && !@ivar_narrowings [ name ] . empty?
333- return @ivar_narrowings [ name ] . last . narrow ( genv , node , vtx )
333+ # Apply all accumulated narrowings in order
334+ @ivar_narrowings [ name ] . each do |narrowing |
335+ vtx = narrowing . narrow ( genv , node , vtx )
336+ end
337+ return vtx
334338 end
335339 vtx
336340 end
Original file line number Diff line number Diff line change 1+ ## update
2+ class Foo
3+ def initialize ( x )
4+ @x = x
5+ end
6+
7+ def accept_int ( x ) = nil
8+ def accept_str ( x ) = nil
9+ def accept_nil ( x ) = nil
10+
11+ def foo
12+ if @x
13+ if @x . is_a? ( String )
14+ accept_str ( @x )
15+ else
16+ accept_int ( @x )
17+ end
18+ else
19+ accept_nil ( @x )
20+ end
21+ end
22+ end
23+
24+ Foo . new ( 1 )
25+ Foo . new ( "" )
26+ Foo . new ( nil )
27+
28+ ## assert
29+ class Foo
30+ def initialize : ( ( Integer | String ) ?) -> ( Integer | String ) ?
31+ def accept_int : ( Integer ) -> nil
32+ def accept_str : ( String ) -> nil
33+ def accept_nil : ( nil ) -> nil
34+ def foo : -> nil
35+ end
You can’t perform that action at this time.
0 commit comments