Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix - Annotation processor wrong array dimension #107

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019 Sygic a.s. All rights reserved.
* Copyright (c) 2020 Sygic a.s. All rights reserved.
*
* This project is licensed under the MIT License.
*
Expand Down Expand Up @@ -260,10 +260,11 @@ public boolean process(final Set<? extends TypeElement> annotations, final Round

cb.add("\n");

cb.addStatement("final $1T[] parameters = new $1T[constructorAssistedParameters.size()]", Object.class);
cb.addStatement("final $1T[][] parameters = new $1T[constructorAssistedParameters.size()][]", Object.class);
cb.beginControlFlow("for ($T v = 0; v < constructorAssistedParameters.size(); v++)", int.class);
cb.addStatement("final $T[] entry = constructorAssistedParameters.get(v)", Class.class);
cb.addStatement("final $T[] nullableInfo = constructorAssistedParametersNullability.get(v)", Boolean.class);
cb.addStatement("parameters[v] = new $T[entry.length]", Object.class);
cb.addStatement("boolean allNullable = true");
cb.beginControlFlow("for (final $T nullable : nullableInfo)", Boolean.class);
cb.beginControlFlow("if (!nullable)");
Expand All @@ -285,7 +286,7 @@ public boolean process(final Set<? extends TypeElement> annotations, final Round
cb.addStatement("continue");
cb.endControlFlow();
cb.beginControlFlow("if (cls.isInstance(" + ASSISTED_PARAMETER_NAME + "[k]))");
cb.addStatement("parameters[i] = assistedValues[k]");
cb.addStatement("parameters[v][i] = assistedValues[k]");
cb.addStatement("k++");
cb.addStatement("continue");
cb.endControlFlow();
Expand All @@ -294,7 +295,7 @@ public boolean process(final Set<? extends TypeElement> annotations, final Round
cb.addStatement("found = false");
cb.addStatement("break");
cb.endControlFlow();
cb.addStatement("parameters[i] = assistedValues[k]");
cb.addStatement("parameters[v][i] = assistedValues[k]");
cb.addStatement("k++");
cb.endControlFlow();
cb.beginControlFlow("if (found)");
Expand All @@ -318,7 +319,7 @@ public boolean process(final Set<? extends TypeElement> annotations, final Round
VariableElement parameter = nonAssistedParameters.get(j);
if (parameter == null) {
parameter = assistedParameters.get(j);
cb.add("($T)parameters[$L]", parameter.asType(), a++);
cb.add("($T)parameters[variant][$L]", parameter.asType(), a++);
} else {
cb.add("$N", parameter.getSimpleName());
}
Expand Down