diff --git a/lib/typeprof/import.rb b/lib/typeprof/import.rb index c0d48d4bf..8cdb9f5cc 100644 --- a/lib/typeprof/import.rb +++ b/lib/typeprof/import.rb @@ -561,7 +561,14 @@ def import(explicit = false) members = cdef[:members] name = classpath.last - superclass = path_to_klass(superclass) if superclass + if superclass + if superclass == classpath + # Remove the second to last element so that lookup happens in the parent + superclass = superclass.dup + superclass.delete_at(-2) + end + superclass = path_to_klass(superclass) + end base_klass = path_to_klass(classpath[0..-2]) klass, = @scratch.get_constant(base_klass, name) diff --git a/smoke/rbs-matching-superclass.rb b/smoke/rbs-matching-superclass.rb new file mode 100644 index 000000000..4adbc61c6 --- /dev/null +++ b/smoke/rbs-matching-superclass.rb @@ -0,0 +1,4 @@ +class Foo +end +__END__ +# Classes diff --git a/smoke/rbs-matching-superclass.rbs b/smoke/rbs-matching-superclass.rbs new file mode 100644 index 000000000..efd3a839d --- /dev/null +++ b/smoke/rbs-matching-superclass.rbs @@ -0,0 +1,7 @@ +class Foo +end + +class Bar + class Foo < Foo + end +end