Bug 174327 - [inline] inlining a parameterized method call may need explicit parameterization
Summary: [inline] inlining a parameterized method call may need explicit parameterization
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.3   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.3 M6   Edit
Assignee: Markus Keller CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 174436
Blocks:
  Show dependency tree
 
Reported: 2007-02-15 11:22 EST by Tom P. Eicher CLA
Modified: 2007-03-08 13:03 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tom P. Eicher CLA 2007-02-15 11:22:36 EST
3.3 M5

- Example taken from bug 174265: 

------- Try.java -----------
package org.example;

import java.util.Collections;
import java.util.Map;

public class Try {
    void caller() {
        Map<String, String> emptyMap = Collections.emptyMap();
        method(emptyMap);
    }

    void method(Map<String, String> map) {
    }
}
------------------------------

- inline "emptyMap"
> expected: the resulting code should compile and apparently needs explicit parameterization: 

  method(Collections.<String,String>emptyMap());

< actual: the emptyMap() call is inlined as is, resulting in a compile error.
Comment 1 Martin Aeschlimann CLA 2007-02-16 05:50:26 EST
hey tom! :-)
Comment 2 Markus Keller CLA 2007-02-16 08:56:24 EST
Darn! Nasty difference between assignment expression and method invocation parameter assignment, see JLS3 15.12.2.8: "If the method result occurs in a context where it will be subject to assignment conversion (ยง5.2) [... then add constraints based on the type of the assignee]".

The situation is hard to distinguish from e.g.
        method(Collections.synchronizedMap(emptyMap))
, since the compiler does the additional inference automatically and only returns the fully resolved binding.

Filed API request for compiler (bug 174436).
Comment 3 Markus Keller CLA 2007-02-23 14:03:34 EST
We should also have a quick fix for turning
    method(Collections.emptyMap());
into
    method(Collections.<String,String>emptyMap());

The quick fix will also have to do some guesswork for wildcards: E.g. with
    void method(Map<String, ?> map) { }
, the fix should be:
    method(Collections.<String, Object>emptyMap());
Comment 4 Markus Keller CLA 2007-03-08 13:03:48 EST
Fixed in HEAD. See bug 176734 for comment 3.