GoPsiType type = builtinTypes[index];
if (!checkParametersExp(type, goExpr)){
result.addProblem(
goExpr,
GoBundle.message("warning.functioncall.type.mismatch", type.getText()),
ProblemHighlightType.GENERIC_ERROR_OR_WARNING, new CastTypeFix(goExpr, GoTypes.fromPsi(type)));
return;
}
}
}
return;
}
for (GoFunctionParameter functionParameter : goFunctionDeclaration.getParameters()) {
if (index >= goExprs.length)
return;
GoPsiType type = functionParameter.getType();
String typeName = type != null ? type.getText() : "";
if (functionParameter.isVariadic()) {
if (call.isCallWithVariadicParameter()){
GoExpr goExpr = goExprs[index];
GoType[] types = goExpr.getType();
if (types.length!=1){
result.addProblem(
goExpr,
GoBundle.message("warning.functioncall.type.mismatch", "[]"+typeName),
ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
return;
}
GoType exprType = types[0].underlyingType();
if (!(exprType instanceof GoTypeSlice)){
result.addProblem(
goExpr,
GoBundle.message("warning.functioncall.type.mismatch", "[]"+typeName),
ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
return;
}
//TODO test with assignable
if (!((GoTypeSlice) exprType).getElementType().isIdentical(GoTypes.fromPsi(type)) ) {
result.addProblem(
goExpr,
GoBundle.message("warning.functioncall.type.mismatch", "[]"+typeName),
ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
return;
}
}else {
for (; index < goExprs.length; index++) {
GoExpr goExpr = goExprs[index];
if (!checkParametersExp(functionParameter.getType(), goExpr)) {
result.addProblem(
goExpr,
GoBundle.message("warning.functioncall.type.mismatch", typeName),
ProblemHighlightType.GENERIC_ERROR_OR_WARNING, new CastTypeFix(goExpr, GoTypes.fromPsi(type)));
return;
}
}
}
} else {
GoLiteralIdentifier[] identifiers = functionParameter.getIdentifiers();
if (identifiers.length < 2) {
GoExpr goExpr = goExprs[index];
if (!checkParametersExp(functionParameter.getType(), goExpr)) {
result.addProblem(
goExpr,
GoBundle.message("warning.functioncall.type.mismatch", typeName),
ProblemHighlightType.GENERIC_ERROR_OR_WARNING, new CastTypeFix(goExpr, GoTypes.fromPsi(type)));
return;
}
index++;
} else {
for (GoLiteralIdentifier goLiteralIdentifier : identifiers) {
GoExpr goExpr = goExprs[index];
if (!checkParametersExp(functionParameter.getType(), goExpr)) {
result.addProblem(
goExpr,
GoBundle.message("warning.functioncall.type.mismatch", typeName),
ProblemHighlightType.GENERIC_ERROR_OR_WARNING, new CastTypeFix(goExpr, GoTypes.fromPsi(type)));
return;
}
index++;
}
}