Fixed completion for safe call
This commit is contained in:
+3
-2
@@ -31,6 +31,7 @@ import org.jetbrains.kotlin.resolve.lazy.FileScopeProvider
|
|||||||
import org.jetbrains.kotlin.resolve.scopes.JetScope
|
import org.jetbrains.kotlin.resolve.scopes.JetScope
|
||||||
import org.jetbrains.kotlin.storage.StorageManager
|
import org.jetbrains.kotlin.storage.StorageManager
|
||||||
import org.jetbrains.kotlin.types.JetType
|
import org.jetbrains.kotlin.types.JetType
|
||||||
|
import org.jetbrains.kotlin.types.typeUtil.makeNotNullable
|
||||||
import org.jetbrains.kotlin.utils.addIfNotNull
|
import org.jetbrains.kotlin.utils.addIfNotNull
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
@@ -76,7 +77,7 @@ class SyntheticExtensionsScope(storageManager: StorageManager) : JetScope by Jet
|
|||||||
override fun getSyntheticExtensionProperties(receiverType: JetType, name: Name): Collection<VariableDescriptor> {
|
override fun getSyntheticExtensionProperties(receiverType: JetType, name: Name): Collection<VariableDescriptor> {
|
||||||
if (name.isSpecial()) return emptyList()
|
if (name.isSpecial()) return emptyList()
|
||||||
if (name.getIdentifier()[0].isUpperCase()) return emptyList()
|
if (name.getIdentifier()[0].isUpperCase()) return emptyList()
|
||||||
return collectSyntheticPropertiesByName(null, receiverType, name) ?: emptyList()
|
return collectSyntheticPropertiesByName(null, receiverType.makeNotNullable(), name) ?: emptyList()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun collectSyntheticPropertiesByName(result: SmartList<PropertyDescriptor>?, type: JetType, name: Name): SmartList<PropertyDescriptor>? {
|
private fun collectSyntheticPropertiesByName(result: SmartList<PropertyDescriptor>?, type: JetType, name: Name): SmartList<PropertyDescriptor>? {
|
||||||
@@ -96,7 +97,7 @@ class SyntheticExtensionsScope(storageManager: StorageManager) : JetScope by Jet
|
|||||||
|
|
||||||
override fun getSyntheticExtensionProperties(receiverType: JetType): Collection<VariableDescriptor> {
|
override fun getSyntheticExtensionProperties(receiverType: JetType): Collection<VariableDescriptor> {
|
||||||
val result = ArrayList<PropertyDescriptor>()
|
val result = ArrayList<PropertyDescriptor>()
|
||||||
result.collectSyntheticProperties(receiverType)
|
result.collectSyntheticProperties(receiverType.makeNotNullable())
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+7
@@ -0,0 +1,7 @@
|
|||||||
|
import java.io.File
|
||||||
|
|
||||||
|
fun foo(file: File?) {
|
||||||
|
file?.<caret>
|
||||||
|
}
|
||||||
|
|
||||||
|
// EXIST_JAVA_ONLY: { lookupString: "absolutePath", itemText: "absolutePath", tailText: " for File", typeText: "String!" }
|
||||||
+6
@@ -1221,6 +1221,12 @@ public class JSBasicCompletionTestGenerated extends AbstractJSBasicCompletionTes
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("SyntheticExtensionsSafeCall.kt")
|
||||||
|
public void testSyntheticExtensionsSafeCall() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/extensions/SyntheticExtensionsSafeCall.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("WrongExplicitReceiver.kt")
|
@TestMetadata("WrongExplicitReceiver.kt")
|
||||||
public void testWrongExplicitReceiver() throws Exception {
|
public void testWrongExplicitReceiver() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/extensions/WrongExplicitReceiver.kt");
|
String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/extensions/WrongExplicitReceiver.kt");
|
||||||
|
|||||||
+6
@@ -1221,6 +1221,12 @@ public class JvmBasicCompletionTestGenerated extends AbstractJvmBasicCompletionT
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("SyntheticExtensionsSafeCall.kt")
|
||||||
|
public void testSyntheticExtensionsSafeCall() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/extensions/SyntheticExtensionsSafeCall.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("WrongExplicitReceiver.kt")
|
@TestMetadata("WrongExplicitReceiver.kt")
|
||||||
public void testWrongExplicitReceiver() throws Exception {
|
public void testWrongExplicitReceiver() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/extensions/WrongExplicitReceiver.kt");
|
String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/extensions/WrongExplicitReceiver.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user