diff --git a/lib/rbs/types.rb b/lib/rbs/types.rb index d1d32e271..1edcffa87 100644 --- a/lib/rbs/types.rb +++ b/lib/rbs/types.rb @@ -1427,6 +1427,7 @@ def to_s(level = 0) def each_type(&block) if block type.each_type(&block) + yield self_type if self_type self.block&.type&.each_type(&block) if self_type = self.block&.self_type yield self_type @@ -1467,7 +1468,7 @@ def has_classish_type? end def with_nonreturn_void? - if type.with_nonreturn_void? + if type.with_nonreturn_void? || self_type&.with_nonreturn_void? true else if block = block() diff --git a/test/rbs/types_test.rb b/test/rbs/types_test.rb index 60b4d9777..2cb01b316 100644 --- a/test/rbs/types_test.rb +++ b/test/rbs/types_test.rb @@ -40,6 +40,7 @@ def test_has_self_type? "[self]", "Array[self]", "^(self) -> void", + "^() [self: self] -> void", "^() { () [self: self] -> void } -> void" ].each do |str| type = parse_type(str) @@ -61,6 +62,7 @@ def test_has_classish_type? "class", "class?", "^() -> instance", + "^() [self: class] -> void", "^() { () [self: class] -> void } -> void" ].each do |str| type = parse_type(str) @@ -80,7 +82,8 @@ def test_with_nonreturn_void? [ "void", "[void]", - "void?" + "void?", + "^() [self: void] -> void" ].each do |str| type = parse_type(str) assert_predicate type, :with_nonreturn_void?