Skip to content

Commit c1b51bb

Browse files
committed
Fix ContextValue validation in the AP
1 parent 013703a commit c1b51bb

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/ap/java/org/spongepowered/plugin/processor/ListenerParameterAnnotation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ void validate(final ParameterContext ctx) {
6363
if (!contained.getModifiers().contains(Modifier.STATIC)) {
6464
ctx.logError("The @ContextValue annotation must refer to a static field", entry.getValue());
6565
}
66-
if (!ctx.types().isSubtype(contained.asType(), key.asType())) {
66+
if (!ctx.types().isSubtype(contained.asType(), ctx.types().erasure(key.asType()))) {
6767
ctx.logError("The @ContextValue annotation must refer to a field with type EventContextKey, but got '" + contained.asType() + "' instead", entry.getValue());
6868
}
6969
// validate field type?

src/main/java/org/spongepowered/api/event/filter/cause/ContextValue.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
import org.spongepowered.api.event.EventContext;
2828
import org.spongepowered.api.event.EventContextKey;
29+
import org.spongepowered.api.event.EventContextKeys;
2930

3031
import java.lang.annotation.ElementType;
3132
import java.lang.annotation.Retention;
@@ -46,6 +47,8 @@
4647
/**
4748
* Gets the name to use with the {@link EventContextKey}.
4849
*
50+
* <p>This must be a field in {@link EventContextKeys}.</p>
51+
*
4952
* @return The name to use
5053
*/
5154
String value();

0 commit comments

Comments
 (0)