Refactor method resolution code out of Compiler and into Reflector

Description

Issues:

  1. Code for obtaining method/constructor instances is duplicated across the Compiler

  2. Code for resolving a preferred overloaded method lives in the Compiler

By consolidating the duplicated code, moving the reflection-related parts into Reflector, and providing a straightforward API, it should be easier to read and understand the method resolution process. Further, improvements to (e.g., CLJ-445) the mechanism for reflecting on class members can largely be isolated from the Compiler. And the few points of coordination (e.g., Compiler emitting same arg and return types as Reflector does when invoking) can be clearly identified and documented.

Environment

None

Activity

Show:
Michael Blume
January 30, 2015, 7:44 PM

To summarize perhaps a bit better, there's some code that this patch moves from Compiler into its own method in Reflector that was relatively easy to move back when this patch was first authored, but now has some extra reflection-warning-printing that wants to know row/column stuff that's available in its original location in Compiler but not in the extracted function in Reflector. We could pass row/column into that method, but then we'd have to eventually pass them through a few other Reflector methods and that sounds ugly. Alternately we could pass some indication out of that reflector method of how exactly it failed to find a method so that the Compiler method could make its own decisions about how to print the failure, but that would involve either inventing exceptions or some sort of Success/Failure ADT.

Nicola Mometto
January 30, 2015, 7:45 PM

Michael, what about doing

inside the block starting with

in Compiler.java?

Michael Blume
January 30, 2015, 8:08 PM

That makes sense, it runs into trouble later when Reflector.getMethods gets replaced with the private getMethodsForName but maybe we can hack around that...

Michael Blume
January 30, 2015, 8:27 PM

No, still doesn't print out the right warnings

Michael Blume
January 30, 2015, 8:29 PM

Assignee

Unassigned

Reporter

Alexander Taggart

Labels

None

Approval

None

Patch

None

Priority

Major