Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephan Herrmann2013-07-07 13:03:12 +0000
committerStephan Herrmann2013-08-07 12:42:10 +0000
commit1b76d1263c31e5c68d443b5403fb264d42f38984 (patch)
treea875efe1e8696898cdfb5450edded71688bc8d4b
parentaed03906e7d2f17f49e54e89e6351371507226f9 (diff)
downloadeclipse.jdt.core-1b76d1263c31e5c68d443b5403fb264d42f38984.tar.gz
eclipse.jdt.core-1b76d1263c31e5c68d443b5403fb264d42f38984.tar.xz
eclipse.jdt.core-1b76d1263c31e5c68d443b5403fb264d42f38984.zip
Bug 412076 - [compiler] @NonNullByDefault doesn't work for varargsM20130814-0800M20130807-1400M20130807-1000
parameter when in generic interface
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullAnnotationTest.java36
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedTypeBinding.java7
2 files changed, 40 insertions, 3 deletions
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 0a527c2dce..d0f020cc0b 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
@@ -51,7 +51,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[] { "test_nonnull_field_2e" };
+// TESTS_NAMES = new String[] { "testBug412076" };
// TESTS_NUMBERS = new int[] { 561 };
// TESTS_RANGE = new int[] { 1, 2049 };
}
@@ -6195,4 +6195,38 @@ public void testBug403086_2() {
customOptions,
"");
}
+
+// https://bugs.eclipse.org/412076 - [compiler] @NonNullByDefault doesn't work for varargs parameter when in generic interface
+public void testBug412076() {
+ Map options = getCompilerOptions();
+ options.put(JavaCore.COMPILER_PB_MISSING_OVERRIDE_ANNOTATION, JavaCore.IGNORE);
+ runConformTestWithLibs(
+ new String[] {
+ "Foo.java",
+ "import org.eclipse.jdt.annotation.*;\n" +
+ "@NonNullByDefault\n" +
+ "public interface Foo<V> {\n" +
+ " V bar(String... values);\n" +
+ " V foo(String value);\n" +
+ "}\n"
+ },
+ options,
+ "");
+ runConformTestWithLibs(
+ new String[] {
+ "FooImpl.java",
+ "import org.eclipse.jdt.annotation.*;\n" +
+ "@NonNullByDefault\n" +
+ "public class FooImpl implements Foo<String> {\n" +
+ " public String bar(final String... values) {\n" +
+ " return (\"\");\n" +
+ " }\n" +
+ " public String foo(final String value) {\n" +
+ " return (\"\");\n" +
+ " }\n" +
+ "}\n"
+ },
+ options,
+ "");
+}
}
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 d887d6d7a7..ad8aef8a08 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2012 IBM Corporation and others.
+ * Copyright (c) 2005, 2013 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -10,6 +10,7 @@
* Stephan Herrmann - Contributions for
* bug 349326 - [1.7] new warning for missing try-with-resources
* bug 395002 - Self bound generic class doesn't resolve bounds properly for wildcards for certain parametrisation.
+ * Bug 412076 - [compiler] @NonNullByDefault doesn't work for varargs parameter when in generic interface
*******************************************************************************/
package org.eclipse.jdt.internal.compiler.lookup;
@@ -686,7 +687,9 @@ public class ParameterizedTypeBinding extends ReferenceBinding implements Substi
this.tagBits |= someArgument.tagBits & (TagBits.HasTypeVariable | TagBits.HasMissingType | TagBits.ContainsNestedTypeReferences);
}
}
- this.tagBits |= someType.tagBits & (TagBits.IsLocalType| TagBits.IsMemberType | TagBits.IsNestedType | TagBits.HasMissingType | TagBits.ContainsNestedTypeReferences);
+ this.tagBits |= someType.tagBits & (TagBits.IsLocalType| TagBits.IsMemberType | TagBits.IsNestedType | TagBits.ContainsNestedTypeReferences
+ | TagBits.HasMissingType
+ | TagBits.AnnotationNonNullByDefault | TagBits.AnnotationNullUnspecifiedByDefault);
this.tagBits &= ~(TagBits.AreFieldsComplete|TagBits.AreMethodsComplete);
}

Back to the top