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 243294 Details for
Bug 434899
[1.8][null] Java 1.8 null annotations still cause 'Contradictory null annotations' error
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]
proposed patch
Bug-434899--18null-Java-18-null-annotations-still-ca.patch (text/plain), 3.29 KB, created by
Stephan Herrmann
on 2014-05-20 09:35:07 EDT
(
hide
)
Description:
proposed patch
Filename:
MIME Type:
Creator:
Stephan Herrmann
Created:
2014-05-20 09:35:07 EDT
Size:
3.29 KB
patch
obsolete
>diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullTypeAnnotationTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullTypeAnnotationTest.java >index dc7abd6..b04ca24 100644 >--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullTypeAnnotationTest.java >+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullTypeAnnotationTest.java >@@ -3777,6 +3777,51 @@ > getCompilerOptions(), > ""); > } >+ // https://bugs.eclipse.org/434899 >+ public void testTypeVariable6() { >+ runNegativeTestWithLibs( >+ new String[] { >+ "Assert.java", >+ "import org.eclipse.jdt.annotation.*;\n" + >+ "public class Assert {\n" + >+ " public static void caller() {\n" + >+ " assertNotNull(\"not null\"); // Compiler error\n" + >+ " assertNotNull(null); // Compiler error\n" + >+ " }\n" + >+ " private static @NonNull <T> T assertNotNull(@Nullable T object) {\n" + >+ " return object; // this IS bogus\n" + >+ " }\n" + >+ "}\n" >+ }, >+ getCompilerOptions(), >+ "----------\n" + >+ "1. ERROR in Assert.java (at line 8)\n" + >+ " return object; // this IS bogus\n" + >+ " ^^^^^^\n" + >+ "Null type mismatch (type annotations): required \'@NonNull T\' but this expression has type \'@Nullable T\'\n" + >+ "----------\n"); >+ } >+ // https://bugs.eclipse.org/434899 - variant which has always worked >+ public void testTypeVariable6a() { >+ runConformTestWithLibs( >+ new String[] { >+ "Assert.java", >+ "import org.eclipse.jdt.annotation.*;\n" + >+ "public class Assert {\n" + >+ " public static Object caller() {\n" + >+ " @NonNull Object result = assertNotNull(\"not null\");\n" + >+ " result = assertNotNull(null);\n" + >+ " return result;\n" + >+ " }\n" + >+ " private static @NonNull <T> T assertNotNull(@Nullable T object) {\n" + >+ " if (object == null) throw new NullPointerException();\n" + >+ " return object;\n" + >+ " }\n" + >+ "}\n" >+ }, >+ getCompilerOptions(), >+ ""); >+ } > public void testSE7AnnotationCopy() { // we were dropping annotations here, but null analysis worked already since the tagbits were not "dropped", just the same capturing in a test > runNegativeTestWithLibs( > new String[] { >diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/InferenceContext18.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/InferenceContext18.java >index 2e6f8aa..b28f024 100644 >--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/InferenceContext18.java >+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/InferenceContext18.java >@@ -373,6 +373,10 @@ > public BoundSet inferInvocationType(BoundSet b1, TypeBinding expectedType, InvocationSite invocationSite, MethodBinding method) > throws InferenceFailureException > { >+ // not JLS: simply ensure that null hints from the return type have been seen even in standalone contexts: >+ if (expectedType == null && method.returnType != null) >+ substitute(method.returnType); // result is ignore, the only effect is on InferenceVariable.nullHints >+ // > BoundSet previous = this.currentBounds.copy(); > this.currentBounds = b1; > try {
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 434899
: 243294