Skip to content

Commit

Permalink
Merge pull request #493 from ckipp01/darnFunctions
Browse files Browse the repository at this point in the history
  • Loading branch information
olafurpg authored Aug 22, 2022
2 parents d54ebf2 + 46ef27e commit d582189
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public class SignatureFormatter {

private static final Type NOTHING_SYMBOL = typeRef("scala/Nothing#");
private static final String FUNCTION_SYMBOL_PREFIX = "scala/Function";
// Special case scala/Function object to not conflict with Function1 for example
private static final String FUNCTION_OBJECT = "scala/Function.";
private static final String TUPLE_SYMBOL_PREFIX = "scala/Tuple";
private static final String ARRAY_SYMBOL = "scala/Array#";
private static final String ENUM_SYMBOL = "java/lang/Enum#";
Expand Down Expand Up @@ -557,7 +559,10 @@ private String formatType(Type type) {
b.append(formatType(typeRef.getTypeArguments(0)));
b.append("[]");
}
} else if (isScala && typeRef.getSymbol().startsWith(FUNCTION_SYMBOL_PREFIX)) {
} else if (isScala
&& typeRef.getSymbol().startsWith(FUNCTION_SYMBOL_PREFIX)
&& typeRef.getTypeArgumentsCount() > 0
&& !typeRef.getSymbol().startsWith(FUNCTION_OBJECT)) {
int n = typeRef.getTypeArgumentsCount() - 1;
if (n == 0) {
// Special-case for Function1[A, B]: don't wrap `A` in parenthesis like this `(A) => B`
Expand Down

0 comments on commit d582189

Please sign in to comment.