Fixed nullability for return and parameter types in SAM-adapters

This commit is contained in:
Valentin Kipyatkov
2015-07-29 14:37:17 +03:00
parent 321bf40b65
commit cb9ef9e1f0
12 changed files with 143 additions and 18 deletions
@@ -0,0 +1,13 @@
// FILE: KotlinFile.kt
fun foo(javaClass: JavaClass) {
javaClass.getSomething()<!UNSAFE_CALL!>.<!>length()
javaClass.something<!UNSAFE_CALL!>.<!>length()
}
// FILE: JavaClass.java
import org.jetbrains.annotations.*;
public class JavaClass {
@Nullable
public String getSomething() { return null; }
}
@@ -0,0 +1,11 @@
package
internal fun foo(/*0*/ javaClass: JavaClass): kotlin.Unit
public open class JavaClass {
public constructor JavaClass()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
org.jetbrains.annotations.Nullable() public open fun getSomething(): kotlin.String?
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -0,0 +1,12 @@
// FILE: KotlinFile.kt
fun foo(javaInterface: JavaInterface) {
javaInterface.doIt(<!NULL_FOR_NONNULL_TYPE!>null<!>) <!TYPE_MISMATCH!>{ }<!>
javaInterface.doIt("", <!NULL_FOR_NONNULL_TYPE!>null<!>)
}
// FILE: JavaInterface.java
import org.jetbrains.annotations.*;
public interface JavaInterface {
void doIt(@NotNull String s, @NotNull Runnable runnable);
}
@@ -0,0 +1,11 @@
package
public /*synthesized*/ fun JavaInterface(/*0*/ function: (kotlin.String!, java.lang.Runnable!) -> kotlin.Unit): JavaInterface
internal fun foo(/*0*/ javaInterface: JavaInterface): kotlin.Unit
public interface JavaInterface {
public abstract fun doIt(/*0*/ org.jetbrains.annotations.NotNull() s: kotlin.String, /*1*/ org.jetbrains.annotations.NotNull() runnable: java.lang.Runnable): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -0,0 +1,10 @@
// FILE: KotlinFile.kt
fun foo(javaInterface: JavaInterface) {
javaInterface.doIt(null, null) { }
javaInterface.doIt("", { }, null)
}
// FILE: JavaInterface.java
public interface JavaInterface {
void doIt(String s, Runnable runnable1, Runnable runnable2);
}
@@ -0,0 +1,11 @@
package
public /*synthesized*/ fun JavaInterface(/*0*/ function: (kotlin.String!, java.lang.Runnable!, java.lang.Runnable!) -> kotlin.Unit): JavaInterface
internal fun foo(/*0*/ javaInterface: JavaInterface): kotlin.Unit
public interface JavaInterface {
public abstract fun doIt(/*0*/ s: kotlin.String!, /*1*/ runnable1: java.lang.Runnable!, /*2*/ runnable2: java.lang.Runnable!): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -0,0 +1,19 @@
// FILE: KotlinFile.kt
fun foo(javaInterface: JavaInterface) {
val value: String?
value = javaInterface.compute { "" }
value<!UNSAFE_CALL!>.<!>length()
}
// FILE: JavaInterface.java
import org.jetbrains.annotations.*;
public interface JavaInterface {
@Nullable
<T> String compute(@NotNull Provider<T> provider);
}
// FILE: Provider.java
public interface Provider<T> {
public T compute();
}
@@ -0,0 +1,18 @@
package
public /*synthesized*/ fun </*0*/ T : kotlin.Any!> Provider(/*0*/ function: () -> T!): Provider<T>
internal fun foo(/*0*/ javaInterface: JavaInterface): kotlin.Unit
public interface JavaInterface {
org.jetbrains.annotations.Nullable() public abstract fun </*0*/ T : kotlin.Any!> compute(/*0*/ org.jetbrains.annotations.NotNull() provider: Provider<T!>): kotlin.String?
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public interface Provider</*0*/ T : kotlin.Any!> {
public abstract fun compute(): T!
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}