Unified obtaining psi element for descriptor. Now code for finding effective descriptors of fake override and finding source element for original declarations are separated. Old method DescriptorToSourceUtils.descriptorToDeclaration is still there, because it has ~90 usages.
This commit is contained in:
@@ -1817,7 +1817,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
}
|
||||
|
||||
PsiElement element = bindingContext.get(LABEL_TARGET, expression.getTargetLabel());
|
||||
if (element != DescriptorToSourceUtils.callableDescriptorToDeclaration(context.getContextDescriptor())) {
|
||||
if (element != DescriptorToSourceUtils.getSourceFromDescriptor(context.getContextDescriptor())) {
|
||||
DeclarationDescriptor elementDescriptor = typeMapper.getBindingContext().get(DECLARATION_TO_DESCRIPTOR, element);
|
||||
assert element != null : "Expression should be not null " + expression.getText();
|
||||
assert elementDescriptor != null : "Descriptor should be not null: " + element.getText();
|
||||
|
||||
@@ -73,7 +73,7 @@ import static org.jetbrains.kotlin.codegen.JvmSerializationBindings.*;
|
||||
import static org.jetbrains.kotlin.codegen.binding.CodegenBinding.isLocalNamedFun;
|
||||
import static org.jetbrains.kotlin.descriptors.CallableMemberDescriptor.Kind.DECLARATION;
|
||||
import static org.jetbrains.kotlin.load.java.JvmAnnotationNames.OLD_JET_VALUE_PARAMETER_ANNOTATION;
|
||||
import static org.jetbrains.kotlin.resolve.DescriptorToSourceUtils.callableDescriptorToDeclaration;
|
||||
import static org.jetbrains.kotlin.resolve.DescriptorToSourceUtils.getSourceFromDescriptor;
|
||||
import static org.jetbrains.kotlin.resolve.DescriptorUtils.isFunctionLiteral;
|
||||
import static org.jetbrains.kotlin.resolve.DescriptorUtils.isTrait;
|
||||
import static org.jetbrains.kotlin.resolve.jvm.AsmTypes.OBJECT_TYPE;
|
||||
@@ -498,7 +498,7 @@ public class FunctionCodegen {
|
||||
);
|
||||
|
||||
if (!bridgesToGenerate.isEmpty()) {
|
||||
PsiElement origin = descriptor.getKind() == DECLARATION ? callableDescriptorToDeclaration(descriptor) : null;
|
||||
PsiElement origin = descriptor.getKind() == DECLARATION ? getSourceFromDescriptor(descriptor) : null;
|
||||
for (Bridge<Method> bridge : bridgesToGenerate) {
|
||||
generateBridge(origin, descriptor, bridge.getFrom(), bridge.getTo());
|
||||
}
|
||||
@@ -628,12 +628,12 @@ public class FunctionCodegen {
|
||||
if (this.owner instanceof PackageFacadeContext) {
|
||||
mv.visitCode();
|
||||
generatePackageDelegateMethodBody(mv, defaultMethod, (PackageFacadeContext) this.owner);
|
||||
endVisit(mv, "default method delegation", callableDescriptorToDeclaration(functionDescriptor));
|
||||
endVisit(mv, "default method delegation", getSourceFromDescriptor(functionDescriptor));
|
||||
}
|
||||
else {
|
||||
mv.visitCode();
|
||||
generateDefaultImplBody(owner, functionDescriptor, mv, loadStrategy, function, memberCodegen);
|
||||
endVisit(mv, "default method", callableDescriptorToDeclaration(functionDescriptor));
|
||||
endVisit(mv, "default method", getSourceFromDescriptor(functionDescriptor));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -101,9 +101,9 @@ class BuilderFactoryForDuplicateSignatureDiagnostics(
|
||||
|
||||
if (member.getKind() != DELEGATION) {
|
||||
// Delegates don't have declarations in the code
|
||||
memberElement = origin.element ?: DescriptorToSourceUtils.callableDescriptorToDeclaration(member)
|
||||
memberElement = origin.element ?: DescriptorToSourceUtils.descriptorToDeclaration(member)
|
||||
if (memberElement == null && member is PropertyAccessorDescriptor) {
|
||||
memberElement = DescriptorToSourceUtils.callableDescriptorToDeclaration(member.getCorrespondingProperty())
|
||||
memberElement = DescriptorToSourceUtils.descriptorToDeclaration(member.getCorrespondingProperty())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -619,7 +619,7 @@ public class JetTypeMapper {
|
||||
return "invoke";
|
||||
}
|
||||
else if (descriptor instanceof AnonymousFunctionDescriptor) {
|
||||
PsiElement element = DescriptorToSourceUtils.callableDescriptorToDeclaration(descriptor);
|
||||
PsiElement element = DescriptorToSourceUtils.getSourceFromDescriptor(descriptor);
|
||||
if (element instanceof JetFunctionLiteral) {
|
||||
PsiElement expression = element.getParent();
|
||||
if (expression instanceof JetFunctionLiteralExpression) {
|
||||
|
||||
Reference in New Issue
Block a user