Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 365152 - import static extension toString(Type x) favors Object.toString()
Summary: import static extension toString(Type x) favors Object.toString()
Status: CLOSED WONTFIX
Alias: None
Product: TMF
Classification: Modeling
Component: Xtext (show other bugs)
Version: 2.2.0   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-29 20:08 EST by McKinley CLA
Modified: 2017-09-19 17:29 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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