Error when using the new array literals in annotation


#1

My code

import javax.persistence.*

@Entity
class ShopItem(@Id @GeneratedValue(strategy = GenerationType.AUTO)
               val id: Long = 0,
               @OneToOne(fetch = FetchType.EAGER, cascade = [CascadeType.ALL])
               val item: Item,
               val price: Float)

Throws this error when compiling

Error:Kotlin: [Internal Error] org.jetbrains.kotlin.util.KotlinFrontEndException: Exception while analyzing expression at (8,61) in /Users/me/dev/kotlin/Tori/src/main/kotlin/com/gahvigames/tori/model/ShopItem.kt:
[CascadeType.ALL]

This is what my build.gradle looks like

buildscript {
	ext {
		kotlinVersion = '1.2-M1'
		springBootVersion = '2.0.0.M2'
	}
	repositories {
		mavenCentral()
		maven { url "https://repo.spring.io/snapshot" }
		maven { url "https://repo.spring.io/milestone" }
        maven { url "http://dl.bintray.com/kotlin/kotlin-eap-1.2" }
    }
	dependencies {
		classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
		classpath("org.jetbrains.kotlin:kotlin-allopen:${kotlinVersion}")
		classpath("org.jetbrains.kotlin:kotlin-noarg:${kotlinVersion}")
        classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlinVersion}")
    }
}

apply plugin: 'kotlin'
apply plugin: 'kotlin-jpa'
apply plugin: 'kotlin-spring'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'

version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8
compileKotlin {
	kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
	kotlinOptions.jvmTarget = "1.8"
}

repositories {
	mavenCentral()
	maven { url "https://repo.spring.io/snapshot" }
	maven { url "https://repo.spring.io/milestone" }
	maven { url "http://dl.bintray.com/kotlin/kotlin-eap-1.2" }
}


dependencies {
	compile('org.springframework.boot:spring-boot-starter')
	compile('org.springframework.boot:spring-boot-starter-web')
	compile('org.springframework.boot:spring-boot-starter-data-jpa')
    compile("com.fasterxml.jackson.module:jackson-module-kotlin:2.8.9")
    compile("com.h2database:h2")
	compile("org.jetbrains.kotlin:kotlin-stdlib-jre8:${kotlinVersion}")
	compile("org.jetbrains.kotlin:kotlin-reflect:${kotlinVersion}")
	testCompile('org.springframework.boot:spring-boot-starter-test')
}

Using arrayOf(CascadeType.ALL) works fine, am I doing something wrong here?


#2

Currently I can’t reproduce the problem on an artificial example.
Are you able to share the project sources?


#3

Here you go, running gradle build gives me the error.

code.zip (62.3 KB)


#4

Thank you! Indeed, there is a serious problem on our side, I’ve created an issue in our bugtracker:
https://youtrack.jetbrains.com/issue/KT-18845