Translate reference to kotlin.Unit to a shorter JS code

This commit is contained in:
Alexey Andreev
2017-07-24 11:50:47 +03:00
parent 2656a6a513
commit 0acc96c4f3
@@ -112,11 +112,17 @@ public final class ReferenceTranslator {
}
if (DescriptorUtils.isObject(descriptor) || DescriptorUtils.isEnumEntry(descriptor)) {
ClassDescriptor classDescriptor = (ClassDescriptor) descriptor;
if (!isLocallyAvailableDeclaration(context, descriptor)) {
return getLazyReferenceToObject((ClassDescriptor) descriptor, context);
if (KotlinBuiltIns.isUnit(classDescriptor.getDefaultType())) {
return context.getInnerReference(descriptor);
}
else {
return getLazyReferenceToObject(classDescriptor, context);
}
}
else {
JsExpression functionRef = JsAstUtils.pureFqn(context.getNameForObjectInstance((ClassDescriptor) descriptor), null);
JsExpression functionRef = JsAstUtils.pureFqn(context.getNameForObjectInstance(classDescriptor), null);
return new JsInvocation(functionRef);
}
}