Compiler crush on extending inner class


#1

 

package inner

open class A {
  inner open class Child {

  }
}

class ExtA : A(){
  inner class ExtChild : A.Child(){

  }
}

Output:

Information:Kotlin: Kotlin JPS plugin version 0.12.613.Idea141.7 Information:Kotlin: Using kotlin-home = C:Usersadmin.IntelliJIdea14configpluginsKotlinkotlinc Information:Kotlin: Kotlin Compiler version 0.12.613 Information:29.06.2015 6:27 - Compilation completed with 2 errors and 0 warnings in 2s 67ms Error:Kotlin: [Internal Error] java.lang.RuntimeException: Error generating constructors of class ExtChild with kind IMPLEMENTATION   at org.jetbrains.kotlin.codegen.ImplementationBodyCodegen.generateSyntheticParts(ImplementationBodyCodegen.java:357)   at org.jetbrains.kotlin.codegen.MemberCodegen.generate(MemberCodegen.java:111)   at org.jetbrains.kotlin.codegen.MemberCodegen.genClassOrObject(MemberCodegen.java:201)   at org.jetbrains.kotlin.codegen.MemberCodegen.genClassOrObject(MemberCodegen.java:218)   at org.jetbrains.kotlin.codegen.ClassBodyCodegen.generateDeclaration(ClassBodyCodegen.java:100)   at org.jetbrains.kotlin.codegen.ClassBodyCodegen.generateBody(ClassBodyCodegen.java:61)   at org.jetbrains.kotlin.codegen.MemberCodegen.generate(MemberCodegen.java:109)   at org.jetbrains.kotlin.codegen.MemberCodegen.genClassOrObject(MemberCodegen.java:201)   at org.jetbrains.kotlin.codegen.PackageCodegen.generateClassOrObject(PackageCodegen.java:398)   at org.jetbrains.kotlin.codegen.PackageCodegen.generate(PackageCodegen.java:308)   at org.jetbrains.kotlin.codegen.PackageCodegen.generate(PackageCodegen.java:214)   at org.jetbrains.kotlin.codegen.KotlinCodegenFacade.generatePackage(KotlinCodegenFacade.java:80)   at org.jetbrains.kotlin.codegen.KotlinCodegenFacade.compileCorrectFiles(KotlinCodegenFacade.java:67)   at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.generate(KotlinToJVMBytecodeCompiler.java:384)   at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules(KotlinToJVMBytecodeCompiler.java:145)   at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.java:178)   at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.java:53)   at org.jetbrains.kotlin.cli.common.CLICompiler.exec(CLICompiler.java:148)   at org.jetbrains.kotlin.cli.common.CLICompiler.exec(CLICompiler.java:128)   at org.jetbrains.kotlin.cli.common.CLICompiler.execAndOutputXml(CLICompiler.java:58)   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)   at java.lang.reflect.Method.invoke(Method.java:497)   at org.jetbrains.kotlin.compilerRunner.CompilerRunnerUtil.invokeExecMethod(CompilerRunnerUtil.java:92)   at org.jetbrains.kotlin.compilerRunner.KotlinCompilerRunner.execCompiler(KotlinCompilerRunner.java:119)   at org.jetbrains.kotlin.compilerRunner.KotlinCompilerRunner.runCompiler(KotlinCompilerRunner.java:94)   at org.jetbrains.kotlin.compilerRunner.KotlinCompilerRunner.runK2JvmCompiler(KotlinCompilerRunner.java:63)   at org.jetbrains.kotlin.jps.build.KotlinBuilder.compileToJvm(KotlinBuilder.kt:466)   at org.jetbrains.kotlin.jps.build.KotlinBuilder.doCompileModuleChunk(KotlinBuilder.kt:233)   at org.jetbrains.kotlin.jps.build.KotlinBuilder.build(KotlinBuilder.kt:134)   at org.jetbrains.jps.incremental.IncProjectBuilder.runModuleLevelBuilders(IncProjectBuilder.java:1196)   at org.jetbrains.jps.incremental.IncProjectBuilder.runBuildersForChunk(IncProjectBuilder.java:877)   at org.jetbrains.jps.incremental.IncProjectBuilder.buildTargetsChunk(IncProjectBuilder.java:945)   at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunkIfAffected(IncProjectBuilder.java:840)   at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunks(IncProjectBuilder.java:663)   at org.jetbrains.jps.incremental.IncProjectBuilder.runBuild(IncProjectBuilder.java:370)   at org.jetbrains.jps.incremental.IncProjectBuilder.build(IncProjectBuilder.java:191)   at org.jetbrains.jps.cmdline.BuildRunner.runBuild(BuildRunner.java:137)   at org.jetbrains.jps.cmdline.BuildSession.runBuild(BuildSession.java:293)   at org.jetbrains.jps.cmdline.BuildSession.run(BuildSession.java:124)   at org.jetbrains.jps.cmdline.BuildMain$MyMessageHandler$1.run(BuildMain.java:242)   at org.jetbrains.jps.service.impl.SharedThreadPoolImpl$1.run(SharedThreadPoolImpl.java:41)   at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)   at java.util.concurrent.FutureTask.run(FutureTask.java:266)   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)   at java.lang.Thread.run(Thread.java:745) Caused by: java.lang.UnsupportedOperationException: Don't know how to generate outer expression for lazy class ExtA   at org.jetbrains.kotlin.codegen.context.CodegenContext.getOuterExpression(CodegenContext.java:124)   at org.jetbrains.kotlin.codegen.context.CodegenContext.getOuterExpression(CodegenContext.java:118)   at org.jetbrains.kotlin.codegen.ExpressionCodegen.generateThisOrOuter(ExpressionCodegen.java:2577)   at org.jetbrains.kotlin.codegen.ImplementationBodyCodegen.generateSuperCallImplicitArguments(ImplementationBodyCodegen.java:1530)   at org.jetbrains.kotlin.codegen.ImplementationBodyCodegen.generateDelegatorToConstructorCall(ImplementationBodyCodegen.java:1480)   at org.jetbrains.kotlin.codegen.ImplementationBodyCodegen.generatePrimaryConstructorImpl(ImplementationBodyCodegen.java:1100)   at org.jetbrains.kotlin.codegen.ImplementationBodyCodegen.access$400(ImplementationBodyCodegen.java:96)   at org.jetbrains.kotlin.codegen.ImplementationBodyCodegen$4.doGenerateBody(ImplementationBodyCodegen.java:1053)   at org.jetbrains.kotlin.codegen.FunctionGenerationStrategy$CodegenBased.generateBody(FunctionGenerationStrategy.java:72)   at org.jetbrains.kotlin.codegen.FunctionCodegen.generateMethodBody(FunctionCodegen.java:363)   at org.jetbrains.kotlin.codegen.FunctionCodegen.generateMethod(FunctionCodegen.java:202)   at org.jetbrains.kotlin.codegen.ImplementationBodyCodegen.generatePrimaryConstructor(ImplementationBodyCodegen.java:1049)   at org.jetbrains.kotlin.codegen.ImplementationBodyCodegen.generateSyntheticParts(ImplementationBodyCodegen.java:345)   ... 47 more Error:Kotlin: Compiler terminated with internal error

Sometimes compiler dont crush and just tells:

Error:(10, 33) Kotlin: Unresolved reference: Child


#2

This is a known problem, see KT-7421.

The only workarounds we know of are either to make Child non-inner, or to inherit from it in Java (see the linked issue for details).