diff --git a/compiler/frontend/src/org/jetbrains/kotlin/util/lookupTrackerUtil.kt b/compiler/frontend/src/org/jetbrains/kotlin/util/lookupTrackerUtil.kt index a1c59460f75..3aae9aca834 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/util/lookupTrackerUtil.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/util/lookupTrackerUtil.kt @@ -2,9 +2,10 @@ package org.jetbrains.kotlin.util import org.jetbrains.kotlin.incremental.KotlinLookupLocation import org.jetbrains.kotlin.incremental.components.LookupTracker +import org.jetbrains.kotlin.incremental.getScopeKind import org.jetbrains.kotlin.incremental.record 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.typeUtil.isUnit @@ -16,7 +17,7 @@ fun LookupTracker.record(expression: KtExpression, type: KotlinType) { // 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 - if (!isLocal(typeDescriptor)) { + if (getScopeKind(scopeDescriptor) != null && !DescriptorUtils.isLocal(typeDescriptor)) { record(KotlinLookupLocation(expression), scopeDescriptor, typeDescriptor.name) } diff --git a/core/descriptors/src/org/jetbrains/kotlin/incremental/utils.kt b/core/descriptors/src/org/jetbrains/kotlin/incremental/utils.kt index fdec289002f..80c8bfaebf4 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/incremental/utils.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/incremental/utils.kt @@ -28,14 +28,16 @@ fun LookupTracker.record(from: LookupLocation, scopeOwner: DeclarationDescriptor val location = from.location ?: return - val scopeKind = - when (scopeOwner) { - is ClassifierDescriptor -> ScopeKind.CLASSIFIER - is PackageFragmentDescriptor -> ScopeKind.PACKAGE - else -> throw AssertionError("Unexpected containing declaration type: ${scopeOwner.javaClass}") - } + val scopeKind = getScopeKind(scopeOwner) ?: + throw AssertionError("Unexpected containing declaration type: ${scopeOwner.javaClass}") val position = if (requiresPosition) location.position else Position.NO_POSITION 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 +} \ No newline at end of file diff --git a/jps-plugin/testData/incremental/lookupTracker/expressionType/genericType.kt b/jps-plugin/testData/incremental/lookupTracker/expressionType/genericType.kt new file mode 100644 index 00000000000..7eb6d235268 --- /dev/null +++ b/jps-plugin/testData/incremental/lookupTracker/expressionType/genericType.kt @@ -0,0 +1,15 @@ +package foo + +// From KT-10772 Problem with daemon on Idea 15.0.3 & 1-dev-25 + +/*p:foo*/fun identity(): (T) -> T = /*p:kotlin(Nothing) p:kotlin(Function1)*/null as (T) -> T + +/*p:foo*/fun compute(f: () -> T) { + val result = f() +} + +/*p:foo*/class Bar(val t: T) { + init { + val a = /*c:foo.Bar c:foo.Bar(T)*/t + } +} \ No newline at end of file