Skip to content
Browse files

Fixed completion problem for overloaded method.

When trying to removed duplicate types, the code was also removing
overloaded method. Modified the check so it is more precise.
Added regression test.
Fix #1000654
  • Loading branch information...
1 parent 567510a commit 7517a037a7219eb494282247dd06df734c688c2b @skyluc skyluc committed Dec 4, 2011
View
9 org.scala-ide.sdt.core.tests/src/scala/tools/eclipse/completion/CompletionTests.scala
@@ -128,12 +128,19 @@ class CompletionTests {
* Test completion for 'any' Java type visible in the project
*/
@Test
- def ticket100476() {
+ def ticket1000476() {
val oraclePos4_26 = List("ArrayList", "ArrayLister")
val oraclePos6_33 = List("ArrayList")
val oraclePos11_16 = List("TreeSet")
runTest("ticket_1000476/Ticket1000476.scala", true)(oraclePos4_26, oraclePos6_33, oraclePos11_16)
}
+ @Test
+ def ticket1000654() {
+ val oraclePos10_13 = List("t654_a(String): Unit", "t654_a(Int): Unit")
+
+ runTest("ticket_1000654/Ticket1000654.scala", true)(oraclePos10_13)
+ }
+
}
View
12 ...scala-ide.sdt.core.tests/test-workspace/completion/src/ticket_1000654/Ticket1000654.scala
@@ -0,0 +1,12 @@
+package ticket_1000654
+
+class C {
+ def t654_a(i: Int)
+ def t654_a(s: String)
+}
+
+class Test1 {
+
+ new C().t654 /*!*/
+
+}
View
10 org.scala-ide.sdt.core/src/scala/tools/eclipse/completion/ScalaCompletions.scala
@@ -52,19 +52,21 @@ class ScalaCompletions extends HasLogger {
val buff = new mutable.ListBuffer[CompletionProposal]
- def alreadyListed(fullyQualifiedName: String) = buff.exists((completion) => fullyQualifiedName.equals(completion.fullyQualifiedName))
+ def isAlreadyListed(fullyQualifiedName: String, display: String) = buff.exists((completion) => fullyQualifiedName.equals(completion.fullyQualifiedName) && display == completion.display)
+ def isCompletionAlreadyListed(completion: CompletionProposal) = isAlreadyListed(completion.fullyQualifiedName, completion.display)
+
for (completions <- completed.get.left.toOption) {
compiler.askOption { () =>
for (completion <- completions) {
completion match {
case compiler.TypeMember(sym, tpe, accessible, inherited, viaView) if !sym.isConstructor && nameMatches(sym) =>
val completionProposal= compiler.mkCompletionProposal(start, sym, tpe, inherited, viaView)
- if (!alreadyListed(completionProposal.fullyQualifiedName))
+ if (!isCompletionAlreadyListed(completionProposal))
buff += completionProposal
case compiler.ScopeMember(sym, tpe, accessible, _) if !sym.isConstructor && nameMatches(sym) =>
val completionProposal= compiler.mkCompletionProposal(start, sym, tpe, false, compiler.NoSymbol)
- if (!alreadyListed(completionProposal.fullyQualifiedName))
+ if (!isCompletionAlreadyListed(completionProposal))
buff += completionProposal
case _ =>
}
@@ -102,7 +104,7 @@ class ScalaCompletions extends HasLogger {
logger.info("Found type: " + fullyQualifiedName)
- if (!alreadyListed(fullyQualifiedName)) {
+ if (!isAlreadyListed(fullyQualifiedName, simpleName)) {
logger.info("Adding type: " + fullyQualifiedName)
// if the type is not already in the completion list, add it
buff+= CompletionProposal(

0 comments on commit 7517a03

Please sign in to comment.
Something went wrong with that request. Please try again.