Report of UNINITIALIZED_ENUM_COMPANION also for implicit receivers #KT-11769 Fixed

This commit is contained in:
Mikhail Glukhikh
2016-08-09 15:30:27 +03:00
parent 04f71bccf2
commit 1c5c6506ce
5 changed files with 39 additions and 25 deletions
@@ -39,10 +39,7 @@ import org.jetbrains.kotlin.lexer.KtTokens.*
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.psi.psiUtil.getQualifiedElementSelector
import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType
import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.resolve.BindingContextUtils
import org.jetbrains.kotlin.resolve.BindingTrace
import org.jetbrains.kotlin.resolve.CompileTimeConstantUtils
import org.jetbrains.kotlin.resolve.*
import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall
import org.jetbrains.kotlin.resolve.calls.model.ArgumentMatch
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
@@ -1481,6 +1478,16 @@ class ControlFlowProcessor(private val trace: BindingTrace) {
when (receiver) {
is ImplicitReceiver -> {
if (callElement is KtCallExpression) {
val declaration = receiver.declarationDescriptor
if (declaration is ClassDescriptor) {
val fakeDescriptor = getFakeDescriptorForObject(declaration)
val calleeExpression = callElement.calleeExpression
if (fakeDescriptor != null && calleeExpression != null) {
builder.read(calleeExpression, AccessTarget.Declaration(fakeDescriptor), emptyMap())
}
}
}
receiverValues = receiverValues.plus(createSyntheticValue(callElement, MagicKind.IMPLICIT_RECEIVER), receiver)
}
is ExpressionReceiver -> {
@@ -91,7 +91,12 @@ public class PseudocodeUtil {
public static VariableDescriptor extractVariableDescriptorIfAny(@NotNull Instruction instruction, boolean onlyReference, @NotNull BindingContext bindingContext) {
KtElement element = null;
if (instruction instanceof ReadValueInstruction) {
element = ((ReadValueInstruction) instruction).getElement();
ReadValueInstruction readValueInstruction = (ReadValueInstruction) instruction;
AccessTarget target = readValueInstruction.getTarget();
if (target instanceof AccessTarget.Declaration) {
return ((AccessTarget.Declaration) target).getDescriptor();
}
element = readValueInstruction.getElement();
}
else if (instruction instanceof WriteValueInstruction) {
element = ((WriteValueInstruction) instruction).getLValue();