File tree 1 file changed +15
-2
lines changed
src/jvmMain/java/org/jetbrains/annotations
1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change 21
21
* The tools may issue a warning if the nullability for a subclass method contradicts from the specified nullability
22
22
* of a superclass method.
23
23
* <p>
24
- * The annotation has no effect on newly declared type parameters and their bounds. Only instantiations of
25
- * type parameters are constrained.
24
+ * For newly declared type parameters, the annotation applies to its bounds, including implicit {@code Object}
25
+ * bound if no explicit bound is declared. For example, {@code <T>} declared under {@code @NotNullByDefault} scope
26
+ * means the same as {@code <T extends @NotNull Object>}. To reset to default behavior in this case, one should use
27
+ * {@code <T extends @UnknownNullability Object>}.
28
+ * <p>
29
+ * The type parameter references are not affected by {@code @NotNullByDefault}. For example:
30
+ * <pre>{@code
31
+ * @NotNullByDefault
32
+ * interface Pair<K extends @Nullable Object, V> {
33
+ * // Not assumed to be @NotNull; may return null depending on the T instantiation
34
+ * K getKey();
35
+ * // Returns @NotNull, as implicit upper bound of V is @NotNull Object,
36
+ * // so it cannot be instantiated with a nullable type
37
+ * V getValue();
38
+ * }}</pre>
26
39
* <p>
27
40
* The annotation has no effect on local variables.
28
41
*
You can’t perform that action at this time.
0 commit comments