Skip to content

Commit 393e2dd

Browse files
authored
Merge pull request #2192 from ksss/validate-proc-self-type
Should validate self-type on Proc
2 parents 493012d + bb6b6ee commit 393e2dd

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

lib/rbs/types.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1427,6 +1427,7 @@ def to_s(level = 0)
14271427
def each_type(&block)
14281428
if block
14291429
type.each_type(&block)
1430+
yield self_type if self_type
14301431
self.block&.type&.each_type(&block)
14311432
if self_type = self.block&.self_type
14321433
yield self_type
@@ -1467,7 +1468,7 @@ def has_classish_type?
14671468
end
14681469

14691470
def with_nonreturn_void?
1470-
if type.with_nonreturn_void?
1471+
if type.with_nonreturn_void? || self_type&.with_nonreturn_void?
14711472
true
14721473
else
14731474
if block = block()

test/rbs/types_test.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ def test_has_self_type?
4040
"[self]",
4141
"Array[self]",
4242
"^(self) -> void",
43+
"^() [self: self] -> void",
4344
"^() { () [self: self] -> void } -> void"
4445
].each do |str|
4546
type = parse_type(str)
@@ -61,6 +62,7 @@ def test_has_classish_type?
6162
"class",
6263
"class?",
6364
"^() -> instance",
65+
"^() [self: class] -> void",
6466
"^() { () [self: class] -> void } -> void"
6567
].each do |str|
6668
type = parse_type(str)
@@ -80,7 +82,8 @@ def test_with_nonreturn_void?
8082
[
8183
"void",
8284
"[void]",
83-
"void?"
85+
"void?",
86+
"^() [self: void] -> void"
8487
].each do |str|
8588
type = parse_type(str)
8689
assert_predicate type, :with_nonreturn_void?

0 commit comments

Comments
 (0)