Using kotlin.nullable

I am having issues making use of kotlin.nullables extension methods and would appreciate some guidance.

My code is pretty simple,

package Kotlin101

import kotlin.nullable

fun main (args : Array<String>){

  var x: String? = "james"

  x.map({ it + "asdasdasdasd" })

}

But the nullable string doesn’t appear to get extended with the methods.  If I copy and paste the map function into my file it compiles but wont run due to the error (listed at the end).  Can anyone illuminate me as to what I am doing wrong here please?

org.jetbrains.jet.codegen.CompilationException: Back-end (JVM) Internal error: error types are not allowed when classBuilderMode = FULL

Cause: error types are not allowed when classBuilderMode = FULL

File being compiled and position: (14,7) in /Users/kouphax/Projects/tinkering/kotlin-tinkering/src/Jumps.kt

The root cause was thrown at: JetTypeMapper.java:410

at org.jetbrains.jet.codegen.ExpressionCodegen.genQualified(ExpressionCodegen.java:173)

at org.jetbrains.jet.codegen.ExpressionCodegen.visitDotQualifiedExpression(ExpressionCodegen.java:1737)

at org.jetbrains.jet.codegen.ExpressionCodegen.visitDotQualifiedExpression(ExpressionCodegen.java:62)

at org.jetbrains.jet.lang.psi.JetDotQualifiedExpression.accept(JetDotQualifiedExpression.java:37)

at org.jetbrains.jet.codegen.ExpressionCodegen.genQualified(ExpressionCodegen.java:163)

at org.jetbrains.jet.codegen.ExpressionCodegen.gen(ExpressionCodegen.java:178)

at org.jetbrains.jet.codegen.ExpressionCodegen.generateBlock(ExpressionCodegen.java:881)

at org.jetbrains.jet.codegen.ExpressionCodegen.visitBlockExpression(ExpressionCodegen.java:737)

at org.jetbrains.jet.codegen.ExpressionCodegen.visitBlockExpression(ExpressionCodegen.java:62)

at org.jetbrains.jet.lang.psi.JetBlockExpression.accept(JetBlockExpression.java:50)

at org.jetbrains.jet.codegen.ExpressionCodegen.genQualified(ExpressionCodegen.java:163)

at org.jetbrains.jet.codegen.ExpressionCodegen.gen(ExpressionCodegen.java:178)

at org.jetbrains.jet.codegen.ExpressionCodegen.returnExpression(ExpressionCodegen.java:977)

at org.jetbrains.jet.codegen.FunctionCodegen.generatedMethod(FunctionCodegen.java:262)

at org.jetbrains.jet.codegen.FunctionCodegen.generateMethod(FunctionCodegen.java:75)

at org.jetbrains.jet.codegen.FunctionCodegen.gen(FunctionCodegen.java:65)

at org.jetbrains.jet.codegen.MemberCodegen.generateFunctionOrProperty(MemberCodegen.java:45)

at org.jetbrains.jet.codegen.NamespaceCodegen.generate(NamespaceCodegen.java:140)

at org.jetbrains.jet.codegen.NamespaceCodegen.generate(NamespaceCodegen.java:109)

at org.jetbrains.jet.codegen.GenerationState.generateNamespace(GenerationState.java:180)

at org.jetbrains.jet.codegen.GenerationState.compileCorrectFiles(GenerationState.java:156)

at org.jetbrains.jet.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.generate(KotlinToJVMBytecodeCompiler.java:279)

at org.jetbrains.jet.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.analyzeAndGenerate(KotlinToJVMBytecodeCompiler.java:232)

at org.jetbrains.jet.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.analyzeAndGenerate(KotlinToJVMBytecodeCompiler.java:216)

at org.jetbrains.jet.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModule(KotlinToJVMBytecodeCompiler.java:80)

at org.jetbrains.jet.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules(KotlinToJVMBytecodeCompiler.java:101)

at org.jetbrains.jet.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.java:117)

at org.jetbrains.jet.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.java:49)

at org.jetbrains.jet.cli.common.CLICompiler.exec(CLICompiler.java:117)

at org.jetbrains.jet.cli.jvm.K2JVMCompiler.exec(K2JVMCompiler.java:188)

at org.jetbrains.jet.cli.jvm.K2JVMCompiler.exec(K2JVMCompiler.java:49)

at org.jetbrains.jet.cli.common.CLICompiler.exec(CLICompiler.java:47)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:597)

at org.jetbrains.jet.plugin.compiler.CompilerUtils.invokeExecMethod(CompilerUtils.java:175)

at org.jetbrains.jet.plugin.compiler.JetCompiler.execInProcess(JetCompiler.java:248)

at org.jetbrains.jet.plugin.compiler.JetCompiler.access$000(JetCompiler.java:54)

at org.jetbrains.jet.plugin.compiler.JetCompiler$1.invoke(JetCompiler.java:235)

at org.jetbrains.jet.plugin.compiler.JetCompiler$1.invoke(JetCompiler.java:232)

at org.jetbrains.jet.plugin.compiler.CompilerUtils.outputCompilerMessagesAndHandleExitCode(CompilerUtils.java:314)

at org.jetbrains.jet.plugin.compiler.JetCompiler.runInProcess(JetCompiler.java:232)

at org.jetbrains.jet.plugin.compiler.JetCompiler.runCompiler(JetCompiler.java:139)

at org.jetbrains.jet.plugin.compiler.JetCompiler.doCompile(JetCompiler.java:127)

at org.jetbrains.jet.plugin.compiler.JetCompiler.compile(JetCompiler.java:102)

at com.intellij.compiler.impl.CompileDriver.compileSources(CompileDriver.java:1931)

at com.intellij.compiler.impl.CompileDriver.translate(CompileDriver.java:1254)

at com.intellij.compiler.impl.CompileDriver.doCompile(CompileDriver.java:986)

at com.intellij.compiler.impl.CompileDriver.doCompile(CompileDriver.java:747)

at com.intellij.compiler.impl.CompileDriver.access$1000(CompileDriver.java:104)

at com.intellij.compiler.impl.CompileDriver$8.run(CompileDriver.java:665)

at com.intellij.compiler.progress.CompilerTask.run(CompilerTask.java:155)

at com.intellij.openapi.progress.impl.ProgressManagerImpl$TaskRunnable.run(ProgressManagerImpl.java:469)

at com.intellij.openapi.progress.impl.ProgressManagerImpl$2.run(ProgressManagerImpl.java:178)

at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:218)

at com.intellij.openapi.progress.impl.ProgressManagerImpl.runProcess(ProgressManagerImpl.java:169)

at com.intellij.openapi.progress.impl.ProgressManagerImpl$8.run(ProgressManagerImpl.java:378)

at com.intellij.openapi.application.impl.ApplicationImpl$6.run(ApplicationImpl.java:434)

at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)

at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)

at java.util.concurrent.FutureTask.run(FutureTask.java:138)

at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)

at java.lang.Thread.run(Thread.java:680)

at com.intellij.openapi.application.impl.ApplicationImpl$1$1.run(ApplicationImpl.java:145)

Caused by: java.lang.IllegalStateException: error types are not allowed when classBuilderMode = FULL

at org.jetbrains.jet.codegen.JetTypeMapper.mapType(JetTypeMapper.java:410)

at org.jetbrains.jet.codegen.JetTypeMapper.mapReturnType(JetTypeMapper.java:269)

at org.jetbrains.jet.codegen.JetTypeMapper.mapReturnType(JetTypeMapper.java:247)

at org.jetbrains.jet.codegen.ExpressionCodegen.returnValueAsStackValue(ExpressionCodegen.java:1380)

at org.jetbrains.jet.codegen.ExpressionCodegen.invokeFunction(ExpressionCodegen.java:1364)

at org.jetbrains.jet.codegen.ExpressionCodegen.visitCallExpression(ExpressionCodegen.java:1323)

at org.jetbrains.jet.codegen.ExpressionCodegen.visitCallExpression(ExpressionCodegen.java:62)

at org.jetbrains.jet.lang.psi.JetCallExpression.accept(JetCallExpression.java:45)

at org.jetbrains.jet.codegen.ExpressionCodegen.genQualified(ExpressionCodegen.java:163)

... 65 more

OK so as I suspected it was me being stupid.

Rather than import kotlin.nullable I should have imported kotlin.nullable.*

Problem solved :slight_smile:

But this is still a bug, I guess. Mine to report it to the tracker? Thanks.