EA-141456 extra logging enabled
diff --git a/idea/ide-common/src/org/jetbrains/kotlin/util/exceptionUtils.kt b/idea/ide-common/src/org/jetbrains/kotlin/util/exceptionUtils.kt
index 9825695..61f589c 100644
--- a/idea/ide-common/src/org/jetbrains/kotlin/util/exceptionUtils.kt
+++ b/idea/ide-common/src/org/jetbrains/kotlin/util/exceptionUtils.kt
@@ -9,7 +9,7 @@
import java.lang.IllegalStateException
import kotlin.reflect.KClass
-class ExceptionWithAttachmentWrapper(val ref: String, vararg val vars: Any? = emptyArray()) {
+class ExceptionWithAttachmentWrapper(val ref: String, val varsProvider: () -> Array<Any?>?) {
var catch: KClass<out Throwable> = Throwable::class
fun <T> invoke(block: () -> T) =
@@ -28,10 +28,12 @@
} catch (t: Throwable) {
if (catch.java.isAssignableFrom(t.javaClass)) {
val exception = KotlinExceptionWithAttachments(ref + t.message, t)
- for (arg in vars.withIndex())
+ val vars = varsProvider.invoke() ?: emptyArray()
+ for (arg in vars.withIndex()) {
arg.value?.let {
exception.withAttachment("arg" + arg.index, arg.value.toString())
}
+ }
throw exception
}
throw t;
@@ -40,11 +42,22 @@
}
object EA {
- fun ea141456(vararg vars: Any?) =
- ExceptionWithAttachmentWrapper("EA-141456", vars).catch<IllegalStateException>()
+ inline fun <T> vars(vararg elements: T): () -> Array<Any?>? =
+ { arrayOf(elements) }
- fun ea219323(vararg vars: Any?) =
- ExceptionWithAttachmentWrapper("EA-219323", vars).catch<IllegalStateException>()
+ fun ea141456(f: (EA) -> () -> Array<Any?>?) =
+ ExceptionWithAttachmentWrapper("EA-141456", f(EA)).catch<IllegalStateException>()
+
+ fun ea219323(f: (EA) -> () -> Array<Any?>?) =
+ ExceptionWithAttachmentWrapper("EA-219323", f(EA)).catch<IllegalStateException>()
}
+fun main() {
+ EA.ea141456 {
+ it.vars("1", "2")
+ }.invoke {
+ System.out.println("1");
+ throw IllegalStateException()
+ }
+}
\ No newline at end of file
diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/Utils.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/Utils.kt
index 939b571..a58261d 100644
--- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/Utils.kt
+++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/Utils.kt
@@ -30,6 +30,7 @@
import org.jetbrains.kotlin.types.typeUtil.TypeNullability
import org.jetbrains.kotlin.types.typeUtil.isNothing
import org.jetbrains.kotlin.types.typeUtil.isNullableNothing
+import org.jetbrains.kotlin.util.EA
import org.jetbrains.kotlin.util.descriptorsEqualWithSubstitution
import java.util.*
@@ -304,7 +305,9 @@
}
if (this is CallableDescriptor) {
- val returnType = fuzzyReturnType() ?: return emptyList()
+ val returnType =
+ EA.ea141456(this, this.returnType)
+ .invoke { fuzzyReturnType() } ?: return emptyList()
// skip declarations of types Nothing, Nothing?, dynamic or of generic parameter type which has no real bounds
if (returnType.type.isNothing() ||
diff --git a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/KotlinIndicesHelper.kt b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/KotlinIndicesHelper.kt
index 9260bb0..785226f 100644
--- a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/KotlinIndicesHelper.kt
+++ b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/KotlinIndicesHelper.kt
@@ -55,6 +55,7 @@
import org.jetbrains.kotlin.resolve.scopes.SyntheticScopes
import org.jetbrains.kotlin.resolve.scopes.collectSyntheticStaticFunctions
import org.jetbrains.kotlin.types.KotlinType
+import org.jetbrains.kotlin.util.EA
import java.lang.reflect.Field
import java.lang.reflect.Modifier
import java.util.*
@@ -242,14 +243,23 @@
): Collection<CallableDescriptor> {
val result = LinkedHashSet<CallableDescriptor>()
- fun processDescriptor(descriptor: CallableDescriptor) {
+ fun processDescriptor(callableDeclaration: KtCallableDeclaration, descriptor: CallableDescriptor) {
if (descriptor.extensionReceiverParameter != null && descriptorFilter(descriptor)) {
- result.addAll(descriptor.substituteExtensionIfCallable(receiverTypes, callType))
+ EA.ea141456(
+ callableDeclaration.text,
+ descriptor,
+ descriptor.extensionReceiverParameter,
+ descriptor.extensionReceiverParameter?.type,
+ ).invoke {
+ result.addAll(descriptor.substituteExtensionIfCallable(receiverTypes, callType))
+ }
}
}
- declarations.forEach { it.resolveToDescriptors<CallableDescriptor>().forEach(::processDescriptor) }
-
+ declarations.forEach {
+ for (callableDescriptor in it.resolveToDescriptors<CallableDescriptor>())
+ processDescriptor(it, callableDescriptor)
+ }
return result
}
@@ -455,7 +465,7 @@
shortNamesCache.processAllMethodNames(
{ name -> if (nameFilter(name)) allMethodNames.add(name); true },
scopeWithoutKotlin,
- idFilter
+ idFilter,
)
for (name in allMethodNames) {
ProgressManager.checkCanceled()