Skip to content

Fix superclass constant resolution to avoid self-reference#373

Open
pvcresin wants to merge 1 commit intoruby:masterfrom
pvcresin:fix/superclass-self-reference
Open

Fix superclass constant resolution to avoid self-reference#373
pvcresin wants to merge 1 commit intoruby:masterfrom
pvcresin:fix/superclass-self-reference

Conversation

@pvcresin
Copy link
Contributor

This change fixes superclass constant resolution for nested class Foo < Foo so the resolver no longer picks the class currently being defined.
It introduces an exclusion cpath on StaticRead and applies it from ClassNode#define0 before re-resolving the superclass read.
A regression scenario was also added at scenario/regressions/superclass-self-reference.rb.

## update: model.rb
class Foo
  def value = 1
end

module Bar
  class Foo < Foo
  end
end

## update: test.rb
def call
  Bar::Foo.new.value
end

With this case, TypeProf now consistently infers def call: -> Integer instead of falling back to untyped.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments