diff --git a/scip_indexer/SCIPIndexer.cc b/scip_indexer/SCIPIndexer.cc index 3f3e4bbf2..a3a97254a 100644 --- a/scip_indexer/SCIPIndexer.cc +++ b/scip_indexer/SCIPIndexer.cc @@ -477,7 +477,7 @@ class SCIPState { ast::ExpressionPtr &constantLitExpr) { auto *expr = &constantLitExpr; while (auto *constantLit = ast::cast_tree(*expr)) { - if (constantLit->symbol.exists() && constantLit->symbol.asClassOrModuleRef().exists()) { + if (constantLit->symbol.exists() && constantLit->symbol.isClassOrModule() && constantLit->symbol.asClassOrModuleRef().exists()) { core::Context ctx(gs, constantLit->symbol, file); auto status = this->saveReference(ctx, GenericSymbolRef::classOrModule(constantLit->symbol), /*overrideType*/ std::nullopt, constantLit->loc, 0); diff --git a/test/scip/testdata/inheritance.rb b/test/scip/testdata/inheritance.rb index ccbd2c8ec..4b16003f8 100644 --- a/test/scip/testdata/inheritance.rb +++ b/test/scip/testdata/inheritance.rb @@ -47,3 +47,7 @@ def write_f_plus_1(a) end end +Z5 = Object +class Z6 < Z5 +end + diff --git a/test/scip/testdata/inheritance.snapshot.rb b/test/scip/testdata/inheritance.snapshot.rb index dc51d5d52..ef7ee4b72 100644 --- a/test/scip/testdata/inheritance.snapshot.rb +++ b/test/scip/testdata/inheritance.snapshot.rb @@ -89,3 +89,12 @@ def write_f_plus_1(a) end end + Z5 = Object +#^^ definition [..] Z5. +#relation reference=[..] Object# +#^^^^^^^^^^^ reference [..] Z5. +# ^^^^^^ reference [..] Object# + class Z6 < Z5 +# ^^ definition [..] Z6# + end +