Support JVM target versions up to 12

#KT-26240 Fixed
This commit is contained in:
Alexander Udalov
2019-03-01 21:54:29 +01:00
parent 9f75fd0d62
commit 518b03125c
7 changed files with 24 additions and 15 deletions
@@ -14,6 +14,7 @@
* limitations under the License.
*/
package org.jetbrains.kotlin.config
import org.jetbrains.org.objectweb.asm.Opcodes
@@ -21,10 +22,13 @@ import org.jetbrains.org.objectweb.asm.Opcodes
enum class JvmTarget(override val description: String) : TargetPlatformVersion {
JVM_1_6("1.6"),
JVM_1_8("1.8"),
JVM_9("9"),
JVM_10("10"),
JVM_11("11"),
JVM_12("12"),
;
val bytecodeVersion: Int by lazy {
@Suppress("DEPRECATION")
when (this) {
JVM_1_6 -> Opcodes.V1_6
JVM_1_8 ->
@@ -33,6 +37,10 @@ enum class JvmTarget(override val description: String) : TargetPlatformVersion {
java.lang.Boolean.valueOf(System.getProperty("kotlin.test.substitute.bytecode.1.8.to.1.9")) -> Opcodes.V9
else -> Opcodes.V1_8
}
JVM_9 -> Opcodes.V9
JVM_10 -> Opcodes.V9 + 1
JVM_11 -> Opcodes.V9 + 2
JVM_12 -> Opcodes.V9 + 3
}
}
@@ -44,16 +52,13 @@ enum class JvmTarget(override val description: String) : TargetPlatformVersion {
fun fromString(string: String) = values().find { it.description == string }
fun getDescription(bytecodeVersion: Int): String {
@Suppress("DEPRECATION")
val platformDescription = values().find { it.bytecodeVersion == bytecodeVersion }?.description ?:
when (bytecodeVersion) {
Opcodes.V1_7 -> "1.7"
Opcodes.V9 -> "1.9"
else -> null
}
val platformDescription = values().find { it.bytecodeVersion == bytecodeVersion }?.description ?: when (bytecodeVersion) {
Opcodes.V1_7 -> "1.7"
else -> null
}
return if (platformDescription != null) "JVM target $platformDescription"
else "JVM bytecode version $bytecodeVersion"
else "JVM bytecode version $bytecodeVersion"
}
}
}
@@ -41,7 +41,7 @@ import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm.*
class InterfaceDefaultMethodCallChecker(val jvmTarget: JvmTarget) : CallChecker {
override fun check(resolvedCall: ResolvedCall<*>, reportOn: PsiElement, context: CallCheckerContext) {
val supportDefaults = jvmTarget == JvmTarget.JVM_1_8
val supportDefaults = jvmTarget >= JvmTarget.JVM_1_8
val descriptor = resolvedCall.resultingDescriptor as? CallableMemberDescriptor ?: return
if (descriptor is JavaPropertyDescriptor) return