Force resolve companion in light class generation

This commit is contained in:
Michael Bogdanov
2015-12-11 15:17:21 +03:00
parent a849f3f5d4
commit 39d9b35e27
2 changed files with 5 additions and 7 deletions
@@ -282,11 +282,7 @@ public abstract class CodegenContext<T extends DeclarationDescriptor> {
}
ClassContext classContext = new ClassContext(state.getTypeMapper(), descriptor, kind, this, null);
//We can't call descriptor.getCompanionObjectDescriptor() on light class generation
// because it triggers companion light class generation via putting it to BindingContext.CLASS
// (so MemberCodegen doesn't skip it in genClassOrObject).
if (state.getTypeMapper().getClassBuilderMode() != ClassBuilderMode.LIGHT_CLASSES &&
descriptor.getCompanionObjectDescriptor() != null) {
if (descriptor.getCompanionObjectDescriptor() != null) {
//We need to create companion object context ahead of time
// because otherwise we can't generate synthetic accessor for private members in companion object
classContext.intoClass(descriptor.getCompanionObjectDescriptor(), OwnerKind.IMPLEMENTATION, state);
@@ -80,11 +80,13 @@ public class CliLightClassGenerationSupport(project: Project) : LightClassGenera
}
override fun getContextForPackage(files: Collection<KtFile>): LightClassConstructionContext {
return getContext()
return LightClassConstructionContext(bindingContext, module)
}
override fun getContextForClassOrObject(classOrObject: KtClassOrObject): LightClassConstructionContext {
return getContext()
//force resolve companion for light class generation
bindingContext.get(BindingContext.CLASS, classOrObject)?.companionObjectDescriptor
return LightClassConstructionContext(bindingContext, module)
}
private fun getContext(): LightClassConstructionContext {