KT-7587 Overloads are not generated during partial compilation of package
#KT-7587 fixed
This commit is contained in:
+1
-1
@@ -70,7 +70,7 @@ public class DefaultParameterValueSubstitutor(val state: GenerationState) {
|
||||
* implementation in the companion object class)
|
||||
* @return true if the overloads annotation was found on the element, false otherwise
|
||||
*/
|
||||
fun generateOverloadsIfNeeded(methodElement: JetElement,
|
||||
fun generateOverloadsIfNeeded(methodElement: JetElement?,
|
||||
functionDescriptor: FunctionDescriptor,
|
||||
delegateFunctionDescriptor: FunctionDescriptor,
|
||||
owner: CodegenContext<*>,
|
||||
|
||||
@@ -118,8 +118,11 @@ public class FunctionCodegen {
|
||||
generateOverloadsWithDefaultValues(function, functionDescriptor, functionDescriptor);
|
||||
}
|
||||
|
||||
public void generateOverloadsWithDefaultValues(@NotNull JetNamedFunction function,
|
||||
FunctionDescriptor functionDescriptor, FunctionDescriptor delegateFunctionDescriptor) {
|
||||
public void generateOverloadsWithDefaultValues(
|
||||
@Nullable JetNamedFunction function,
|
||||
@NotNull FunctionDescriptor functionDescriptor,
|
||||
@NotNull FunctionDescriptor delegateFunctionDescriptor
|
||||
) {
|
||||
new DefaultParameterValueSubstitutor(state).generateOverloadsIfNeeded(function,
|
||||
functionDescriptor,
|
||||
delegateFunctionDescriptor,
|
||||
@@ -303,7 +306,11 @@ public class FunctionCodegen {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static Type getThisTypeForFunction(@NotNull FunctionDescriptor functionDescriptor, @NotNull MethodContext context, @NotNull JetTypeMapper typeMapper) {
|
||||
private static Type getThisTypeForFunction(
|
||||
@NotNull FunctionDescriptor functionDescriptor,
|
||||
@NotNull MethodContext context,
|
||||
@NotNull JetTypeMapper typeMapper
|
||||
) {
|
||||
ReceiverParameterDescriptor dispatchReceiver = functionDescriptor.getDispatchReceiverParameter();
|
||||
if (functionDescriptor instanceof ConstructorDescriptor) {
|
||||
return typeMapper.mapType(functionDescriptor);
|
||||
@@ -382,14 +389,15 @@ public class FunctionCodegen {
|
||||
//add this
|
||||
if (thisType != null) {
|
||||
mv.visitLocalVariable("this", thisType.getDescriptor(), null, methodBegin, methodEnd, shift);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
//TODO: provide thisType for callable reference
|
||||
}
|
||||
shift++;
|
||||
}
|
||||
|
||||
for (int i = 0; i < params.size(); i++) {
|
||||
JvmMethodParameterSignature param = params.get(i);
|
||||
JvmMethodParameterSignature param = params.get(i);
|
||||
JvmMethodParameterKind kind = param.getKind();
|
||||
String parameterName;
|
||||
|
||||
@@ -749,7 +757,8 @@ public class FunctionCodegen {
|
||||
) {
|
||||
int flags = ACC_PUBLIC | ACC_BRIDGE | ACC_SYNTHETIC; // TODO.
|
||||
|
||||
MethodVisitor mv = v.newMethod(DiagnosticsPackage.Bridge(descriptor, origin), flags, delegateTo.getName(), bridge.getDescriptor(), null, null);
|
||||
MethodVisitor mv =
|
||||
v.newMethod(DiagnosticsPackage.Bridge(descriptor, origin), flags, delegateTo.getName(), bridge.getDescriptor(), null, null);
|
||||
if (state.getClassBuilderMode() != ClassBuilderMode.FULL) return;
|
||||
|
||||
mv.visitCode();
|
||||
@@ -776,7 +785,8 @@ public class FunctionCodegen {
|
||||
}
|
||||
|
||||
public void genDelegate(@NotNull FunctionDescriptor functionDescriptor, FunctionDescriptor overriddenDescriptor, StackValue field) {
|
||||
genDelegate(functionDescriptor, overriddenDescriptor.getOriginal(), (ClassDescriptor) overriddenDescriptor.getContainingDeclaration(), field);
|
||||
genDelegate(functionDescriptor, overriddenDescriptor.getOriginal(),
|
||||
(ClassDescriptor) overriddenDescriptor.getContainingDeclaration(), field);
|
||||
}
|
||||
|
||||
public void genDelegate(
|
||||
|
||||
@@ -190,6 +190,8 @@ public class PackageCodegen {
|
||||
memberCodegen.functionCodegen.generateDefaultIfNeeded(
|
||||
context.intoFunction(function), function, OwnerKind.PACKAGE, DefaultParameterValueLoader.DEFAULT, null
|
||||
);
|
||||
|
||||
memberCodegen.functionCodegen.generateOverloadsWithDefaultValues(null, function, function);
|
||||
}
|
||||
else if (member instanceof DeserializedPropertyDescriptor) {
|
||||
memberCodegen.propertyCodegen.generateInPackageFacade((DeserializedPropertyDescriptor) member);
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
public final class C {
|
||||
@kotlin.jvm.overloads
|
||||
@org.jetbrains.annotations.NotNull
|
||||
public final java.lang.String foo(@org.jetbrains.annotations.NotNull java.lang.String o, @org.jetbrains.annotations.NotNull java.lang.String s1, @org.jetbrains.annotations.NotNull java.lang.String k, @org.jetbrains.annotations.Nullable java.lang.String s2) { /* compiled code */ }
|
||||
|
||||
@kotlin.jvm.overloads
|
||||
@org.jetbrains.annotations.NotNull
|
||||
public java.lang.String foo(@org.jetbrains.annotations.NotNull java.lang.String p, @org.jetbrains.annotations.NotNull java.lang.String p1, @org.jetbrains.annotations.Nullable java.lang.String p2) { /* compiled code */ }
|
||||
|
||||
@kotlin.jvm.overloads
|
||||
@org.jetbrains.annotations.NotNull
|
||||
public java.lang.String foo(@org.jetbrains.annotations.NotNull java.lang.String p, @org.jetbrains.annotations.Nullable java.lang.String p1) { /* compiled code */ }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user