Don't Know How to Generate Class


#1

Again, using Kotlin (script, .kts) for Advent of Code, and something I end up doing frequently is something like:

    File("input.txt").readLines().map(this::parseLine)

If I change it to:

    File("input.txt").readLines().map(::parseLine)

I get this somewhat arcane message:

    Cause: Don't know how to generate outer expression for class Day20
    File being compiled and position: (15,47) in /Users/geoffrey/dev/work/eval/adventofcode/2017/day20/day20.kts
    PsiElement: map(::buildParticle)
    The root cause was thrown at: CodegenContext.java:218
        at org.jetbrains.kotlin.codegen.inline.InlineCodegen.throwCompilationException(InlineCodegen.kt:132)
        at org.jetbrains.kotlin.codegen.inline.InlineCodegen.performInline(InlineCodegen.kt:180)
        at org.jetbrains.kotlin.codegen.inline.PsiInlineCodegen.genCallInner(InlineCodegen.kt:648)
        at org.jetbrains.kotlin.codegen.CallGenerator$DefaultImpls.genCall(CallGenerator.kt:106)
        at org.jetbrains.kotlin.codegen.inline.PsiInlineCodegen.genCall(InlineCodegen.kt:634)
        at org.jetbrains.kotlin.codegen.ExpressionCodegen.invokeMethodWithArguments(ExpressionCodegen.java:2301)
        at org.jetbrains.kotlin.codegen.ExpressionCodegen.invokeMethodWithArguments(ExpressionCodegen.java:2252)
        at org.jetbrains.kotlin.codegen.Callable$invokeMethodWithArguments$1.invoke(Callable.kt:44)
        at org.jetbrains.kotlin.codegen.Callable$invokeMethodWithArguments$1.invoke(Callable.kt:23)
        at org.jetbrains.kotlin.codegen.OperationStackValue.putSelector(StackValue.kt:75)
        at org.jetbrains.kotlin.codegen.StackValue.put(StackValue.java:105)
        at org.jetbrains.kotlin.codegen.StackValue.put(StackValue.java:98)
        at org.jetbrains.kotlin.codegen.StackValue$StackValueWithSimpleReceiver.store(StackValue.java:1682)
        at org.jetbrains.kotlin.codegen.StackValue$Property.store(StackValue.java:1327)
        at org.jetbrains.kotlin.codegen.StackValue.store(StackValue.java:127)
        at org.jetbrains.kotlin.codegen.MemberCodegen.initializeProperty(MemberCodegen.java:530)
        at org.jetbrains.kotlin.codegen.MemberCodegen.generateInitializers(MemberCodegen.java:498)
        at org.jetbrains.kotlin.codegen.ScriptCodegen.genConstructor(ScriptCodegen.java:210)
        at org.jetbrains.kotlin.codegen.ScriptCodegen.generateBody(ScriptCodegen.java:103)
        at org.jetbrains.kotlin.codegen.MemberCodegen.generate(MemberCodegen.java:142)
        at org.jetbrains.kotlin.codegen.PackageCodegenImpl.generateFile(PackageCodegenImpl.java:115)
        at org.jetbrains.kotlin.codegen.PackageCodegenImpl.generate(PackageCodegenImpl.java:66)
        at org.jetbrains.kotlin.codegen.KotlinCodegenFacade.generatePackage(KotlinCodegenFacade.java:100)
        at org.jetbrains.kotlin.codegen.KotlinCodegenFacade.doGenerateFiles(KotlinCodegenFacade.java:78)
        at org.jetbrains.kotlin.codegen.KotlinCodegenFacade.compileCorrectFiles(KotlinCodegenFacade.java:45)
        at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.generate(KotlinToJVMBytecodeCompiler.kt:450)
        at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.analyzeAndGenerate(KotlinToJVMBytecodeCompiler.kt:358)
        at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileScript(KotlinToJVMBytecodeCompiler.kt:330)
        at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileScript$default(KotlinToJVMBytecodeCompiler.kt:329)
        at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileAndExecuteScript$cli(KotlinToJVMBytecodeCompiler.kt:261)
        at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:180)
        at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:61)
        at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.java:107)
        at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.java:51)
        at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:92)
        at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:70)
        at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:36)
        at org.jetbrains.kotlin.cli.common.CLITool$Companion.doMainNoExit(CLITool.kt:157)
        at org.jetbrains.kotlin.cli.common.CLITool$Companion.doMain(CLITool.kt:148)
        at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler$Companion.main(K2JVMCompiler.kt:331)
        at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.main(K2JVMCompiler.kt)
        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:498)
        at org.jetbrains.kotlin.preloading.Preloader.run(Preloader.java:81)
        at org.jetbrains.kotlin.preloading.Preloader.main(Preloader.java:43)
    Caused by: java.lang.UnsupportedOperationException: Don't know how to generate outer expression for class Day20
        at org.jetbrains.kotlin.codegen.context.CodegenContext.getOuterExpression(CodegenContext.java:218)
        at org.jetbrains.kotlin.codegen.context.CodegenContext.lookupInContext(CodegenContext.java:511)
        at org.jetbrains.kotlin.codegen.context.MethodContext.lookupInContext(MethodContext.java:81)
        at org.jetbrains.kotlin.codegen.context.MethodContext.generateReceiver(MethodContext.java:93)
        at org.jetbrains.kotlin.codegen.ExpressionCodegen.generateExtensionReceiver(ExpressionCodegen.java:2540)
        at org.jetbrains.kotlin.codegen.ExpressionCodegen.pushClosureOnStack(ExpressionCodegen.java:1084)
        at org.jetbrains.kotlin.codegen.inline.PsiInlineCodegen.putClosureParametersOnStack(InlineCodegen.kt:672)
        at org.jetbrains.kotlin.codegen.inline.InlineCodegen.putClosureParametersOnStack(InlineCodegen.kt:399)
        at org.jetbrains.kotlin.codegen.inline.InlineCodegen.inlineCall(InlineCodegen.kt:252)
        at org.jetbrains.kotlin.codegen.inline.InlineCodegen.performInline(InlineCodegen.kt:171)
        ... 45 more

    val particles = File("input.txt").readLines().map(::buildParticle)

Is there something I should be doing differently? Compiler bug?