Extraction Engine: Suggest both bounds for nullability-flexible types without nullability annotations. Do not omit return type if inferred one is flexible

#KT-6837 Fixed
This commit is contained in:
Alexey Sedunov
2015-05-25 14:42:55 +03:00
parent 72205540d6
commit 58ef7f2691
24 changed files with 221 additions and 37 deletions
@@ -1,4 +1,5 @@
// WITH_RUNTIME
// SUGGESTED_RETURN_TYPES: kotlin.Boolean?, kotlin.Boolean
// PARAM_DESCRIPTOR: value-parameter val it: kotlin.Map.Entry<(Boolean..Boolean?), (Boolean..Boolean?)> defined in test.<anonymous>
// PARAM_TYPES: kotlin.Map.Entry<(Boolean..Boolean?), (Boolean..Boolean?)>
fun test() {
@@ -1,8 +1,9 @@
// WITH_RUNTIME
// SUGGESTED_RETURN_TYPES: kotlin.Boolean?, kotlin.Boolean
// PARAM_DESCRIPTOR: value-parameter val it: kotlin.Map.Entry<(Boolean..Boolean?), (Boolean..Boolean?)> defined in test.<anonymous>
// PARAM_TYPES: kotlin.Map.Entry<(Boolean..Boolean?), (Boolean..Boolean?)>
fun test() {
J.getMap().filter { b(it) }
}
private fun b(it: Map.Entry<Boolean, Boolean>) = it.getKey()
private fun b(it: Map.Entry<Boolean, Boolean>): Boolean? = it.getKey()
@@ -0,0 +1,8 @@
import org.jetbrains.annotations.NotNull;
public class J {
@NotNull
static String notNull() {
return "";
}
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
// SUGGESTED_NAMES: s, getS
fun test() {
val s = <selection>J.notNull()</selection>
}
@@ -0,0 +1,7 @@
// WITH_RUNTIME
// SUGGESTED_NAMES: s, getS
fun test() {
val s = s()
}
private fun s(): String = J.notNull()
@@ -0,0 +1,8 @@
import org.jetbrains.annotations.Nullable;
public class J {
@Nullable
static String nullable() {
return null;
}
}
@@ -0,0 +1,4 @@
// SUGGESTED_NAMES: s, getS
fun test() {
val s = <selection>J.nullable()</selection>
}
@@ -0,0 +1,6 @@
// SUGGESTED_NAMES: s, getS
fun test() {
val s = s()
}
private fun s(): String? = J.nullable()
@@ -0,0 +1,5 @@
public class J {
static String unknown() {
return "";
}
}
@@ -0,0 +1,5 @@
// SUGGESTED_NAMES: s, getS
// SUGGESTED_RETURN_TYPES: kotlin.String?, kotlin.String
fun test() {
val s = <selection>J.unknown()</selection>
}
@@ -0,0 +1,7 @@
// SUGGESTED_NAMES: s, getS
// SUGGESTED_RETURN_TYPES: kotlin.String?, kotlin.String
fun test() {
val s = s()
}
private fun s(): String? = J.unknown()
@@ -15,4 +15,4 @@ class Foo<T> {
}
}
private fun <T> Foo<T>.t(l: String) = map[l]
private fun <T> Foo<T>.t(l: String): T = map[l]
@@ -11,5 +11,5 @@ class Foo<T> {
return t(l)
}
private fun t(l: String) = map[l]
private fun t(l: String): T = map[l]
}