Returntype of PsiMethodCallExpression is Object
已回答
Hi,
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.
请先登录再写评论。
Push. Anyone has an idea?
Hi,
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:
Hi,
Did you set up the tests according to this doc section?
https://plugins.jetbrains.com/docs/intellij/testing-faq.html#how-to-test-a-jvm-language