Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 365152

Summary: import static extension toString(Type x) favors Object.toString()
Product: [Modeling] TMF Reporter: McKinley <mckinley1411>
Component: XtextAssignee: Project Inbox <tmf.xtext-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: enhancement    
Priority: P3 CC: sven.efftinge
Version: 2.2.0   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description McKinley CLA 2011-11-29 20:08:25 EST
Build Identifier: 2.2.0.v201111291107

While using a static extension import of org.apache.http.util.EntityUtils, the following method is not usable from within Xtend:
public static String toString(final HttpEntity entity)

It favors the toString method of Object.

However, the following is usable as an extension method from Xtend:
public static String toString(final HttpEntity entity, final String defaultCharset)



Reproducible: Always

Steps to Reproduce:
See above
Comment 1 McKinley CLA 2011-11-30 01:05:07 EST
Hmm, if this bug is to be fixed, would it be possible to have println(entity) call EntityUtils.toString(entity) automatically? Perhaps a new type of import extension would be needed to indicate that a particular static method should be the default for a particular signature like toString().
Comment 2 Sven Efftinge CLA 2011-11-30 02:20:03 EST
You are asking for extension methods having precedence over real members. This would make it impossible to call the real members. Why couldn't you give the extension method a different name?

Regarding the second request: Extension methods are lexically scoped, that is they are only available where they are imported. Println being just a plain method doesn't (and shouldn't) know or care from what context it is called.

I fully understand your use case and see how nice it was if it were supported, but it would have too many unwished side effects.
Comment 3 Karsten Thoms CLA 2017-09-19 17:18:12 EDT
Closing all bugs that were set to RESOLVED before Neon.0
Comment 4 Karsten Thoms CLA 2017-09-19 17:29:32 EDT
Closing all bugs that were set to RESOLVED before Neon.0