File tree 1 file changed +10
-10
lines changed
1 file changed +10
-10
lines changed Original file line number Diff line number Diff line change @@ -2039,14 +2039,15 @@ def resolve(type_parser, loader)
2039
2039
2040
2040
def instance? ( o , guard = nil )
2041
2041
return false unless o . is_a? ( Array )
2042
- # compute the tuple's min/max size, and check if that size matches
2043
- size_t = size_type || PIntegerType . new ( *size_range )
2044
-
2045
- return false unless size_t . instance? ( o . size , guard )
2046
- o . each_with_index do |element , index |
2047
- return false unless ( types [ index ] || types [ -1 ] ) . instance? ( element , guard )
2042
+ if @size_type
2043
+ return false unless @size_type . instance? ( o . size , guard )
2044
+ else
2045
+ return false unless @types . empty? || @types . size == o . size
2046
+ end
2047
+ index = -1
2048
+ @types . empty? || o . all? do |element |
2049
+ @types . fetch ( index += 1 ) { @types . last } . instance? ( element , guard )
2048
2050
end
2049
- true
2050
2051
end
2051
2052
2052
2053
def iterable? ( guard = nil )
@@ -2757,10 +2758,9 @@ def instance?(o, guard = nil)
2757
2758
end
2758
2759
2759
2760
def really_instance? ( o , guard = nil )
2760
- @types . inject ( -1 ) do |memo , type |
2761
+ @types . reduce ( -1 ) do |memo , type |
2761
2762
ri = type . really_instance? ( o , guard )
2762
- memo = ri if ri > memo
2763
- memo
2763
+ ri > memo ? ri : memo
2764
2764
end
2765
2765
end
2766
2766
You can’t perform that action at this time.
0 commit comments