Bug 165900 - [select] Incoherent behavior when there is ambiguous methods
Summary: [select] Incoherent behavior when there is ambiguous methods
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.3   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.3 M4   Edit
Assignee: David Audel CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-11-27 06:29 EST by David Audel CLA
Modified: 2007-01-19 22:14 EST (History)
1 user (show)

See Also:


Attachments
Proposed fix (32.64 KB, patch)
2006-11-30 06:10 EST, David Audel CLA
no flags Details | Diff
Better fix (34.38 KB, patch)
2006-12-07 09:34 EST, David Audel CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description David Audel CLA 2006-11-27 06:29:02 EST
from bug 165701

Code select behavior is not the same inside code and javadoc with a similar test case

## test case 1: 2 nothing is proposed

public <T extends Date> T getMax(final Iterable<T> ip1) {
  return null;
}
public <T extends Number> T getMax(final Iterable<T> ip2) {
  return null;
}
public void bar(Iterable i) {
  getMax(i); // do code select here
}

## test case 2: 2 getMax methods are proposed

public <T extends Date> T getMax(final Iterable<T> ip1) {
  return null;
}
public <T extends Number> T getMax(final Iterable<T> ip2) {
  return null;
}
public void bar(Iterable<?> i) {
  getMax(i); // do code select here
}

test case 3: one method foo is proposed

public void foo(Number n) {}
public void foo(Integer i) {}
public void bar() {
  foo(null); // do code select here
}

test case 4: 2 getMax methods are proposed

public <T extends Date> T getMax(final Iterable<T> ip1) {
  return null;
}
public <T extends Number> T getMax(final Iterable<T> ip2) {
  return null;
}
/**
 * @see #getMax(Iterable)  // do code select here
 */
public void bar() {}
Comment 1 David Audel CLA 2006-11-28 07:41:49 EST
test case 5: nothing is proposed

public void foo(Date d) {}
public void foo(Integer i) {}
public void bar() {
  foo(null); // do code select here
}
Comment 2 David Audel CLA 2006-11-30 06:10:32 EST
Created attachment 54768 [details]
Proposed fix
Comment 3 David Audel CLA 2006-11-30 06:22:41 EST
Philippe - what do you think about this patch ? Especially about the changes in compiler (MessageSend, ProblemMethodBinding, Scope, CodeSnippetScope) which add a closest match for ambiguous methods.

All our tests succeed with this patch.
Comment 4 Philipe Mulet CLA 2006-12-07 06:15:07 EST
Patch looks good.
Comment 5 David Audel CLA 2006-12-07 09:34:07 EST
Created attachment 55230 [details]
Better fix

Add changes in JavadocMessageSend (thanks Frederic).
Comment 6 David Audel CLA 2006-12-07 09:52:42 EST
Released for 3.3M4.

Tests added
  ResolveTests#testAmbiguousMethod1()
  ResolveTests_1_5#test103() -> test106()

Test updated
  SelectionJavadocModelTests#testBug165794()
Comment 7 Olivier Thomann CLA 2006-12-11 14:43:20 EST
Verified for 3.3M4 with I20061211-1119