Change resolution scope for componentX in lambda parameters

Component-functions are resolved in the same scope as the first statement of the lambda, but lambda receiver was not available

 #KT-14692 Fixed
This commit is contained in:
Denis Zharkov
2016-11-09 18:10:17 +03:00
parent 6656bf835f
commit 24819a079b
5 changed files with 53 additions and 20 deletions
@@ -53,7 +53,7 @@ open class ValueParameterDescriptorImpl(
isCrossinline: Boolean,
isNoinline: Boolean, isCoroutine: Boolean, varargElementType: KotlinType?,
source: SourceElement,
destructuringVariables: List<VariableDescriptor>?
destructuringVariables: (() -> List<VariableDescriptor>)?
): ValueParameterDescriptorImpl =
if (destructuringVariables == null)
ValueParameterDescriptorImpl(containingDeclaration, original, index, annotations, name, outType,
@@ -74,11 +74,16 @@ open class ValueParameterDescriptorImpl(
isCrossinline: Boolean,
isNoinline: Boolean, isCoroutine: Boolean, varargElementType: KotlinType?,
source: SourceElement,
val destructuringVariables: List<VariableDescriptor>
destructuringVariables: () -> List<VariableDescriptor>
) : ValueParameterDescriptorImpl(
containingDeclaration, original, index, annotations, name, outType, declaresDefaultValue,
isCrossinline, isNoinline, isCoroutine,
varargElementType, source)
varargElementType, source) {
// It's forced to be lazy because its resolution depends on receiver of relevant lambda, that is being created at the same moment
// as value parameters.
// Must be forced via ForceResolveUtil.forceResolveAllContents()
val destructuringVariables by lazy(destructuringVariables)
}
private val original: ValueParameterDescriptor = original ?: this