Returntype of PsiMethodCallExpression is Object Follow
i have the following PsiMethodCallExpression:
optObj.map(x -> new AnotherObject(anotherInput)).orElse(new AnotherObject())
When i call .getType(), the returnType is Object.
optObj is of type Optional.
Is there any way to resolve Object to "AnotherObject"?
PS doing resolveMethod().getReturnType() is get "T", since this is a generic method.
Please sign in to leave a comment.
Push. Anyone has an idea?
It should return the type from the
expression.getType(). I created a similar expression:
and it returns IntStream:
If it doesn't work, then please share the full context: implemented code and the example code it is tested on.
Hi, sorry for the late answer, yes you are correct that it works when running the plugin in "prod mode" via runIde gradle task.
In my tests this is resolved to Object. Do you know why this is not working as expected in my tests?
PS: in my tests i have a custom optional class which behaves exactly the same. I imported this optional class via
For the testbase i use:
Did you set up the tests according to this doc section?