diff options
Diffstat (limited to 'org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodBinding.java')
-rw-r--r-- | org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodBinding.java | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodBinding.java index b600a76fc2..352e279aa8 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodBinding.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodBinding.java @@ -13,6 +13,7 @@ * bug 365519 - editorial cleanup after bug 186342 and bug 365387 * bug 365662 - [compiler][null] warn on contradictory and redundant null annotations * bug 365531 - [compiler][null] investigate alternative strategy for internally encoding nullness defaults + * bug 388281 - [compiler][null] inheritance of null annotations as an option *******************************************************************************/ package org.eclipse.jdt.internal.compiler.lookup; @@ -452,10 +453,9 @@ public final char[] constantPoolName() { /** * After method verifier has finished, fill in missing @NonNull specification from the applicable default. */ -protected void fillInDefaultNonNullness() { +protected void fillInDefaultNonNullness(AbstractMethodDeclaration sourceMethod) { if (this.parameterNonNullness == null) this.parameterNonNullness = new Boolean[this.parameters.length]; - AbstractMethodDeclaration sourceMethod = sourceMethod(); boolean added = false; int length = this.parameterNonNullness.length; for (int i = 0; i < length; i++) { @@ -467,7 +467,7 @@ protected void fillInDefaultNonNullness() { if (sourceMethod != null) { sourceMethod.arguments[i].binding.tagBits |= TagBits.AnnotationNonNull; } - } else if (this.parameterNonNullness[i].booleanValue()) { + } else if (sourceMethod != null && this.parameterNonNullness[i].booleanValue()) { sourceMethod.scope.problemReporter().nullAnnotationIsRedundant(sourceMethod, i); } } @@ -478,7 +478,7 @@ protected void fillInDefaultNonNullness() { && (this.tagBits & (TagBits.AnnotationNonNull|TagBits.AnnotationNullable)) == 0) { this.tagBits |= TagBits.AnnotationNonNull; - } else if ((this.tagBits & TagBits.AnnotationNonNull) != 0) { + } else if (sourceMethod != null && (this.tagBits & TagBits.AnnotationNonNull) != 0) { sourceMethod.scope.problemReporter().nullAnnotationIsRedundant(sourceMethod, -1/*signifies method return*/); } } @@ -1176,4 +1176,11 @@ public String toString() { public TypeVariableBinding[] typeVariables() { return this.typeVariables; } +public boolean hasNonNullDefault() { + if ((this.tagBits & TagBits.AnnotationNonNullByDefault) != 0) + return true; + if ((this.tagBits & TagBits.AnnotationNullUnspecifiedByDefault) != 0) + return false; + return this.declaringClass.hasNonNullDefault(); +} } |