Skip to content

Commit 3294aa1

Browse files
cleanup: Remove some TODOs and add a named FIXME for aliases.
1 parent b7abca4 commit 3294aa1

File tree

5 files changed

+37
-6
lines changed

5 files changed

+37
-6
lines changed

class_flatten/class_flatten.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ class ClassFlattenWalk {
111111
ast::MethodDef::ARGS_store args;
112112
args.emplace_back(ast::make_expression<ast::Local>(blkLoc, blkLocalVar));
113113

114-
// TODO(varun): What does classDef->declLoc correspond to?
115114
auto init = ast::make_expression<ast::MethodDef>(classDef->declLoc, classDef->declLoc, classDef->declLoc, sym,
116115
core::Names::staticInit(), std::move(args), std::move(inits),
117116
ast::MethodDef::Flags());

core/GlobalState.cc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1725,8 +1725,6 @@ void GlobalState::mangleRenameSymbolInternal(SymbolRef what, NameRef origName, U
17251725
}
17261726
case SymbolRef::Kind::Method:
17271727
what.asMethodRef().data(*this)->name = name;
1728-
// TODO(varun): This code path seems to be triggered when processing the stdlib.
1729-
// Should we be setting nameLoc here?
17301728
break;
17311729
case SymbolRef::Kind::FieldOrStaticField:
17321730
what.asFieldRef().data(*this)->name = name;
@@ -2347,7 +2345,7 @@ const vector<shared_ptr<File>> &GlobalState::getFiles() const {
23472345
MethodRef GlobalState::staticInitForClass(ClassOrModuleRef klass, Loc loc) {
23482346
auto prevCount = methodsUsed();
23492347
auto sym = enterMethodSymbol(loc, klass.data(*this)->singletonClass(*this), core::Names::staticInit(),
2350-
klass.data(*this)->loc().offsets()); // TODO(varun): Check if this is OK
2348+
klass.data(*this)->loc().offsets());
23512349
if (prevCount != methodsUsed()) {
23522350
auto blkLoc = core::Loc::none(loc.file());
23532351
auto &blkSym = enterMethodArgumentSymbol(blkLoc, sym, core::Names::blkArg());

resolver/resolver.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1874,6 +1874,7 @@ class ResolveTypeMembersAndFieldsWalk {
18741874
core::ClassOrModuleRef owner;
18751875
core::LocOffsets loc;
18761876
core::LocOffsets toNameLoc;
1877+
// FIXME[alias-support]: Add a fromNameLoc field here
18771878
core::NameRef toName;
18781879
core::NameRef fromName;
18791880
};
@@ -2439,8 +2440,8 @@ class ResolveTypeMembersAndFieldsWalk {
24392440
return;
24402441
}
24412442

2442-
// TODO(varun): is toNameLoc the right field?
2443-
auto alias = ctx.state.enterMethodSymbol(ctx.locAt(job.loc), job.owner, job.fromName, job.toNameLoc);
2443+
// FIXME[alias-support]: Use job.fromNameLoc here for the last argument.
2444+
auto alias = ctx.state.enterMethodSymbol(ctx.locAt(job.loc), job.owner, job.fromName, job.loc);
24442445
alias.data(ctx)->resultType = core::make_type<core::AliasType>(core::SymbolRef(toMethod));
24452446

24462447
// Add a fake keyword argument to remember the toName (for fast path hashing).

test/scip/testdata/alias.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# typed: true
2+
3+
class X
4+
alias_method :am_aaa, :aaa
5+
alias :a_aaa :aaa
6+
7+
def aaa
8+
puts "AAA"
9+
end
10+
11+
def check_alias
12+
return [am_aaa, a_aaa]
13+
end
14+
end

test/scip/testdata/alias.snapshot.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# typed: true
2+
3+
class X
4+
# ^ definition [..] X#
5+
alias_method :am_aaa, :aaa
6+
alias :a_aaa :aaa
7+
8+
def aaa
9+
# ^^^ definition [..] X#aaa().
10+
puts "AAA"
11+
end
12+
13+
def check_alias
14+
# ^^^^^^^^^^^ definition [..] X#check_alias().
15+
return [am_aaa, a_aaa]
16+
# ^^^^^^ reference [..] X#am_aaa().
17+
# ^^^^^ reference [..] X#a_aaa().
18+
end
19+
end

0 commit comments

Comments
 (0)