scala-ide / scala-search

Next Scala Search Engine
6 stars 10 forks source link

Fix for overloaded method symbols #45

Closed mads-hartmann closed 11 years ago

mads-hartmann commented 11 years ago

When asking for the type of a position that contains an invocation of an overloaded method we would sometimes get an overloaded method symbol from the compiler rather than the symbol of the precise method that was being invoked.

The problem is that askTypeAt only returns the smallest fully attributed tree that encloses a given position. Consider the following example

def askOption[A](op: () => A): Option[A] = askOption(op, 10000)
def askOption[A](op: () => A, timeout: Int): Option[A] = None

askOption { () =>
  ...
}

If the position is at the beginning of the askOption identifier (the invocation) then the presentation compiler will only type-check the receiver (the Select node) and not the arguments and thus will not resolve the overloaded method.

We fix this by asking the compiler to type-check more of the tree using a RangePosition.

Fixes #38

mads-hartmann commented 11 years ago

@dragos Probably easiest if you're the one to review this one given that you already know the problem and the solution ;)

mads-hartmann commented 11 years ago

@dragos Pushed some changes so it now uses a subclass of Locator to find the TypeApply node if it exists. Also improved the inline documentation and tried to make the code a bit more clear

dragos commented 11 years ago

Other than the isEligible, LGTM!