Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should set self_type to self #2029

Merged
merged 1 commit into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions core/module.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ class Module < Object
# or method `code' for Thing:Class
#
def class_eval: (String arg0, ?String filename, ?Integer lineno) -> untyped
| [U] () { (self m) -> U } -> U
| [U] () { (self m) [self: self] -> U } -> U

# <!-- rdoc-file=vm_eval.c -->
# Evaluates the given block in the context of the class/module. The method
Expand Down Expand Up @@ -1083,7 +1083,7 @@ class Module < Object
# or method `code' for Thing:Class
#
def module_eval: (String arg0, ?String filename, ?Integer lineno) -> untyped
| [U] () { (self m) -> U } -> U
| [U] () { (self m) [self: self] -> U } -> U

# <!--
# rdoc-file=vm_eval.c
Expand Down
7 changes: 7 additions & 0 deletions test/typecheck/eval/Steepfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
D = Steep::Diagnostic

target :test do
signature "."
check "."
configure_code_diagnostics(D::Ruby.all_error)
end
26 changes: 26 additions & 0 deletions test/typecheck/eval/test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
class Foo
def self.singleton
end

private

def private_method
end
end

module Bar
def self.singleton
end
end

Foo.class_eval do
singleton
end

Foo.new.instance_eval do
private_method
end

Bar.module_eval do
singleton
end
11 changes: 11 additions & 0 deletions test/typecheck/eval/test.rbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class Foo
def self.singleton: () -> void

private

def private_method: () -> void
end

module Bar
def self.singleton: () -> void
end