Skip to content

Kotlin support #402

Description

@Pear0

Kotlin support would be great and nearly works but Kotlin relies on kotlin/Intrinsics and other stdlib classes for many operations that it performs.

Even the most basic RobotPlayer will be rejected by the instrumenter because Kotlin inserts non-null checks using Intrinsics.requireNonNull.

@file:JvmName("RobotPlayer")

package kotlin_test

import battlecode.common.RobotController

fun run(rc: RobotController) {
    println("Hello World")
}

These particular checks can be disabled with -Xno-param-assertions and -Xno-call-assertions, but Kotlin relies on its stdlib for all kinds of things which can't be disabled.

fun check(x: String?) {
    val y = x!! // inserts call to Intrinsics.throwNpe()
    ...
}
fun listOperations() {
    val a = 1..6 // references kotlin/ranges/IntRange
    val b = a.map { it * 2 } // references kotlin/collections/CollectionsKt
}

I'm using Kotlin 1.0.6 if that matters.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions