Skip to content

Commit

Permalink
Tolerate broken kapt stubs
Browse files Browse the repository at this point in the history
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=272957216
  • Loading branch information
cushon authored and cpovirk committed Oct 5, 2019
1 parent 2547614 commit c3e7469
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion java/com/google/turbine/binder/DisambiguateTypeAnnotations.java
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,12 @@ public static ImmutableList<AnnoInfo> groupRepeated(
for (AnnoInfo element : infos) {
elements.add(new TurbineAnnotationValue(element));
}
ClassSymbol container = env.get(symbol).annotationMetadata().repeatable();
TypeBoundClass info = env.get(symbol);
ClassSymbol container = info.annotationMetadata().repeatable();
if (container == null) {
if (isKotlinRepeatable(info)) {
continue;
}
AnnoInfo anno = infos.iterator().next();
throw TurbineError.format(
anno.source(), anno.position(), ErrorKind.NONREPEATABLE_ANNOTATION, symbol);
Expand All @@ -296,4 +300,17 @@ public static ImmutableList<AnnoInfo> groupRepeated(
}
return result.build();
}

// Work-around for https://youtrack.jetbrains.net/issue/KT-34189.
// Kotlin stubs include repeated annotations that are valid in Kotlin (i.e. meta-annotated with
// @kotlin.annotation.Repeatable), even though they are invalid Java.
// TODO(b/142002426): kill this with fire
static boolean isKotlinRepeatable(TypeBoundClass info) {
for (AnnoInfo metaAnno : info.annotations()) {
if (metaAnno.sym().binaryName().equals("kotlin/annotation/Repeatable")) {
return true;
}
}
return false;
}
}

0 comments on commit c3e7469

Please sign in to comment.