diff --git a/idea/src/org/jetbrains/jet/plugin/completion/smart/KeywordValues.kt b/idea/src/org/jetbrains/jet/plugin/completion/smart/KeywordValues.kt index 5d221e6f04d..ec7f820a0dc 100644 --- a/idea/src/org/jetbrains/jet/plugin/completion/smart/KeywordValues.kt +++ b/idea/src/org/jetbrains/jet/plugin/completion/smart/KeywordValues.kt @@ -4,6 +4,7 @@ import com.intellij.codeInsight.lookup.LookupElement import org.jetbrains.jet.plugin.completion.ExpectedInfo import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns import com.intellij.codeInsight.lookup.LookupElementBuilder +import org.jetbrains.jet.lang.types.TypeUtils object KeywordValues { public fun addToCollection(collection: MutableCollection, expectedInfos: Collection) { @@ -11,5 +12,9 @@ object KeywordValues { collection.add(LookupElementBuilder.create("true").bold()) collection.add(LookupElementBuilder.create("false").bold()) } + + if (expectedInfos.any { it.`type`.isNullable() }) { + collection.add(LookupElementBuilder.create("null").bold()) + } } } \ No newline at end of file diff --git a/idea/testData/completion/handlers/smart/ConstructorForNullable.kt b/idea/testData/completion/handlers/smart/ConstructorForNullable.kt index 25277b996eb..f2473672974 100644 --- a/idea/testData/completion/handlers/smart/ConstructorForNullable.kt +++ b/idea/testData/completion/handlers/smart/ConstructorForNullable.kt @@ -3,3 +3,5 @@ class Foo fun foo(p : Any){ var a : Foo? = } + +// ELEMENT: Foo diff --git a/idea/testData/completion/handlers/smart/ConstructorForNullable.kt.after b/idea/testData/completion/handlers/smart/ConstructorForNullable.kt.after index 12b2ed98821..7d096e25031 100644 --- a/idea/testData/completion/handlers/smart/ConstructorForNullable.kt.after +++ b/idea/testData/completion/handlers/smart/ConstructorForNullable.kt.after @@ -3,3 +3,5 @@ class Foo fun foo(p : Any){ var a : Foo? = Foo() } + +// ELEMENT: Foo diff --git a/idea/testData/completion/handlers/smart/MergeTail2.kt b/idea/testData/completion/handlers/smart/MergeTail2.kt index 80f3c048360..64b2ab6ca6d 100644 --- a/idea/testData/completion/handlers/smart/MergeTail2.kt +++ b/idea/testData/completion/handlers/smart/MergeTail2.kt @@ -6,3 +6,5 @@ fun foo(c: C?, i: Int){} fun foo() { foo( } + +// ELEMENT: C diff --git a/idea/testData/completion/handlers/smart/MergeTail2.kt.after b/idea/testData/completion/handlers/smart/MergeTail2.kt.after index 78d52e476ec..89249a9853a 100644 --- a/idea/testData/completion/handlers/smart/MergeTail2.kt.after +++ b/idea/testData/completion/handlers/smart/MergeTail2.kt.after @@ -6,3 +6,5 @@ fun foo(c: C?, i: Int){} fun foo() { foo(C() } + +// ELEMENT: C diff --git a/idea/testData/completion/smart/Null.kt b/idea/testData/completion/smart/Null.kt new file mode 100644 index 00000000000..e38471fbdae --- /dev/null +++ b/idea/testData/completion/smart/Null.kt @@ -0,0 +1,7 @@ +fun foo(p: String?) {} + +fun bar() { + foo() +} + +// EXIST: null diff --git a/idea/tests/org/jetbrains/jet/completion/JvmSmartCompletionTestGenerated.java b/idea/tests/org/jetbrains/jet/completion/JvmSmartCompletionTestGenerated.java index 7fa201c668a..cc26b81bbf0 100644 --- a/idea/tests/org/jetbrains/jet/completion/JvmSmartCompletionTestGenerated.java +++ b/idea/tests/org/jetbrains/jet/completion/JvmSmartCompletionTestGenerated.java @@ -281,6 +281,11 @@ public class JvmSmartCompletionTestGenerated extends AbstractJvmSmartCompletionT doTest("idea/testData/completion/smart/NotSillyAssignment.kt"); } + @TestMetadata("Null.kt") + public void testNull() throws Exception { + doTest("idea/testData/completion/smart/Null.kt"); + } + @TestMetadata("NullableThis.kt") public void testNullableThis() throws Exception { doTest("idea/testData/completion/smart/NullableThis.kt");