mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-05-06 05:10:22 +07:00
return Object if denotable type is needed for functional expression (e.g. lambda expression) type
EA-75552 - IOE: PsiElementFactoryImpl.createField
This commit is contained in:
@@ -37,6 +37,7 @@ import com.intellij.psi.codeStyle.VariableKind;
|
||||
import com.intellij.psi.util.PropertyUtil;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.refactoring.util.RefactoringUtil;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
@@ -215,7 +216,7 @@ public class CreatePropertyFromUsageFix extends CreateFromUsageBaseFix implement
|
||||
expectedTypes = new PsiType[]{type};
|
||||
}
|
||||
else {
|
||||
type = myMethodCall.getArgumentList().getExpressions()[0].getType();
|
||||
type = RefactoringUtil.getTypeByExpression(myMethodCall.getArgumentList().getExpressions()[0]);
|
||||
if (type == null || PsiType.NULL.equals(type)) type = PsiType.getJavaLangObject(manager, myMethodCall.getResolveScope());
|
||||
expectedTypes = new PsiType[]{type};
|
||||
}
|
||||
|
||||
@@ -416,6 +416,12 @@ public class RefactoringUtil {
|
||||
}
|
||||
}
|
||||
|
||||
if (type instanceof PsiLambdaParameterType ||
|
||||
type instanceof PsiLambdaExpressionType ||
|
||||
type instanceof PsiMethodReferenceType) {
|
||||
type = factory.createTypeByFQClassName(CommonClassNames.JAVA_LANG_OBJECT, expr.getResolveScope());
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
// "Create property" "true"
|
||||
class Calculator {
|
||||
private Object i;
|
||||
|
||||
{
|
||||
setI(() -> {});
|
||||
}
|
||||
|
||||
public void setI(Object i) {
|
||||
this.i = i;
|
||||
}
|
||||
|
||||
public Object getI() {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
// "Create property" "true"
|
||||
class Calculator {
|
||||
{
|
||||
set<caret>I(() -> {});
|
||||
}
|
||||
}
|
||||
@@ -27,6 +27,6 @@ public class CreatePropertyFromUsageTest extends LightQuickFixParameterizedTestC
|
||||
|
||||
@Override
|
||||
protected LanguageLevel getLanguageLevel() {
|
||||
return LanguageLevel.JDK_1_5;
|
||||
return LanguageLevel.JDK_1_8;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user