Got rid of constructors/initializers zoo in simple function descriptors
This commit is contained in:
@@ -36,7 +36,7 @@ public class AccessorForFunctionDescriptor extends SimpleFunctionDescriptorImpl
|
|||||||
@NotNull DeclarationDescriptor containingDeclaration,
|
@NotNull DeclarationDescriptor containingDeclaration,
|
||||||
int index
|
int index
|
||||||
) {
|
) {
|
||||||
super(containingDeclaration, Annotations.EMPTY,
|
super(containingDeclaration, null, Annotations.EMPTY,
|
||||||
Name.identifier((descriptor instanceof ConstructorDescriptor ? "$init" : descriptor.getName()) + "$b$" + index),
|
Name.identifier((descriptor instanceof ConstructorDescriptor ? "$init" : descriptor.getName()) + "$b$" + index),
|
||||||
Kind.DECLARATION);
|
Kind.DECLARATION);
|
||||||
|
|
||||||
|
|||||||
@@ -174,9 +174,9 @@ public abstract class ClassBodyCodegen extends MemberCodegen {
|
|||||||
MethodVisitor method = createOrGetClInitMethod();
|
MethodVisitor method = createOrGetClInitMethod();
|
||||||
method.visitCode();
|
method.visitCode();
|
||||||
SimpleFunctionDescriptorImpl clInit =
|
SimpleFunctionDescriptorImpl clInit =
|
||||||
new SimpleFunctionDescriptorImpl(descriptor, Annotations.EMPTY,
|
SimpleFunctionDescriptorImpl.create(descriptor, Annotations.EMPTY,
|
||||||
Name.special("<clinit>"),
|
Name.special("<clinit>"),
|
||||||
CallableMemberDescriptor.Kind.SYNTHESIZED);
|
CallableMemberDescriptor.Kind.SYNTHESIZED);
|
||||||
clInit.initialize(null, null, Collections.<TypeParameterDescriptor>emptyList(),
|
clInit.initialize(null, null, Collections.<TypeParameterDescriptor>emptyList(),
|
||||||
Collections.<ValueParameterDescriptor>emptyList(), null, null, Visibilities.PRIVATE);
|
Collections.<ValueParameterDescriptor>emptyList(), null, null, Visibilities.PRIVATE);
|
||||||
|
|
||||||
|
|||||||
@@ -74,12 +74,13 @@ public class CodegenUtil {
|
|||||||
|
|
||||||
public static SimpleFunctionDescriptor createInvoke(FunctionDescriptor fd) {
|
public static SimpleFunctionDescriptor createInvoke(FunctionDescriptor fd) {
|
||||||
int arity = fd.getValueParameters().size();
|
int arity = fd.getValueParameters().size();
|
||||||
SimpleFunctionDescriptorImpl invokeDescriptor = new SimpleFunctionDescriptorImpl(
|
SimpleFunctionDescriptorImpl invokeDescriptor = SimpleFunctionDescriptorImpl.create(
|
||||||
fd.getExpectedThisObject() != null
|
fd.getExpectedThisObject() != null
|
||||||
? KotlinBuiltIns.getInstance().getExtensionFunction(arity) : KotlinBuiltIns.getInstance().getFunction(arity),
|
? KotlinBuiltIns.getInstance().getExtensionFunction(arity) : KotlinBuiltIns.getInstance().getFunction(arity),
|
||||||
Annotations.EMPTY,
|
Annotations.EMPTY,
|
||||||
Name.identifier("invoke"),
|
Name.identifier("invoke"),
|
||||||
CallableMemberDescriptor.Kind.DECLARATION);
|
CallableMemberDescriptor.Kind.DECLARATION
|
||||||
|
);
|
||||||
|
|
||||||
invokeDescriptor.initialize(DescriptorUtils.getReceiverParameterType(fd.getReceiverParameter()),
|
invokeDescriptor.initialize(DescriptorUtils.getReceiverParameterType(fd.getReceiverParameter()),
|
||||||
fd.getExpectedThisObject(),
|
fd.getExpectedThisObject(),
|
||||||
|
|||||||
@@ -99,9 +99,9 @@ public class PackagePartCodegen extends MemberCodegen {
|
|||||||
FrameMap frameMap = new FrameMap();
|
FrameMap frameMap = new FrameMap();
|
||||||
|
|
||||||
SimpleFunctionDescriptorImpl clInit =
|
SimpleFunctionDescriptorImpl clInit =
|
||||||
new SimpleFunctionDescriptorImpl(this.descriptor, Annotations.EMPTY,
|
SimpleFunctionDescriptorImpl.create(this.descriptor, Annotations.EMPTY,
|
||||||
Name.special("<clinit>"),
|
Name.special("<clinit>"),
|
||||||
CallableMemberDescriptor.Kind.SYNTHESIZED);
|
CallableMemberDescriptor.Kind.SYNTHESIZED);
|
||||||
clInit.initialize(null, null, Collections.<TypeParameterDescriptor>emptyList(),
|
clInit.initialize(null, null, Collections.<TypeParameterDescriptor>emptyList(),
|
||||||
Collections.<ValueParameterDescriptor>emptyList(), null, null, Visibilities.PRIVATE);
|
Collections.<ValueParameterDescriptor>emptyList(), null, null, Visibilities.PRIVATE);
|
||||||
|
|
||||||
|
|||||||
@@ -293,7 +293,7 @@ public class DescriptorResolver {
|
|||||||
@NotNull final DataFlowInfo dataFlowInfo,
|
@NotNull final DataFlowInfo dataFlowInfo,
|
||||||
@NotNull Annotations annotations
|
@NotNull Annotations annotations
|
||||||
) {
|
) {
|
||||||
final SimpleFunctionDescriptorImpl functionDescriptor = new SimpleFunctionDescriptorImpl(
|
final SimpleFunctionDescriptorImpl functionDescriptor = SimpleFunctionDescriptorImpl.create(
|
||||||
containingDescriptor,
|
containingDescriptor,
|
||||||
annotations,
|
annotations,
|
||||||
JetPsiUtil.safeName(function.getName()),
|
JetPsiUtil.safeName(function.getName()),
|
||||||
@@ -379,7 +379,7 @@ public class DescriptorResolver {
|
|||||||
String functionName = COMPONENT_FUNCTION_NAME_PREFIX + parameterIndex;
|
String functionName = COMPONENT_FUNCTION_NAME_PREFIX + parameterIndex;
|
||||||
JetType returnType = property.getType();
|
JetType returnType = property.getType();
|
||||||
|
|
||||||
SimpleFunctionDescriptorImpl functionDescriptor = new SimpleFunctionDescriptorImpl(
|
SimpleFunctionDescriptorImpl functionDescriptor = SimpleFunctionDescriptorImpl.create(
|
||||||
classDescriptor,
|
classDescriptor,
|
||||||
Annotations.EMPTY,
|
Annotations.EMPTY,
|
||||||
Name.identifier(functionName),
|
Name.identifier(functionName),
|
||||||
@@ -409,7 +409,7 @@ public class DescriptorResolver {
|
|||||||
) {
|
) {
|
||||||
JetType returnType = classDescriptor.getDefaultType();
|
JetType returnType = classDescriptor.getDefaultType();
|
||||||
|
|
||||||
SimpleFunctionDescriptorImpl functionDescriptor = new SimpleFunctionDescriptorImpl(
|
SimpleFunctionDescriptorImpl functionDescriptor = SimpleFunctionDescriptorImpl.create(
|
||||||
classDescriptor,
|
classDescriptor,
|
||||||
Annotations.EMPTY,
|
Annotations.EMPTY,
|
||||||
COPY_METHOD_NAME,
|
COPY_METHOD_NAME,
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ public class FunctionDescriptorUtil {
|
|||||||
@NotNull FunctionDescriptor function,
|
@NotNull FunctionDescriptor function,
|
||||||
@NotNull List<ValueParameterDescriptor> newParameters
|
@NotNull List<ValueParameterDescriptor> newParameters
|
||||||
) {
|
) {
|
||||||
FunctionDescriptorImpl descriptor = new SimpleFunctionDescriptorImpl(
|
FunctionDescriptorImpl descriptor = SimpleFunctionDescriptorImpl.create(
|
||||||
function.getContainingDeclaration(),
|
function.getContainingDeclaration(),
|
||||||
function.getAnnotations(),
|
function.getAnnotations(),
|
||||||
function.getName(),
|
function.getName(),
|
||||||
|
|||||||
+1
-1
@@ -90,7 +90,7 @@ public class ControlStructureTypingUtils {
|
|||||||
|
|
||||||
Name specialFunctionName = Name.identifierNoValidate("<SPECIAL-FUNCTION-FOR-" + constructionName + "-RESOLVE>");
|
Name specialFunctionName = Name.identifierNoValidate("<SPECIAL-FUNCTION-FOR-" + constructionName + "-RESOLVE>");
|
||||||
|
|
||||||
SimpleFunctionDescriptorImpl function = new SimpleFunctionDescriptorImpl(
|
SimpleFunctionDescriptorImpl function = SimpleFunctionDescriptorImpl.create(
|
||||||
ErrorUtils.getErrorModule(),//todo hack to avoid returning true in 'isError(DeclarationDescriptor)'
|
ErrorUtils.getErrorModule(),//todo hack to avoid returning true in 'isError(DeclarationDescriptor)'
|
||||||
Annotations.EMPTY, specialFunctionName, CallableMemberDescriptor.Kind.DECLARATION);
|
Annotations.EMPTY, specialFunctionName, CallableMemberDescriptor.Kind.DECLARATION);
|
||||||
|
|
||||||
|
|||||||
+18
-21
@@ -17,6 +17,7 @@
|
|||||||
package org.jetbrains.jet.lang.resolve.java.descriptor;
|
package org.jetbrains.jet.lang.resolve.java.descriptor;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
||||||
import org.jetbrains.jet.lang.descriptors.SimpleFunctionDescriptor;
|
import org.jetbrains.jet.lang.descriptors.SimpleFunctionDescriptor;
|
||||||
import org.jetbrains.jet.lang.descriptors.annotations.Annotations;
|
import org.jetbrains.jet.lang.descriptors.annotations.Annotations;
|
||||||
@@ -27,26 +28,9 @@ import org.jetbrains.jet.lang.resolve.name.Name;
|
|||||||
public class JavaMethodDescriptor extends SimpleFunctionDescriptorImpl implements JavaCallableMemberDescriptor {
|
public class JavaMethodDescriptor extends SimpleFunctionDescriptorImpl implements JavaCallableMemberDescriptor {
|
||||||
private Boolean hasStableParameterNames = null;
|
private Boolean hasStableParameterNames = null;
|
||||||
|
|
||||||
public JavaMethodDescriptor(
|
|
||||||
@NotNull DeclarationDescriptor containingDeclaration,
|
|
||||||
@NotNull Annotations annotations,
|
|
||||||
@NotNull Name name
|
|
||||||
) {
|
|
||||||
this(containingDeclaration, annotations, name, Kind.DECLARATION);
|
|
||||||
}
|
|
||||||
|
|
||||||
private JavaMethodDescriptor(
|
private JavaMethodDescriptor(
|
||||||
@NotNull DeclarationDescriptor containingDeclaration,
|
@NotNull DeclarationDescriptor containingDeclaration,
|
||||||
@NotNull Annotations annotations,
|
@Nullable SimpleFunctionDescriptor original,
|
||||||
@NotNull Name name,
|
|
||||||
@NotNull Kind kind
|
|
||||||
) {
|
|
||||||
super(containingDeclaration, annotations, name, kind);
|
|
||||||
}
|
|
||||||
|
|
||||||
private JavaMethodDescriptor(
|
|
||||||
@NotNull DeclarationDescriptor containingDeclaration,
|
|
||||||
@NotNull SimpleFunctionDescriptor original,
|
|
||||||
@NotNull Annotations annotations,
|
@NotNull Annotations annotations,
|
||||||
@NotNull Name name,
|
@NotNull Name name,
|
||||||
@NotNull Kind kind
|
@NotNull Kind kind
|
||||||
@@ -54,6 +38,15 @@ public class JavaMethodDescriptor extends SimpleFunctionDescriptorImpl implement
|
|||||||
super(containingDeclaration, original, annotations, name, kind);
|
super(containingDeclaration, original, annotations, name, kind);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public static JavaMethodDescriptor createJavaMethod(
|
||||||
|
@NotNull DeclarationDescriptor containingDeclaration,
|
||||||
|
@NotNull Annotations annotations,
|
||||||
|
@NotNull Name name
|
||||||
|
) {
|
||||||
|
return new JavaMethodDescriptor(containingDeclaration, null, annotations, name, Kind.DECLARATION);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasStableParameterNames() {
|
public boolean hasStableParameterNames() {
|
||||||
assert hasStableParameterNames != null : "hasStableParameterNames was not set: " + this;
|
assert hasStableParameterNames != null : "hasStableParameterNames was not set: " + this;
|
||||||
@@ -66,9 +59,13 @@ public class JavaMethodDescriptor extends SimpleFunctionDescriptorImpl implement
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected FunctionDescriptorImpl createSubstitutedCopy(DeclarationDescriptor newOwner, boolean preserveOriginal, Kind kind) {
|
protected FunctionDescriptorImpl createSubstitutedCopy(DeclarationDescriptor newOwner, boolean preserveOriginal, Kind kind) {
|
||||||
JavaMethodDescriptor result = preserveOriginal
|
JavaMethodDescriptor result = new JavaMethodDescriptor(
|
||||||
? new JavaMethodDescriptor(newOwner, getOriginal(), getAnnotations(), getName(), kind)
|
newOwner,
|
||||||
: new JavaMethodDescriptor(newOwner, getAnnotations(), getName(), kind);
|
preserveOriginal ? getOriginal() : null,
|
||||||
|
getAnnotations(),
|
||||||
|
getName(),
|
||||||
|
kind
|
||||||
|
);
|
||||||
result.setHasStableParameterNames(hasStableParameterNames());
|
result.setHasStableParameterNames(hasStableParameterNames());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -29,7 +29,7 @@ public class SamConstructorDescriptor extends SimpleFunctionDescriptorImpl
|
|||||||
@NotNull ClassOrPackageFragmentDescriptor containingDeclaration,
|
@NotNull ClassOrPackageFragmentDescriptor containingDeclaration,
|
||||||
@NotNull JavaClassDescriptor samInterface
|
@NotNull JavaClassDescriptor samInterface
|
||||||
) {
|
) {
|
||||||
super(containingDeclaration, samInterface.getAnnotations(), samInterface.getName(), Kind.SYNTHESIZED);
|
super(containingDeclaration, null, samInterface.getAnnotations(), samInterface.getName(), Kind.SYNTHESIZED);
|
||||||
this.samInterface = samInterface;
|
this.samInterface = samInterface;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -101,7 +101,7 @@ public abstract class LazyJavaMemberScope(
|
|||||||
|
|
||||||
internal fun resolveMethodToFunctionDescriptor(method: JavaMethod, record: Boolean = true): SimpleFunctionDescriptor {
|
internal fun resolveMethodToFunctionDescriptor(method: JavaMethod, record: Boolean = true): SimpleFunctionDescriptor {
|
||||||
|
|
||||||
val functionDescriptorImpl = JavaMethodDescriptor(_containingDeclaration, c.resolveAnnotations(method), method.getName())
|
val functionDescriptorImpl = JavaMethodDescriptor.createJavaMethod(_containingDeclaration, c.resolveAnnotations(method), method.getName())
|
||||||
|
|
||||||
val c = c.child(functionDescriptorImpl, method.getTypeParameters().toSet())
|
val c = c.child(functionDescriptorImpl, method.getTypeParameters().toSet())
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -26,7 +26,7 @@ import org.jetbrains.jet.lang.resolve.java.descriptor.SamAdapterDescriptor;
|
|||||||
private final SimpleFunctionDescriptor declaration;
|
private final SimpleFunctionDescriptor declaration;
|
||||||
|
|
||||||
public SamAdapterFunctionDescriptor(@NotNull SimpleFunctionDescriptor declaration) {
|
public SamAdapterFunctionDescriptor(@NotNull SimpleFunctionDescriptor declaration) {
|
||||||
super(declaration.getContainingDeclaration(), declaration.getAnnotations(), declaration.getName(), Kind.SYNTHESIZED);
|
super(declaration.getContainingDeclaration(), null, declaration.getAnnotations(), declaration.getName(), Kind.SYNTHESIZED);
|
||||||
this.declaration = declaration;
|
this.declaration = declaration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -27,6 +27,6 @@ public class AnonymousFunctionDescriptor extends SimpleFunctionDescriptorImpl {
|
|||||||
@NotNull Annotations annotations,
|
@NotNull Annotations annotations,
|
||||||
@NotNull Kind kind
|
@NotNull Kind kind
|
||||||
) {
|
) {
|
||||||
super(containingDeclaration, annotations, Name.special("<anonymous>"), kind);
|
super(containingDeclaration, null, annotations, Name.special("<anonymous>"), kind);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-9
@@ -32,15 +32,6 @@ public class SimpleFunctionDescriptorImpl extends FunctionDescriptorImpl impleme
|
|||||||
|
|
||||||
private InlineStrategy inlineStrategy;
|
private InlineStrategy inlineStrategy;
|
||||||
|
|
||||||
public SimpleFunctionDescriptorImpl(
|
|
||||||
@NotNull DeclarationDescriptor containingDeclaration,
|
|
||||||
@NotNull Annotations annotations,
|
|
||||||
@NotNull Name name,
|
|
||||||
@NotNull Kind kind
|
|
||||||
) {
|
|
||||||
this(containingDeclaration, null, annotations, name, kind);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected SimpleFunctionDescriptorImpl(
|
protected SimpleFunctionDescriptorImpl(
|
||||||
@NotNull DeclarationDescriptor containingDeclaration,
|
@NotNull DeclarationDescriptor containingDeclaration,
|
||||||
@Nullable SimpleFunctionDescriptor original,
|
@Nullable SimpleFunctionDescriptor original,
|
||||||
@@ -50,6 +41,16 @@ public class SimpleFunctionDescriptorImpl extends FunctionDescriptorImpl impleme
|
|||||||
super(containingDeclaration, original, annotations, name, kind);
|
super(containingDeclaration, original, annotations, name, kind);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public static SimpleFunctionDescriptorImpl create(
|
||||||
|
@NotNull DeclarationDescriptor containingDeclaration,
|
||||||
|
@NotNull Annotations annotations,
|
||||||
|
@NotNull Name name,
|
||||||
|
@NotNull Kind kind
|
||||||
|
) {
|
||||||
|
return new SimpleFunctionDescriptorImpl(containingDeclaration, null, annotations, name, kind);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -89,8 +89,8 @@ public class DescriptorFactory {
|
|||||||
@NotNull JetType returnType
|
@NotNull JetType returnType
|
||||||
) {
|
) {
|
||||||
SimpleFunctionDescriptorImpl values =
|
SimpleFunctionDescriptorImpl values =
|
||||||
new SimpleFunctionDescriptorImpl(classObject, Annotations.EMPTY, VALUES_METHOD_NAME,
|
SimpleFunctionDescriptorImpl.create(classObject, Annotations.EMPTY, VALUES_METHOD_NAME,
|
||||||
CallableMemberDescriptor.Kind.SYNTHESIZED);
|
CallableMemberDescriptor.Kind.SYNTHESIZED);
|
||||||
return values.initialize(null, classObject.getThisAsReceiverParameter(), Collections.<TypeParameterDescriptor>emptyList(),
|
return values.initialize(null, classObject.getThisAsReceiverParameter(), Collections.<TypeParameterDescriptor>emptyList(),
|
||||||
Collections.<ValueParameterDescriptor>emptyList(),
|
Collections.<ValueParameterDescriptor>emptyList(),
|
||||||
returnType, Modality.FINAL,
|
returnType, Modality.FINAL,
|
||||||
@@ -103,8 +103,8 @@ public class DescriptorFactory {
|
|||||||
@NotNull JetType returnType
|
@NotNull JetType returnType
|
||||||
) {
|
) {
|
||||||
SimpleFunctionDescriptorImpl values =
|
SimpleFunctionDescriptorImpl values =
|
||||||
new SimpleFunctionDescriptorImpl(classObject, Annotations.EMPTY, VALUE_OF_METHOD_NAME,
|
SimpleFunctionDescriptorImpl.create(classObject, Annotations.EMPTY, VALUE_OF_METHOD_NAME,
|
||||||
CallableMemberDescriptor.Kind.SYNTHESIZED);
|
CallableMemberDescriptor.Kind.SYNTHESIZED);
|
||||||
ValueParameterDescriptor parameterDescriptor = new ValueParameterDescriptorImpl(
|
ValueParameterDescriptor parameterDescriptor = new ValueParameterDescriptorImpl(
|
||||||
values,
|
values,
|
||||||
0,
|
0,
|
||||||
|
|||||||
+1
-1
@@ -30,7 +30,7 @@ public class ErrorSimpleFunctionDescriptorImpl extends SimpleFunctionDescriptorI
|
|||||||
private final ErrorUtils.ErrorScope ownerScope;
|
private final ErrorUtils.ErrorScope ownerScope;
|
||||||
|
|
||||||
public ErrorSimpleFunctionDescriptorImpl(ErrorUtils.ErrorScope ownerScope) {
|
public ErrorSimpleFunctionDescriptorImpl(ErrorUtils.ErrorScope ownerScope) {
|
||||||
super(ErrorUtils.getErrorClass(), Annotations.EMPTY, Name.special("<ERROR FUNCTION>"), Kind.DECLARATION);
|
super(ErrorUtils.getErrorClass(), null, Annotations.EMPTY, Name.special("<ERROR FUNCTION>"), Kind.DECLARATION);
|
||||||
this.ownerScope = ownerScope;
|
this.ownerScope = ownerScope;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user