Bug 223029 - Expressions view should use run-time type when calling methods
Summary: Expressions view should use run-time type when calling methods
Status: ASSIGNED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Debug (show other bugs)
Version: 3.3   Edit
Hardware: PC Linux
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: JDT-Debug-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-03-17 21:25 EDT by Sergey Prigogin CLA
Modified: 2008-04-21 16:45 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 Sergey Prigogin CLA 2008-03-17 21:25:48 EDT
Currently Expressions view doesn't call methods that are defined by the actual object's class, but do not exist in the declared type. For example, the Expressions view refuses to evaluate s.indexOf("abc"), if s is declared as Object, but contains a String. To evaluate this expression a user has to type ((String) s).indexOf("abc"). It gets even uglier if the run-time class is not imported in the current context. In this case the user has to use the fully qualified class name.

It would be nice if the Expressions view was smart and did the cast for the user. All it has to do is to always assume a cast to the actual type. For example, an expression s, where s is an object, should be treated as ((TheActualClassOf_s) s). 

This change would eliminate inequality between treatment of data members and methods. Currently the data members can be viewed without an explicit cast, but calling methods requires a cast.
Comment 1 Darin Wright CLA 2008-04-21 16:45:05 EDT
Not targeted for 3.4. This turns out to be more involved. Since an expression could contain multiple statements and could re-assign the value of a variable to another object, we cannot assume that any newly assigned value will be of the same type as the first value (and thus we cannot downcast/sepcialize the type of the object).