get back old isDenotableType and deprecate it

This commit is contained in:
Roman.Ivanov
2018-06-01 10:37:01 +07:00
parent a71e9d7f12
commit 3842c10375
2 changed files with 12 additions and 4 deletions
@@ -321,9 +321,17 @@ public class PsiTypesUtil {
}
/**
* @param context in which type should be checked
* @return false if type is null or has no explicit canonical type representation (e. g. intersection type)
* Not compliant to specification, use {@link PsiTypesUtil#isDenotableType(PsiType, PsiElement)} instead
*/
@Deprecated
public static boolean isDenotableType(@Nullable PsiType type) {
return !(type instanceof PsiWildcardType || type instanceof PsiCapturedWildcardType);
}
/**
* @param context in which type should be checked
* @return false if type is null or has no explicit canonical type representation (e. g. intersection type)
*/
public static boolean isDenotableType(@Nullable PsiType type, @NotNull PsiElement context) {
if (type == null) return false;
PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(context.getProject());
@@ -161,9 +161,9 @@ object LambdaToAnonymousTransformer : PsiElementTransformer.Base() {
val interfaceMethod = LambdaUtil.getFunctionalInterfaceMethod(functionalInterfaceType)
if (interfaceMethod != null) {
val substitutor = LambdaUtil.getSubstitutor(interfaceMethod, PsiUtil.resolveGenericsClassInType(functionalInterfaceType))
if (interfaceMethod.getSignature(substitutor).parameterTypes.any { !PsiTypesUtil.isDenotableType(it, lambdaExpression) }) return false
if (interfaceMethod.getSignature(substitutor).parameterTypes.any { !PsiTypesUtil.isDenotableType(it) }) return false
val returnType = LambdaUtil.getFunctionalInterfaceReturnType(functionalInterfaceType)
return PsiTypesUtil.isDenotableType(returnType, lambdaExpression)
return PsiTypesUtil.isDenotableType(returnType)
}
}