Skip to content

Commit 71eccc5

Browse files
committed
fix: don't choke on scala/Function.
This took me an embarrassingly long time to catch what was going on ha. But in the `SignatureFormatter` we special case things like `Function1` to ensure we don't print `(A) => B` and instead `A => B`. We do this by looking for symbols that start with `scala/Function`. However, the Scala codebase has a `scala/Function.` object that causes this logic to trip up. This change introduces another check to ensure that when we are in Scala and see a symbol starting with `scala/Function` that it's not `scala/Funtion.`. This should get indexing working on the Scala codebase again. Refs: #475
1 parent d54ebf2 commit 71eccc5

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

scip-semanticdb/src/main/java/com/sourcegraph/scip_semanticdb/SignatureFormatter.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ public class SignatureFormatter {
2323

2424
private static final Type NOTHING_SYMBOL = typeRef("scala/Nothing#");
2525
private static final String FUNCTION_SYMBOL_PREFIX = "scala/Function";
26+
// Special case scala/Function object to not confluce with Function1 for example
27+
private static final String FUNCTION_OBJECT = "scala/Function.";
2628
private static final String TUPLE_SYMBOL_PREFIX = "scala/Tuple";
2729
private static final String ARRAY_SYMBOL = "scala/Array#";
2830
private static final String ENUM_SYMBOL = "java/lang/Enum#";
@@ -557,7 +559,9 @@ private String formatType(Type type) {
557559
b.append(formatType(typeRef.getTypeArguments(0)));
558560
b.append("[]");
559561
}
560-
} else if (isScala && typeRef.getSymbol().startsWith(FUNCTION_SYMBOL_PREFIX)) {
562+
} else if (isScala
563+
&& typeRef.getSymbol().startsWith(FUNCTION_SYMBOL_PREFIX)
564+
&& !typeRef.getSymbol().startsWith(FUNCTION_OBJECT)) {
561565
int n = typeRef.getTypeArgumentsCount() - 1;
562566
if (n == 0) {
563567
// Special-case for Function1[A, B]: don't wrap `A` in parenthesis like this `(A) => B`

0 commit comments

Comments
 (0)