mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
fix g++ test: allow partial argument->parameter mapping
This commit is contained in:
+10
-7
@@ -125,7 +125,7 @@ public class GrClosureSignatureUtil {
|
||||
}
|
||||
|
||||
public static boolean isSignatureApplicable(GrClosureSignature signature, PsiType[] args, GroovyPsiElement context) {
|
||||
if (mapArgTypesToParameters(signature, args, context) != null) return true;
|
||||
if (mapArgTypesToParameters(signature, args, context, false) != null) return true;
|
||||
|
||||
if (args.length == 1) {
|
||||
final GrClosureParameter[] parameters = signature.getParameters();
|
||||
@@ -133,27 +133,30 @@ public class GrClosureSignatureUtil {
|
||||
PsiType arg = args[0];
|
||||
if (arg instanceof GrTupleType) {
|
||||
args = ((GrTupleType)arg).getComponentTypes();
|
||||
if (mapArgTypesToParameters(signature, args, context) != null) return true;
|
||||
if (mapArgTypesToParameters(signature, args, context, false) != null) return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static ArgInfo<PsiType>[] mapArgTypesToParameters(GrClosureSignature signature, PsiType[] args, GroovyPsiElement context) {
|
||||
return mapParametersToArguments(signature, args, (Function<PsiType, PsiType>)Function.ID, context);
|
||||
public static ArgInfo<PsiType>[] mapArgTypesToParameters(GrClosureSignature signature,
|
||||
PsiType[] args,
|
||||
GroovyPsiElement context,
|
||||
boolean partial) {
|
||||
return mapParametersToArguments(signature, args, (Function<PsiType, PsiType>)Function.ID, context, partial);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static <Arg> ArgInfo<Arg>[] mapParametersToArguments(GrClosureSignature signature,
|
||||
Arg[] args,
|
||||
Function<Arg, PsiType> typeComputer,
|
||||
GroovyPsiElement context) {
|
||||
GroovyPsiElement context, boolean partial) {
|
||||
GrClosureParameter[] params = signature.getParameters();
|
||||
if (args.length > params.length && !signature.isVarargs()) return null;
|
||||
int optional = getOptionalParamCount(signature, false);
|
||||
int notOptional = params.length - optional;
|
||||
if (signature.isVarargs()) notOptional--;
|
||||
if (notOptional > args.length) return null;
|
||||
if (notOptional > args.length && !partial) return null;
|
||||
|
||||
final ArgInfo<Arg>[] map = mapSimple(params, args, typeComputer, context);
|
||||
if (map != null) return map;
|
||||
@@ -374,7 +377,7 @@ public class GrClosureSignatureUtil {
|
||||
public PsiType fun(InnerArg o) {
|
||||
return o.type;
|
||||
}
|
||||
}, list);
|
||||
}, list, false);
|
||||
if (innerMap == null) return null;
|
||||
|
||||
ArgInfo<PsiElement>[] map = new ArgInfo[innerMap.length];
|
||||
|
||||
+14
-8
@@ -138,7 +138,7 @@ public class MethodResolverProcessor extends ResolverProcessor {
|
||||
final GrClosureParameter[] params = signature.getParameters();
|
||||
|
||||
final GrClosureSignatureUtil.ArgInfo<PsiType>[] argInfos =
|
||||
GrClosureSignatureUtil.mapArgTypesToParameters(erasedSignature, argTypes, (GroovyPsiElement)myPlace);
|
||||
GrClosureSignatureUtil.mapArgTypesToParameters(erasedSignature, argTypes, (GroovyPsiElement)myPlace, myAllVariants);
|
||||
if (argInfos == null) return partialSubstitutor;
|
||||
|
||||
int max = Math.max(params.length, argTypes.length);
|
||||
@@ -147,15 +147,21 @@ public class MethodResolverProcessor extends ResolverProcessor {
|
||||
PsiType[] argumentTypes = new PsiType[max];
|
||||
int i = 0;
|
||||
for (int paramIndex = 0; paramIndex < argInfos.length; paramIndex++) {
|
||||
GrClosureSignatureUtil.ArgInfo<PsiType> argInfo = argInfos[paramIndex];
|
||||
final List<PsiType> psiTypes = argInfo.args;
|
||||
PsiType paramType = params[paramIndex].getType();
|
||||
if (argInfo.isMultiArg) {
|
||||
if (paramType instanceof PsiArrayType) paramType = ((PsiArrayType)paramType).getComponentType();
|
||||
}
|
||||
for (PsiType type : psiTypes) {
|
||||
|
||||
GrClosureSignatureUtil.ArgInfo<PsiType> argInfo = argInfos[paramIndex];
|
||||
if (argInfo != null) {
|
||||
if (argInfo.isMultiArg) {
|
||||
if (paramType instanceof PsiArrayType) paramType = ((PsiArrayType)paramType).getComponentType();
|
||||
}
|
||||
for (PsiType type : argInfo.args) {
|
||||
argumentTypes[i] = handleConversion(paramType, type);
|
||||
parameterTypes[i] = paramType;
|
||||
i++;
|
||||
}
|
||||
} else {
|
||||
parameterTypes[i] = paramType;
|
||||
argumentTypes[i] = handleConversion(paramType, type);
|
||||
argumentTypes[i] = PsiType.NULL;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user