Internal Error: No descriptor for Type Constructor of Object


#1

I've created two abstract DAO classes called IdentifiableDao and NamedDao with the following code:

``

public abstract class IdentifiableDao<T extends Identifiable> extends AbstractDAO<T> {
  public IdentifiableDao(final SessionFactory factory) {
  super(factory);
  }
  public Optional<T> findById(final UUID id) {
  return Optional.fromNullable(get(id));
  }
  public List<T> findAll() {
  String queryName = String.format(“com.syncofy.core.music.%s.findAll”,
                                   getEntityClass().getSimpleName());
  return list(namedQuery(queryName));
  }
  public UUID create(final T toCreate) {
  return persist(toCreate).getId();
  }
  public Set<UUID> create(Set<T> elementsToCreate) {
  Set<UUID> createdIds = new HashSet<>();
  for (T toCreate : elementsToCreate)
           createdIds.add(create(toCreate));
  return createdIds;
  }
}


and NamedDao:

``

public abstract class NamedDao<T extends Identifiable & Named> extends IdentifiableDao<T> {
  public NamedDao(final SessionFactory factory) {
  super(factory);
  }
  public Optional<T> findByName(final String name) {
  String queryName = String.format(“com.syncofy.core.music.%s.findByName”,
                                           getEntityClass().getSimpleName());
  Query q = namedQuery(queryName);
  q.setParameter(“name”, name);
  return Optional.fromNullable(uniqueResult(q));
  }
  public Set<UUID> createMissing(Set<String> names) {
  Set<UUID> elementIds = new HashSet<>();
  for (String name : names) {
           Optional<T> storedElement = findByName(name);
           if (storedElement.isPresent())
           elementIds.add(storedElement.get().getId());
           else {
           T newElement = newInstance();
           newElement.setName(name);
           elementIds.add(create(newElement));
           }
  }
  return elementIds;
  }

  protected T newInstance() {
  try {
           return getEntityClass().newInstance();
  } catch (InstantiationException e) {
           throw new RuntimeException("Could not create a new instance of type " +getEntityClass().getSimpleName());
  } catch (IllegalAccessException e) {
           throw new RuntimeException("Could not access type " +getEntityClass().getSimpleName());
  }
  }
}


I’ve tried creating a test for each of these Daos using a concrete class that does not override any of these functions, however, I get a very obscure error whenever I try to invoke NamedDao.findByName()

``

class NamedDaoTest : DAOTest() {
  val artistDao = ArtistDao(sessionFactory)
  val brahms = Artist(“Brahms”)
  val mahler = Artist(“Mahler”)
  val schopenhauer = Artist(“Schopenhauer”)
  Before fun setUp() {
  beginTransaction()
  getSession().createQuery(“DELETE FROM Artist”)!!.executeUpdate()
  artistDao.create(setOf(brahms, mahler, schopenhauer))
  endTransaction()
  }
  After fun tearDown() {
  beginTransaction()
  getSession().createQuery(“DELETE FROM Artist”)!!.executeUpdate()
  endTransaction()
  }
  Test fun findByName() {
  beginTransaction()
  assertTrue(artistDao.findByName(“Brahms”)!!.isPresent()) // <— First error here, but happens for every use of findName
  assertEquals(brahms, artistDao.findByName(“Brahms”)!!.get()!!) // <-- If I comment out above, error here, and so forth
  endTransaction()
  }
}


The error:

Kotlin: [Internal Error] org.jetbrains.jet.codegen.CompilationException: Back-end (JVM) Internal error: no descriptor for type constructor of Object Cause: no descriptor for type constructor of Object File being compiled and position: (55,30) in C:/Users/SoulBeaver/Documents/GitHub/syncofy-core/common/src/test/java/com/syncofy/common/db/dao/NamedDaoTest.kt PsiElement: findByName("Two Times Terror") The root cause was thrown at: JetTypeMapper.java:280      at org.jetbrains.jet.codegen.ExpressionCodegen.genQualified(ExpressionCodegen.java:269)      at org.jetbrains.jet.codegen.ExpressionCodegen.genQualified(ExpressionCodegen.java:240)      at org.jetbrains.jet.codegen.ExpressionCodegen.visitDotQualifiedExpression(ExpressionCodegen.java:2618)      at org.jetbrains.jet.codegen.ExpressionCodegen.visitDotQualifiedExpression(ExpressionCodegen.java:83)      at org.jetbrains.jet.lang.psi.JetDotQualifiedExpression.accept(JetDotQualifiedExpression.java:34)      at org.jetbrains.jet.codegen.ExpressionCodegen.genQualified(ExpressionCodegen.java:259)      at org.jetbrains.jet.codegen.ExpressionCodegen.genQualified(ExpressionCodegen.java:240)      at org.jetbrains.jet.codegen.ExpressionCodegen.visitPostfixExpression(ExpressionCodegen.java:3063)      at org.jetbrains.jet.codegen.ExpressionCodegen.visitPostfixExpression(ExpressionCodegen.java:83)      at org.jetbrains.jet.lang.psi.JetPostfixExpression.accept(JetPostfixExpression.java:41)      at org.jetbrains.jet.codegen.ExpressionCodegen.genQualified(ExpressionCodegen.java:259)      at org.jetbrains.jet.codegen.ExpressionCodegen.genQualified(ExpressionCodegen.java:240)      at org.jetbrains.jet.codegen.ExpressionCodegen.gen(ExpressionCodegen.java:275)      at org.jetbrains.jet.codegen.ExpressionCodegen.gen(ExpressionCodegen.java:279)      at org.jetbrains.jet.codegen.ExpressionCodegen.generateFromResolvedCall(ExpressionCodegen.java:2201)      at org.jetbrains.jet.codegen.StackValue$CallReceiver.genReceiver(StackValue.java:1238)      at org.jetbrains.jet.codegen.StackValue$CallReceiver.put(StackValue.java:1217)      at org.jetbrains.jet.codegen.ExpressionCodegen.invokeMethodWithArguments(ExpressionCodegen.java:2140)      at org.jetbrains.jet.codegen.ExpressionCodegen.invokeFunction(ExpressionCodegen.java:2023)      at org.jetbrains.jet.codegen.ExpressionCodegen.visitCallExpression(ExpressionCodegen.java:1925)      at org.jetbrains.jet.codegen.ExpressionCodegen.visitCallExpression(ExpressionCodegen.java:83)      at org.jetbrains.jet.lang.psi.JetCallExpression.accept(JetCallExpression.java:42)      at org.jetbrains.jet.codegen.ExpressionCodegen.genQualified(ExpressionCodegen.java:259)      at org.jetbrains.jet.codegen.ExpressionCodegen.genQualified(ExpressionCodegen.java:240)      at org.jetbrains.jet.codegen.ExpressionCodegen.visitDotQualifiedExpression(ExpressionCodegen.java:2618)      at org.jetbrains.jet.codegen.ExpressionCodegen.visitDotQualifiedExpression(ExpressionCodegen.java:83)      at org.jetbrains.jet.lang.psi.JetDotQualifiedExpression.accept(JetDotQualifiedExpression.java:34)      at org.jetbrains.jet.codegen.ExpressionCodegen.genQualified(ExpressionCodegen.java:259)      at org.jetbrains.jet.codegen.ExpressionCodegen.genQualified(ExpressionCodegen.java:240)      at org.jetbrains.jet.codegen.ExpressionCodegen.gen(ExpressionCodegen.java:275)      at org.jetbrains.jet.codegen.ExpressionCodegen.gen(ExpressionCodegen.java:279)      at org.jetbrains.jet.codegen.ExpressionCodegen.pushMethodArguments(ExpressionCodegen.java:2349)      at org.jetbrains.jet.codegen.ExpressionCodegen.pushArgumentsAndInvoke(ExpressionCodegen.java:2147)      at org.jetbrains.jet.codegen.ExpressionCodegen.invokeMethodWithArguments(ExpressionCodegen.java:2143)      at org.jetbrains.jet.codegen.ExpressionCodegen.invokeFunction(ExpressionCodegen.java:2023)      at org.jetbrains.jet.codegen.ExpressionCodegen.visitCallExpression(ExpressionCodegen.java:1925)      at org.jetbrains.jet.codegen.ExpressionCodegen.visitCallExpression(ExpressionCodegen.java:83)      at org.jetbrains.jet.lang.psi.JetCallExpression.accept(JetCallExpression.java:42)      at org.jetbrains.jet.codegen.CodegenStatementVisitor.visitJetElement(CodegenStatementVisitor.java:31)      at org.jetbrains.jet.codegen.CodegenStatementVisitor.visitJetElement(CodegenStatementVisitor.java:22)      at org.jetbrains.jet.lang.psi.JetVisitor.visitExpression(JetVisitor.java:154)      at org.jetbrains.jet.lang.psi.JetVisitor.visitCallExpression(JetVisitor.java:246)      at org.jetbrains.jet.lang.psi.JetCallExpression.accept(JetCallExpression.java:42)      at org.jetbrains.jet.codegen.ExpressionCodegen.genQualified(ExpressionCodegen.java:259)      at org.jetbrains.jet.codegen.ExpressionCodegen.genStatement(ExpressionCodegen.java:288)      at org.jetbrains.jet.codegen.ExpressionCodegen.generateBlock(ExpressionCodegen.java:1447)      at org.jetbrains.jet.codegen.ExpressionCodegen.visitBlockExpression(ExpressionCodegen.java:1306)      at org.jetbrains.jet.codegen.ExpressionCodegen.visitBlockExpression(ExpressionCodegen.java:83)      at org.jetbrains.jet.lang.psi.JetBlockExpression.accept(JetBlockExpression.java:47)      at org.jetbrains.jet.codegen.ExpressionCodegen.genQualified(ExpressionCodegen.java:259)      at org.jetbrains.jet.codegen.ExpressionCodegen.genQualified(ExpressionCodegen.java:240)      at org.jetbrains.jet.codegen.ExpressionCodegen.gen(ExpressionCodegen.java:275)      at org.jetbrains.jet.codegen.ExpressionCodegen.returnExpression(ExpressionCodegen.java:1608)      at org.jetbrains.jet.codegen.FunctionGenerationStrategy$FunctionDefault.doGenerateBody(FunctionGenerationStrategy.java:83)      at org.jetbrains.jet.codegen.FunctionGenerationStrategy$CodegenBased.generateBody(FunctionGenerationStrategy.java:106)      at org.jetbrains.jet.codegen.FunctionCodegen.generateMethodBody(FunctionCodegen.java:296)      at org.jetbrains.jet.codegen.FunctionCodegen.generateMethod(FunctionCodegen.java:146)      at org.jetbrains.jet.codegen.FunctionCodegen.generateMethod(FunctionCodegen.java:97)      at org.jetbrains.jet.codegen.FunctionCodegen.gen(FunctionCodegen.java:83)      at org.jetbrains.jet.codegen.MemberCodegen.genFunctionOrProperty(MemberCodegen.java:47)      at org.jetbrains.jet.codegen.ClassBodyCodegen.generateDeclaration(ClassBodyCodegen.java:116)      at org.jetbrains.jet.codegen.ImplementationBodyCodegen.generateDeclaration(ImplementationBodyCodegen.java:1594)      at org.jetbrains.jet.codegen.ClassBodyCodegen.generateClassBody(ClassBodyCodegen.java:102)      at org.jetbrains.jet.codegen.ClassBodyCodegen.generate(ClassBodyCodegen.java:69)      at org.jetbrains.jet.codegen.MemberCodegen.genClassOrObject(MemberCodegen.java:91)      at org.jetbrains.jet.codegen.NamespaceCodegen.generateClassOrObject(NamespaceCodegen.java:206)      at org.jetbrains.jet.codegen.NamespaceCodegen.generate(NamespaceCodegen.java:178)      at org.jetbrains.jet.codegen.NamespaceCodegen.generate(NamespaceCodegen.java:113)      at org.jetbrains.jet.codegen.KotlinCodegenFacade.generateNamespace(KotlinCodegenFacade.java:71)      at org.jetbrains.jet.codegen.KotlinCodegenFacade.compileCorrectFiles(KotlinCodegenFacade.java:60)      at org.jetbrains.jet.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.generate(KotlinToJVMBytecodeCompiler.java:300)      at org.jetbrains.jet.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.analyzeAndGenerate(KotlinToJVMBytecodeCompiler.java:261)      at org.jetbrains.jet.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModule(KotlinToJVMBytecodeCompiler.java:103)      at org.jetbrains.jet.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules(KotlinToJVMBytecodeCompiler.java:139)      at org.jetbrains.jet.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.java:132)      at org.jetbrains.jet.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.java:48)      at org.jetbrains.jet.cli.common.CLICompiler.exec(CLICompiler.java:152)      at org.jetbrains.jet.cli.common.CLICompiler.exec(CLICompiler.java:138)      at org.jetbrains.jet.cli.common.CLICompiler.exec(CLICompiler.java:57)      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)      at java.lang.reflect.Method.invoke(Method.java:606)      at org.jetbrains.jet.compiler.runner.CompilerRunnerUtil.invokeExecMethod(CompilerRunnerUtil.java:121)      at org.jetbrains.jet.compiler.runner.KotlinCompilerRunner.execCompiler(KotlinCompilerRunner.java:111)      at org.jetbrains.jet.compiler.runner.KotlinCompilerRunner.access$000(KotlinCompilerRunner.java:39)      at org.jetbrains.jet.compiler.runner.KotlinCompilerRunner$1.fun(KotlinCompilerRunner.java:94)      at org.jetbrains.jet.compiler.runner.KotlinCompilerRunner$1.fun(KotlinCompilerRunner.java:91)      at org.jetbrains.jet.compiler.runner.CompilerRunnerUtil.outputCompilerMessagesAndHandleExitCode(CompilerRunnerUtil.java:130)      at org.jetbrains.jet.compiler.runner.KotlinCompilerRunner.runCompiler(KotlinCompilerRunner.java:91)      at org.jetbrains.jet.compiler.runner.KotlinCompilerRunner.runK2JvmCompiler(KotlinCompilerRunner.java:57)      at org.jetbrains.jet.jps.build.KotlinBuilder.build(KotlinBuilder.java:168)      at org.jetbrains.jps.incremental.IncProjectBuilder.runModuleLevelBuilders(IncProjectBuilder.java:1084)      at org.jetbrains.jps.incremental.IncProjectBuilder.runBuildersForChunk(IncProjectBuilder.java:801)      at org.jetbrains.jps.incremental.IncProjectBuilder.buildTargetsChunk(IncProjectBuilder.java:849)      at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunkIfAffected(IncProjectBuilder.java:764)      at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunks(IncProjectBuilder.java:587)      at org.jetbrains.jps.incremental.IncProjectBuilder.runBuild(IncProjectBuilder.java:344)      at org.jetbrains.jps.incremental.IncProjectBuilder.build(IncProjectBuilder.java:184)      at org.jetbrains.jps.cmdline.BuildRunner.runBuild(BuildRunner.java:129)      at org.jetbrains.jps.cmdline.BuildSession.runBuild(BuildSession.java:224)      at org.jetbrains.jps.cmdline.BuildSession.run(BuildSession.java:113)      at org.jetbrains.jps.cmdline.BuildMain$MyMessageHandler$1.run(BuildMain.java:133)      at org.jetbrains.jps.service.impl.SharedThreadPoolImpl$1.run(SharedThreadPoolImpl.java:41)      at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)      at java.util.concurrent.FutureTask.run(FutureTask.java:262)      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)      at java.lang.Thread.run(Thread.java:744) Caused by: java.lang.UnsupportedOperationException: no descriptor for type constructor of Object      at org.jetbrains.jet.codegen.state.JetTypeMapper.mapType(JetTypeMapper.java:280)      at org.jetbrains.jet.codegen.state.JetTypeMapper.mapType(JetTypeMapper.java:235)      at org.jetbrains.jet.codegen.state.JetTypeMapper.mapType(JetTypeMapper.java:205)      at org.jetbrains.jet.codegen.state.JetTypeMapper.mapType(JetTypeMapper.java:325)      at org.jetbrains.jet.codegen.state.JetTypeMapper.mapType(JetTypeMapper.java:235)      at org.jetbrains.jet.codegen.state.JetTypeMapper.writeGenericType(JetTypeMapper.java:382)      at org.jetbrains.jet.codegen.state.JetTypeMapper.mapType(JetTypeMapper.java:319)      at org.jetbrains.jet.codegen.state.JetTypeMapper.mapReturnType(JetTypeMapper.java:200)      at org.jetbrains.jet.codegen.state.JetTypeMapper.mapSignature(JetTypeMapper.java:636)      at org.jetbrains.jet.codegen.state.JetTypeMapper.mapSignature(JetTypeMapper.java:593)      at org.jetbrains.jet.codegen.state.JetTypeMapper.mapToCallableMethod(JetTypeMapper.java:451)      at org.jetbrains.jet.codegen.ExpressionCodegen.resolveToCallableMethod(ExpressionCodegen.java:2105)      at org.jetbrains.jet.codegen.ExpressionCodegen.resolveToCallable(ExpressionCodegen.java:2095)      at org.jetbrains.jet.codegen.ExpressionCodegen.invokeFunction(ExpressionCodegen.java:2020)      at org.jetbrains.jet.codegen.ExpressionCodegen.visitCallExpression(ExpressionCodegen.java:1925)      at org.jetbrains.jet.codegen.ExpressionCodegen.visitCallExpression(ExpressionCodegen.java:83)      at org.jetbrains.jet.lang.psi.JetCallExpression.accept(JetCallExpression.java:42)      at org.jetbrains.jet.codegen.ExpressionCodegen.genQualified(ExpressionCodegen.java:259)      ... 108 more

IDE:  Intellij IDEA 13.0.2 Kotlin Plugin: 0.6.1673


#2

Your bug seems to be already fixed in current version of Kotlin compiler.

Minimal reproducible case for 1.6.1673:

fun <T : Comparable<T>> f() where T : CharSequence
{
}

fun main(args: Array<String>) {
  f<String>()
}


P. S. It was pretty tough to reproduce without code for “ArtistDao” and other. It would be really great if you extracted minimal reproducible sample which causes bug. It saves time.


#3

I'm very sorry about that! I was thinking that I could share a minimal example if a cursory glance didn't produce any suggestions- you actually made a minimal example? My apologies, I'll provide a minimal working sample from now on.

As to the current version of the Kotlin compiler. I’m currently using the plugin, but I’d have to build the Kotlin compiler from source if I wanted the fix right now, right? Do you have an ETA on when a new version is coming out so I can gauge whether or not it’s worth the effort?


#4

No need to build from sources, you can use nighly builds, see "http://confluence.jetbrains.com/display/Kotlin/Getting+Started">Getting Started" page for details. The next milestone version may be available in a few weeks.

If you decide to use nighly builds, be careful that we are going to require IDEA 13.1 EAP by default one of the next days. IDEA 13.0.x will be still supported, but with different plugin repository URL. Details will be published on “Getting Started” page.