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 243617 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]
WIP: Patch
patch.patch (text/plain), 5.77 KB, created by
shankha banerjee
on 2014-05-28 07:04:00 EDT
(
hide
)
Description:
WIP: Patch
Filename:
MIME Type:
Creator:
shankha banerjee
Created:
2014-05-28 07:04:00 EDT
Size:
5.77 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..4e5a93f 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 >@@ -36,7 +36,7 @@ public NullAnnotationTest(String name) { > // Static initializer to specify tests subset using TESTS_* static variables > // All specified tests which do not belong to the class are skipped... > static { >-// TESTS_NAMES = new String[] { "testBug412076" }; >+ TESTS_NAMES = new String[] { "testBug434604" }; > // TESTS_NUMBERS = new int[] { 561 }; > // TESTS_RANGE = new int[] { 1, 2049 }; > } >@@ -7436,4 +7436,87 @@ 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(), >+ ""); >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=434602 >+//Possible error with inferred null annotations leading to contradictory null annotations >+//Method part of parameterized class. >+public void testBug434603() { >+ 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 Z <T> {\n" + >+ " void foo() {\n" + >+ " Z<Y> z = new Z<Y>();\n" + >+ " z.bar(); // Error: Contradictory null annotations before the fix\n" + >+ " }\n" + >+ "\n" + >+ " public @Nullable T bar() {\n" + >+ " return null;\n" + >+ " }\n" + >+ "}\n" + >+ "class X {}\n" >+ }, >+ getCompilerOptions(), >+ ""); >+} >+public void testBug434604() { >+ 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" + >+ "import org.eclipse.jdt.annotation.NonNull;\n" + >+ "\n" + >+ "class Y {}\n" + >+ "class Y2 extends Y {}\n" + >+ "\n" + >+ "//@NonNullByDefault\n" + >+ "class X {\n" + >+ " void foo() {\n" + >+ " X x = new X();\n" + >+ " x.bar(new Y2()); \n" + >+ " }\n" + >+ " public <T extends @NonNull Y> @Nullable T bar(T t) {\n" + >+ " return t;\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..d91b2fc 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 >@@ -739,6 +739,10 @@ public class ParameterizedGenericMethodBinding extends ParameterizedMethodBindin > // check this variable can be substituted given parameterized type > if (originalVariable.rank < length && TypeBinding.equalsEquals(variables[originalVariable.rank], originalVariable)) { > TypeBinding substitute = this.typeArguments[originalVariable.rank]; >+ if ((originalVariable.tagBits & TagBits.AnnotationNullable) == TagBits.AnnotationNullable >+ && (substitute.tagBits & TagBits.AnnotationNonNull) == TagBits.AnnotationNonNull) { >+ substitute = substitute.unannotated(); >+ } > return originalVariable.hasTypeAnnotations() ? this.environment.createAnnotatedType(substitute, originalVariable.getTypeAnnotations()) : substitute; > } > return originalVariable; >diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedTypeBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedTypeBinding.java >index d22336c..e308f49 100644 >--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedTypeBinding.java >+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedTypeBinding.java >@@ -1188,6 +1188,10 @@ public class ParameterizedTypeBinding extends ReferenceBinding implements Substi > return originalVariable; > } > TypeBinding substitute = currentType.arguments[originalVariable.rank]; >+ if ((originalVariable.tagBits & TagBits.AnnotationNullable) == TagBits.AnnotationNullable >+ && (substitute.tagBits & TagBits.AnnotationNonNull) == TagBits.AnnotationNonNull) { >+ substitute = substitute.unannotated(); >+ } > return originalVariable.hasTypeAnnotations() ? this.environment.createAnnotatedType(substitute, originalVariable.getTypeAnnotations()) : substitute; > } > }
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