diff --git a/patches/api/Adventure.patch b/patches/api/Adventure.patch index 3c56008661..23c90c1382 100644 --- a/patches/api/Adventure.patch +++ b/patches/api/Adventure.patch @@ -3722,12 +3722,3 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 "Lorg/jetbrains/annotations/Nullable;", "Lorg/jetbrains/annotations/NotNull;", "Lorg/jetbrains/annotations/Contract;", -@@ -0,0 +0,0 @@ public class AnnotationTest { - return true; - } - -- private static boolean isWellAnnotated(@Nullable List annotations) { -+ private static boolean isWellAnnotated(@Nullable List annotations) { // Paper - allow children of AnnotationNode - if (annotations == null) { - return false; - } diff --git a/patches/api/Allow-use-of-TYPE_USE-annotations.patch b/patches/api/Allow-use-of-TYPE_USE-annotations.patch index 717483352a..e963a63588 100644 --- a/patches/api/Allow-use-of-TYPE_USE-annotations.patch +++ b/patches/api/Allow-use-of-TYPE_USE-annotations.patch @@ -9,11 +9,24 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/test/java/org/bukkit/AnnotationTest.java +++ b/src/test/java/org/bukkit/AnnotationTest.java @@ -0,0 +0,0 @@ public class AnnotationTest { - continue; } -- if (mustBeAnnotated(Type.getReturnType(method.desc)) && !isWellAnnotated(method.invisibleAnnotations)) { -+ if (mustBeAnnotated(Type.getReturnType(method.desc)) && !isWellAnnotated(method.invisibleAnnotations) && !isWellAnnotated(method.visibleTypeAnnotations) && !isWellAnnotated(method.invisibleTypeAnnotations)) { // Paper - also check (in)visible type annotations + 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"); } @@ -23,7 +36,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + dancing: // Paper for (int i = 0; i < paramTypes.length; i++) { if (mustBeAnnotated(paramTypes[i]) && !isWellAnnotated(method.invisibleParameterAnnotations == null ? null : method.invisibleParameterAnnotations[i])) { -+ // Paper start - wheeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee ++ // 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); @@ -36,3 +49,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 ParameterNode paramNode = parameters == null ? null : parameters.get(i); String paramName = paramNode == null ? null : paramNode.name; +@@ -0,0 +0,0 @@ public class AnnotationTest { + return true; + } + +- private static boolean isWellAnnotated(@Nullable List annotations) { ++ private static boolean isWellAnnotated(@Nullable List annotations) { // Paper + if (annotations == null) { + return false; + }