From 4ec4d6ec66c3ed19f15ca86424d333ce7dc0bca9 Mon Sep 17 00:00:00 2001 From: "Pavel V. Talanov" Date: Thu, 5 May 2016 16:38:39 +0300 Subject: [PATCH] implicitReceiversUtils: Script descriptors are implicit receivers This fixes completion in repl --- .../kotlin/idea/util/implicitReceiversUtils.kt | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/idea/ide-common/src/org/jetbrains/kotlin/idea/util/implicitReceiversUtils.kt b/idea/ide-common/src/org/jetbrains/kotlin/idea/util/implicitReceiversUtils.kt index ec14f32947f..438c2b2db06 100644 --- a/idea/ide-common/src/org/jetbrains/kotlin/idea/util/implicitReceiversUtils.kt +++ b/idea/ide-common/src/org/jetbrains/kotlin/idea/util/implicitReceiversUtils.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2015 JetBrains s.r.o. + * Copyright 2010-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,10 +16,7 @@ package org.jetbrains.kotlin.idea.util -import org.jetbrains.kotlin.descriptors.ClassDescriptor -import org.jetbrains.kotlin.descriptors.DeclarationDescriptor -import org.jetbrains.kotlin.descriptors.PropertyAccessorDescriptor -import org.jetbrains.kotlin.descriptors.ReceiverParameterDescriptor +import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.psi.KtExpression import org.jetbrains.kotlin.psi.KtFunctionLiteral @@ -59,6 +56,10 @@ fun LexicalScope.getImplicitReceiversWithInstanceToExpression(): Map() for ((index, receiver) in receivers.withIndex()) { val owner = receiver.containingDeclaration + if (owner is ScriptDescriptor) { + result.put(receiver, null) + continue + } val (expressionText, isImmediateThis) = if (owner in outerDeclarationsWithInstance) { val thisWithLabel = thisQualifierName(receiver)?.let { "this@${it.render()}" } if (index == 0)