Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 243496 Details for
Bug 434602
[1.8][null] Possible error with inferred null annotations leading to contradictory null annotations
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Patch
patch.patch (text/plain), 4.36 KB, created by
shankha banerjee
on 2014-05-26 11:30:41 EDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
shankha banerjee
Created:
2014-05-26 11:30:41 EDT
Size:
4.36 KB
patch
obsolete
>diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullAnnotationTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullAnnotationTest.java >index 264abd2..ca78698 100644 >--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullAnnotationTest.java >+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullAnnotationTest.java >@@ -7436,4 +7436,31 @@ public void testBug434374c() { > getCompilerOptions(), > ""); > } >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=434602 >+// Possible error with inferred null annotations leading to contradictory null annotations >+public void testBug434602() { >+ if (this.complianceLevel < ClassFileConstants.JDK1_8) >+ return; >+ runConformTestWithLibs( >+ new String[] { >+ "X.java", >+ "import org.eclipse.jdt.annotation.NonNullByDefault;\n" + >+ "import org.eclipse.jdt.annotation.Nullable;\n" + >+ "\n" + >+ "class Y {}\n" + >+ "@NonNullByDefault\n" + >+ "class X {\n" + >+ " void foo() {\n" + >+ " X x = new X();\n" + >+ " x.bar(); // Error: Contradictory null annotations before the fix\n" + >+ " }\n" + >+ "\n" + >+ " public <T extends Y> @Nullable T bar() {\n" + >+ " return null;\n" + >+ " }\n" + >+ "}\n" >+ }, >+ getCompilerOptions(), >+ ""); >+} > } >diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedGenericMethodBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedGenericMethodBinding.java >index fb5cbb3..44621af 100644 >--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedGenericMethodBinding.java >+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedGenericMethodBinding.java >@@ -484,6 +484,35 @@ public class ParameterizedGenericMethodBinding extends ParameterizedMethodBindin > this.defaultNullness = originalMethod.defaultNullness; > } > >+ /** >+ * Override NonNull with Nullable for return type. >+ */ >+ private TypeBinding substitutedConflictingNullAnnotationReturnType(MethodBinding method, LookupEnvironment env) { >+ // error case where exception type variable would have been substituted by a non-reference type (207573) >+ TypeBinding substitutedReturnType = Scope.substitute(this, method.returnType); >+ if (!env.globalOptions.isAnnotationBasedNullAnalysisEnabled) >+ return substitutedReturnType; >+ >+ // No conflicting null annotations (NonNull and Nullable). >+ if ((substitutedReturnType.tagBits & TagBits.AnnotationNullMASK) != TagBits.AnnotationNullMASK) >+ return substitutedReturnType; >+ >+ // We should not suppress errors where user annotated the return type with both NonNull >+ // and Nullable explicitly. >+ if ((method.returnType.tagBits & TagBits.AnnotationNullable) == TagBits.AnnotationNullable >+ && (method.returnType.tagBits & TagBits.AnnotationNonNull) != TagBits.AnnotationNonNull) { >+ AnnotationBinding[] annotationBinding = substitutedReturnType.typeAnnotations; >+ AnnotationBinding[] newbies = new AnnotationBinding[annotationBinding.length-1]; >+ for (int i = 0, length = annotationBinding.length, j = 0; i < length; i++) { >+ if (annotationBinding[i].type.id != TypeIds.T_ConfiguredAnnotationNonNull) >+ newbies[j++] = annotationBinding[i]; >+ } >+ substitutedReturnType.typeAnnotations = newbies; >+ substitutedReturnType.tagBits &= ~TagBits.AnnotationNonNull; >+ } >+ return substitutedReturnType; >+ } >+ > /** > * Create method of parameterized type, substituting original parameters with type arguments. > */ >@@ -498,8 +527,7 @@ public class ParameterizedGenericMethodBinding extends ParameterizedMethodBindin > this.tagBits = originalMethod.tagBits; > this.originalMethod = originalMethod; > this.parameters = Scope.substitute(this, originalMethod.parameters); >- // error case where exception type variable would have been substituted by a non-reference type (207573) >- this.returnType = Scope.substitute(this, originalMethod.returnType); >+ this.returnType = substitutedConflictingNullAnnotationReturnType(originalMethod, environment); > this.thrownExceptions = Scope.substitute(this, originalMethod.thrownExceptions); > if (this.thrownExceptions == null) this.thrownExceptions = Binding.NO_EXCEPTIONS; > checkMissingType: {
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 434602
:
242950
|
243496
|
243617