Skip to content
Open
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
6 changes: 5 additions & 1 deletion lib/typeprof/core/ast/module.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,11 @@ def subnodes
def define0(genv)
if @static_cpath && @superclass_cpath
const = @superclass_cpath.define(genv)
const.followers << genv.resolve_cpath(@static_cpath) if const
if const
const.exclude_cpath = @static_cpath
const.refresh(genv)
const.followers << genv.resolve_cpath(@static_cpath)
end
end
super(genv)
end
Expand Down
11 changes: 11 additions & 0 deletions lib/typeprof/core/env/static_read.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ def initialize(name)
@name = name
@followers = Set[]
@source_modules = Set[]
@exclude_cpath = nil
end

attr_reader :name, :followers
attr_accessor :exclude_cpath

def propagate(genv)
@followers.each do |follower|
Expand Down Expand Up @@ -68,6 +70,10 @@ def initialize(genv, name, cref, strict_const_scope)
def on_scope_updated(genv)
resolve(genv, @cref, @search_ancestors, false)
end

def refresh(genv)
on_scope_updated(genv)
end
end

class ScopedStaticRead < StaticRead
Expand All @@ -85,6 +91,10 @@ def on_cbase_updated(genv)
resolution_failed(genv)
end
end

def refresh(genv)
on_cbase_updated(genv)
end
end

module ConstRead
Expand All @@ -93,6 +103,7 @@ def check_module(genv, mod)
if cdef && cdef.exist?
inner_mod = genv.resolve_cpath(mod.cpath + [@name]) # TODO
cpath = inner_mod.exist? ? inner_mod.cpath : nil
return false if @exclude_cpath && cpath == @exclude_cpath
update_module(genv, cpath, cdef)
return true
end
Expand Down
19 changes: 19 additions & 0 deletions scenario/regressions/superclass-self-reference.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
## 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

## assert: test.rb
class Object
def call: -> Integer
end