forked from JetBrains/kotlin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
KT-29586: Add android.annotation annotations
KT-29586 Fixed
- Loading branch information
Showing
9 changed files
with
153 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER | ||
// FILE: A.java | ||
|
||
import android.annotation.*; | ||
|
||
public class A<T> { | ||
@Nullable public String field = null; | ||
|
||
@Nullable | ||
public String foo(@NonNull String x, @Nullable CharSequence y) { | ||
return ""; | ||
} | ||
|
||
@NonNull | ||
public String bar() { | ||
return ""; | ||
} | ||
|
||
@Nullable | ||
public T baz(@NonNull T x) { return x; } | ||
} | ||
|
||
// FILE: main.kt | ||
|
||
fun main(a: A<String>, a1: A<String?>) { | ||
a.foo("", null)?.length | ||
a.foo("", null)<!UNSAFE_CALL!>.<!>length | ||
a.foo(<!NULL_FOR_NONNULL_TYPE!>null<!>, "")<!UNSAFE_CALL!>.<!>length | ||
|
||
a.bar().length | ||
a.bar()<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>.length | ||
|
||
a.field?.length | ||
a.field<!UNSAFE_CALL!>.<!>length | ||
|
||
a.baz("")<!UNSAFE_CALL!>.<!>length | ||
a.baz("")?.length | ||
a.baz(<!NULL_FOR_NONNULL_TYPE!>null<!>)<!UNSAFE_CALL!>.<!>length | ||
|
||
a1.baz("")!!.length | ||
a1.baz(<!NULL_FOR_NONNULL_TYPE!>null<!>)!!.length | ||
} |
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,14 @@ | ||
package | ||
|
||
public fun main(/*0*/ a: A<kotlin.String>, /*1*/ a1: A<kotlin.String?>): kotlin.Unit | ||
|
||
public open class A</*0*/ T : kotlin.Any!> { | ||
public constructor A</*0*/ T : kotlin.Any!>() | ||
@android.annotation.Nullable public final var field: kotlin.String? | ||
@android.annotation.NonNull public open fun bar(): kotlin.String | ||
@android.annotation.Nullable public open fun baz(/*0*/ @android.annotation.NonNull x: T): T? | ||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean | ||
@android.annotation.Nullable public open fun foo(/*0*/ @android.annotation.NonNull x: kotlin.String, /*1*/ @android.annotation.Nullable y: kotlin.CharSequence?): kotlin.String? | ||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int | ||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String | ||
} |
5 changes: 5 additions & 0 deletions
5
...org/jetbrains/kotlin/checkers/ForeignAnnotationsNoAnnotationInClasspathTestGenerated.java
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
5 changes: 5 additions & 0 deletions
5
.../checkers/ForeignAnnotationsNoAnnotationInClasspathWithFastClassReadingTestGenerated.java
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
5 changes: 5 additions & 0 deletions
5
compiler/tests/org/jetbrains/kotlin/checkers/ForeignAnnotationsTestGenerated.java
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
5 changes: 5 additions & 0 deletions
5
compiler/tests/org/jetbrains/kotlin/checkers/javac/JavacForeignAnnotationsTestGenerated.java
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Copyright (C) 2013 The Android Open Source Project | ||
* | ||
* 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 android.annotation; | ||
|
||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.Target; | ||
|
||
import static java.lang.annotation.ElementType.FIELD; | ||
import static java.lang.annotation.ElementType.METHOD; | ||
import static java.lang.annotation.ElementType.PARAMETER; | ||
import static java.lang.annotation.RetentionPolicy.CLASS; | ||
|
||
/** | ||
* Denotes that a parameter, field or method return value can never be null. | ||
* <p> | ||
* This is a marker annotation and it has no specific attributes. | ||
*/ | ||
@Retention(CLASS) | ||
@Target({METHOD, PARAMETER, FIELD}) | ||
public @interface NonNull { | ||
} |
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,41 @@ | ||
/* | ||
* Copyright (C) 2013 The Android Open Source Project | ||
* | ||
* 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 android.annotation; | ||
|
||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.Target; | ||
|
||
import static java.lang.annotation.ElementType.FIELD; | ||
import static java.lang.annotation.ElementType.METHOD; | ||
import static java.lang.annotation.ElementType.PARAMETER; | ||
import static java.lang.annotation.RetentionPolicy.CLASS; | ||
|
||
/** | ||
* Denotes that a parameter, field or method return value can be null. | ||
* <p> | ||
* When decorating a method call parameter, this denotes that the parameter can | ||
* legitimately be null and the method will gracefully deal with it. Typically | ||
* used on optional parameters. | ||
* <p> | ||
* When decorating a method, this denotes the method might legitimately return | ||
* null. | ||
* <p> | ||
* This is a marker annotation and it has no specific attributes. | ||
*/ | ||
@Retention(CLASS) | ||
@Target({METHOD, PARAMETER, FIELD}) | ||
public @interface Nullable { | ||
} |