KT-10772 Problem with daemon on Idea 15.0.3 & 1-dev-25
# KT-10772 Fixed
This commit is contained in:
@@ -2,9 +2,10 @@ package org.jetbrains.kotlin.util
|
|||||||
|
|
||||||
import org.jetbrains.kotlin.incremental.KotlinLookupLocation
|
import org.jetbrains.kotlin.incremental.KotlinLookupLocation
|
||||||
import org.jetbrains.kotlin.incremental.components.LookupTracker
|
import org.jetbrains.kotlin.incremental.components.LookupTracker
|
||||||
|
import org.jetbrains.kotlin.incremental.getScopeKind
|
||||||
import org.jetbrains.kotlin.incremental.record
|
import org.jetbrains.kotlin.incremental.record
|
||||||
import org.jetbrains.kotlin.psi.KtExpression
|
import org.jetbrains.kotlin.psi.KtExpression
|
||||||
import org.jetbrains.kotlin.resolve.DescriptorUtils.isLocal
|
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||||
import org.jetbrains.kotlin.types.KotlinType
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
import org.jetbrains.kotlin.types.typeUtil.isUnit
|
import org.jetbrains.kotlin.types.typeUtil.isUnit
|
||||||
|
|
||||||
@@ -16,7 +17,7 @@ fun LookupTracker.record(expression: KtExpression, type: KotlinType) {
|
|||||||
|
|
||||||
// Scope descriptor is function descriptor only when type is local
|
// Scope descriptor is function descriptor only when type is local
|
||||||
// Lookups for local types are not needed since all usages are compiled with the type
|
// Lookups for local types are not needed since all usages are compiled with the type
|
||||||
if (!isLocal(typeDescriptor)) {
|
if (getScopeKind(scopeDescriptor) != null && !DescriptorUtils.isLocal(typeDescriptor)) {
|
||||||
record(KotlinLookupLocation(expression), scopeDescriptor, typeDescriptor.name)
|
record(KotlinLookupLocation(expression), scopeDescriptor, typeDescriptor.name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,14 +28,16 @@ fun LookupTracker.record(from: LookupLocation, scopeOwner: DeclarationDescriptor
|
|||||||
|
|
||||||
val location = from.location ?: return
|
val location = from.location ?: return
|
||||||
|
|
||||||
val scopeKind =
|
val scopeKind = getScopeKind(scopeOwner) ?:
|
||||||
when (scopeOwner) {
|
throw AssertionError("Unexpected containing declaration type: ${scopeOwner.javaClass}")
|
||||||
is ClassifierDescriptor -> ScopeKind.CLASSIFIER
|
|
||||||
is PackageFragmentDescriptor -> ScopeKind.PACKAGE
|
|
||||||
else -> throw AssertionError("Unexpected containing declaration type: ${scopeOwner.javaClass}")
|
|
||||||
}
|
|
||||||
|
|
||||||
val position = if (requiresPosition) location.position else Position.NO_POSITION
|
val position = if (requiresPosition) location.position else Position.NO_POSITION
|
||||||
|
|
||||||
record(location.filePath, position, scopeOwner.fqNameUnsafe.asString(), scopeKind, name.asString())
|
record(location.filePath, position, scopeOwner.fqNameUnsafe.asString(), scopeKind, name.asString())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getScopeKind(scopeOwner: DeclarationDescriptor) = when (scopeOwner) {
|
||||||
|
is ClassifierDescriptor -> ScopeKind.CLASSIFIER
|
||||||
|
is PackageFragmentDescriptor -> ScopeKind.PACKAGE
|
||||||
|
else -> null
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package foo
|
||||||
|
|
||||||
|
// From KT-10772 Problem with daemon on Idea 15.0.3 & 1-dev-25
|
||||||
|
|
||||||
|
/*p:foo*/fun <T> identity(): (T) -> T = /*p:kotlin(Nothing) p:kotlin(Function1)*/null as (T) -> T
|
||||||
|
|
||||||
|
/*p:foo*/fun <T> compute(f: () -> T) {
|
||||||
|
val result = f()
|
||||||
|
}
|
||||||
|
|
||||||
|
/*p:foo*/class Bar<T>(val t: T) {
|
||||||
|
init {
|
||||||
|
val a = /*c:foo.Bar c:foo.Bar(T)*/t
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user