-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
32 changed files
with
6,472 additions
and
1,100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
...pecify/conformance/tests/irrelevantannotations/notnullmarked/AnnotatedTypeParameters.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/* | ||
* Copyright 2024 The JSpecify Authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.jspecify.conformance.tests.irrelevantannotations.notnullmarked; | ||
|
||
import org.jspecify.annotations.NonNull; | ||
import org.jspecify.annotations.Nullable; | ||
|
||
/** | ||
* {@link Nullable @Nullable} and {@link NonNull @NonNull} annotations are unrecognized when applied | ||
* to type parameters themselves (as opposed to their bounds). | ||
* | ||
* @see <a | ||
* href="https://jspecify.dev/docs/spec#recognized-locations-for-type-use-annotations">Recognized | ||
* locations for type-use annotations</a> in the JSpecify specification. | ||
*/ | ||
public interface AnnotatedTypeParameters { | ||
|
||
// test:name:Nullable on simple type parameter on method | ||
// test:irrelevant-annotation:Nullable | ||
<@Nullable T> void nParameter(); | ||
|
||
// test:name:NonNull on simple type parameter on method | ||
// test:irrelevant-annotation:NonNull | ||
<@NonNull T> void rParameter(); | ||
|
||
// test:name:Nullable on bounded type parameter on method | ||
// test:irrelevant-annotation:Nullable | ||
<@Nullable T extends Object> void nParameterWithBound(); | ||
|
||
// test:name:NonNull on bounded type parameter on method | ||
// test:irrelevant-annotation:NonNull | ||
<@NonNull T extends Object> void rParameterWithBound(); | ||
|
||
// test:name:NonNull on annotated-bounded type parameter on method | ||
// test:irrelevant-annotation:NonNull | ||
<@NonNull T extends @Nullable Object> void rParameterWithNBound(); | ||
|
||
// test:name:Nullable on annotated-bounded type parameter on method | ||
// test:irrelevant-annotation:Nullable | ||
<@Nullable T extends @NonNull Object> void nParameterWithRBound(); | ||
|
||
// test:name:Nullable on simple type parameter on class | ||
// test:irrelevant-annotation:Nullable | ||
interface NParameter<@Nullable T> {} | ||
|
||
// test:name:NonNull on simple type parameter on class | ||
// test:irrelevant-annotation:NonNull | ||
interface RParameter<@NonNull T> {} | ||
|
||
// test:name:Nullable on bounded type parameter on class | ||
// test:irrelevant-annotation:Nullable | ||
interface NParameterWithBound<@Nullable T extends Object> {} | ||
|
||
// test:name:NonNull on bounded type parameter on class | ||
// test:irrelevant-annotation:NonNull | ||
interface RParameterWithBound<@NonNull T extends Object> {} | ||
|
||
// test:name:NonNull on annotated-bounded type parameter on class | ||
// test:irrelevant-annotation:NonNull | ||
interface RParameterWithNBound<@NonNull T extends @Nullable Object> {} | ||
|
||
// test:name:Nullable on annotated-bounded type parameter on class | ||
// test:irrelevant-annotation:Nullable | ||
interface NParameterWithRBound<@Nullable T extends @NonNull Object> {} | ||
} |
55 changes: 55 additions & 0 deletions
55
...rg/jspecify/conformance/tests/irrelevantannotations/notnullmarked/AnnotatedWildcards.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Copyright 2024 The JSpecify Authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.jspecify.conformance.tests.irrelevantannotations.notnullmarked; | ||
|
||
import org.jspecify.annotations.NonNull; | ||
import org.jspecify.annotations.Nullable; | ||
import org.jspecify.conformance.deps.nullmarked.NHolder; | ||
|
||
/** | ||
* {@link Nullable @Nullable} and {@link NonNull @NonNull} annotations are unrecognized when applied | ||
* to wildcards themselves (as opposed to their bounds). | ||
* | ||
* @see <a | ||
* href="https://jspecify.dev/docs/spec#recognized-locations-for-type-use-annotations">Recognized | ||
* locations for type-use annotations</a> in the JSpecify specification. | ||
*/ | ||
public interface AnnotatedWildcards { | ||
|
||
// test:name:Nullable on unbounded wildcard | ||
// test:irrelevant-annotation:Nullable | ||
NHolder<@Nullable ?> nWildcard(); | ||
|
||
// test:name:NonNull on unbounded wildcard | ||
// test:irrelevant-annotation:NonNull | ||
NHolder<@NonNull ?> rWildcard(); | ||
|
||
// test:name:Nullable on bounded wildcard | ||
// test:irrelevant-annotation:Nullable | ||
NHolder<@Nullable ? extends Object> nWildcardWithBound(); | ||
|
||
// test:name:NonNull on bounded wildcard | ||
// test:irrelevant-annotation:NonNull | ||
NHolder<@NonNull ? extends Object> rWildcardWithBound(); | ||
|
||
// test:name:NonNull on annotated-bounded wildcard | ||
// test:irrelevant-annotation:NonNull | ||
NHolder<@NonNull ? extends @Nullable Object> rWildcardWithNBound(); | ||
|
||
// test:name:Nullable on annotated-bounded wildcard | ||
// test:irrelevant-annotation:Nullable | ||
NHolder<@Nullable ? extends @NonNull Object> nWildcardWithRBound(); | ||
} |
104 changes: 104 additions & 0 deletions
104
...rtions/java/org/jspecify/conformance/tests/irrelevantannotations/notnullmarked/Other.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
/* | ||
* Copyright 2024 The JSpecify Authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.jspecify.conformance.tests.irrelevantannotations.notnullmarked; | ||
|
||
import org.jspecify.annotations.NonNull; | ||
import org.jspecify.annotations.Nullable; | ||
|
||
public class Other { | ||
|
||
/** | ||
* {@link Nullable @Nullable} and {@link NonNull @NonNull} annotations are unrecognized when | ||
* applied to root types of local variables. | ||
* | ||
* @see <a | ||
* href="https://jspecify.dev/docs/spec#recognized-locations-for-type-use-annotations">Recognized | ||
* locations for type-use annotations</a> in the JSpecify specification. | ||
*/ | ||
void localVariables() { | ||
// test:name:Nullable local variable object | ||
// test:irrelevant-annotation:Nullable | ||
@Nullable Object n; | ||
|
||
// test:name:NonNull local variable object | ||
// test:irrelevant-annotation:NonNull | ||
@NonNull Object r; | ||
|
||
// test:name:Nullable local variable array | ||
// test:irrelevant-annotation:Nullable | ||
Object @Nullable [] nArray; | ||
|
||
// test:name:NonNull local variable array | ||
// test:irrelevant-annotation:NonNull | ||
Object @NonNull [] rArray; | ||
} | ||
|
||
/** | ||
* {@link Nullable @Nullable} and {@link NonNull @NonNull} annotations are unrecognized when | ||
* applied to catch parameter types. | ||
* | ||
* @see <a | ||
* href="https://jspecify.dev/docs/spec#recognized-locations-for-type-use-annotations">Recognized | ||
* locations for type-use annotations</a> in the JSpecify specification. | ||
*/ | ||
void catchParameters() { | ||
try { | ||
// test:name:Nullable exception parameter | ||
// test:irrelevant-annotation:Nullable | ||
} catch (@Nullable RuntimeException e) { | ||
} | ||
try { | ||
// test:name:NonNull exception parameter | ||
// test:irrelevant-annotation:NonNull | ||
} catch (@NonNull RuntimeException e) { | ||
} | ||
} | ||
|
||
/** | ||
* {@link Nullable @Nullable} and {@link NonNull @NonNull} annotations are unrecognized when | ||
* applied to try-with-resources parameter types. | ||
* | ||
* @see <a | ||
* href="https://jspecify.dev/docs/spec#recognized-locations-for-type-use-annotations">Recognized | ||
* locations for type-use annotations</a> in the JSpecify specification. | ||
*/ | ||
void tryWithResourcesParameters() throws Exception { | ||
// test:name:Nullable try-with-resources | ||
// test:irrelevant-annotation:Nullable | ||
try (@Nullable AutoCloseable a = () -> {}) {} | ||
// test:name:NonNull try-with-resources | ||
// test:irrelevant-annotation:NonNull | ||
try (@Nullable AutoCloseable a = () -> {}) {} | ||
} | ||
|
||
/** | ||
* {@link Nullable @Nullable} and {@link NonNull @NonNull} annotations are unrecognized when | ||
* applied to thrown types. | ||
* | ||
* @see <a | ||
* href="https://jspecify.dev/docs/spec#recognized-locations-for-type-use-annotations">Recognized | ||
* locations for type-use annotations</a> in the JSpecify specification. | ||
*/ | ||
interface ExceptionTypes { | ||
// test:name:Nullable exception type | ||
// test:irrelevant-annotation:Nullable | ||
void throwsN() throws @Nullable Exception; | ||
|
||
// test:name:NonNull exception type | ||
// test:irrelevant-annotation:NonNulll | ||
void throwsR() throws @NonNull Exception; | ||
} | ||
} |
Oops, something went wrong.