Introduce Variable to support object types

One thing that I constantly run into is the fact that IDEA's introduce variable functionality only supports the same class as "returned" by the statement. Very often the type is Object and then I have to go and manually change it to the actual class. Perhaps an example will make this more clear:

I have statement:

Now I run the introduce variable and the result is:
Object userDAO = context.getBean("userDAO");

Instead, I would like to change the object type in the dialog that pops up so that it would automatically generate something like:
UserDAO userDAO = (UserDAO) context.getBean("userDAO");

I think this is a very common situation and it would be nice if IDEA would handle it a bit more smoothly. IDEA could even check that the class specified is actually a valid subclass of the return type of the statement.

Please sign in to leave a comment.