mirror of
https://github.com/PaperMC/Paper.git
synced 2024-09-06 11:58:10 +02:00
61 lines
3.5 KiB
Diff
61 lines
3.5 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Riley Park <riley.park@meino.net>
|
|
Date: Mon, 21 Jun 2021 09:51:29 -0700
|
|
Subject: [PATCH] Allow use of TYPE_USE annotations
|
|
|
|
|
|
diff --git a/src/test/java/org/bukkit/AnnotationTest.java b/src/test/java/org/bukkit/AnnotationTest.java
|
|
index 0c7377247ad9251c9e498039511e7220370aba2d..8d14d81c078d29781591e0ce96ea80338565e42b 100644
|
|
--- a/src/test/java/org/bukkit/AnnotationTest.java
|
|
+++ b/src/test/java/org/bukkit/AnnotationTest.java
|
|
@@ -67,14 +67,40 @@ public class AnnotationTest {
|
|
}
|
|
|
|
if (mustBeAnnotated(Type.getReturnType(method.desc)) && !isWellAnnotated(method.invisibleAnnotations)) {
|
|
+ // Paper start
|
|
+ boolean warn = true;
|
|
+ if (isWellAnnotated(method.visibleTypeAnnotations)) {
|
|
+ warn = false;
|
|
+ } else if (method.invisibleTypeAnnotations != null) {
|
|
+ dance: for (final org.objectweb.asm.tree.TypeAnnotationNode invisibleTypeAnnotation : method.invisibleTypeAnnotations) {
|
|
+ final org.objectweb.asm.TypeReference ref = new org.objectweb.asm.TypeReference(invisibleTypeAnnotation.typeRef);
|
|
+ if (ref.getSort() == org.objectweb.asm.TypeReference.METHOD_RETURN && java.util.Arrays.binarySearch(ACCEPTED_ANNOTATIONS, invisibleTypeAnnotation.desc) >= 0) {
|
|
+ warn = false;
|
|
+ break dance; // cha cha real smooth
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+ if (warn)
|
|
+ // Paper end
|
|
warn(errors, clazz, method, "return value");
|
|
}
|
|
|
|
Type[] paramTypes = Type.getArgumentTypes(method.desc);
|
|
List<ParameterNode> parameters = method.parameters;
|
|
|
|
+ dancing: // Paper
|
|
for (int i = 0; i < paramTypes.length; i++) {
|
|
if (mustBeAnnotated(paramTypes[i]) && !isWellAnnotated(method.invisibleParameterAnnotations == null ? null : method.invisibleParameterAnnotations[i])) {
|
|
+ // Paper start
|
|
+ if (method.invisibleTypeAnnotations != null) {
|
|
+ for (final org.objectweb.asm.tree.TypeAnnotationNode invisibleTypeAnnotation : method.invisibleTypeAnnotations) {
|
|
+ final org.objectweb.asm.TypeReference ref = new org.objectweb.asm.TypeReference(invisibleTypeAnnotation.typeRef);
|
|
+ if (ref.getSort() == org.objectweb.asm.TypeReference.METHOD_FORMAL_PARAMETER && ref.getTypeParameterIndex() == i && java.util.Arrays.binarySearch(ACCEPTED_ANNOTATIONS, invisibleTypeAnnotation.desc) >= 0) {
|
|
+ continue dancing;
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+ // Paper end
|
|
ParameterNode paramNode = parameters == null ? null : parameters.get(i);
|
|
String paramName = paramNode == null ? null : paramNode.name;
|
|
|
|
@@ -174,7 +200,7 @@ public class AnnotationTest {
|
|
return true;
|
|
}
|
|
|
|
- private static boolean isWellAnnotated(@Nullable List<AnnotationNode> annotations) {
|
|
+ private static boolean isWellAnnotated(@Nullable List<? extends AnnotationNode> annotations) { // Paper
|
|
if (annotations == null) {
|
|
return false;
|
|
}
|