JVM IR: Remove type substitutions from ExpressionCodegen
Instead, determine whether the return type of a call is Nothing, by looking at the type of the call expression.
This commit is contained in:
committed by
max-kammerer
parent
2f0f4e570f
commit
aea5e3ffbc
+3
-4
@@ -453,9 +453,8 @@ class ExpressionCodegen(
|
|||||||
addInlineMarker(mv, isStartNotEnd = false)
|
addInlineMarker(mv, isStartNotEnd = false)
|
||||||
}
|
}
|
||||||
|
|
||||||
val returnType = callee.returnType
|
|
||||||
return when {
|
return when {
|
||||||
returnType.substitute(expression.typeSubstitutionMap).isNothing() -> {
|
expression.type.isNothing() -> {
|
||||||
mv.aconst(null)
|
mv.aconst(null)
|
||||||
mv.athrow()
|
mv.athrow()
|
||||||
immaterialUnitValue
|
immaterialUnitValue
|
||||||
@@ -467,9 +466,9 @@ class ExpressionCodegen(
|
|||||||
immaterialUnitValue
|
immaterialUnitValue
|
||||||
expression.type.isUnit() ->
|
expression.type.isUnit() ->
|
||||||
// NewInference allows casting `() -> T` to `() -> Unit`. A CHECKCAST here will fail.
|
// NewInference allows casting `() -> T` to `() -> Unit`. A CHECKCAST here will fail.
|
||||||
MaterialValue(this, callable.asmMethod.returnType, returnType).discard().coerce(expression.type)
|
MaterialValue(this, callable.asmMethod.returnType, callee.returnType).discard().coerce(expression.type)
|
||||||
else ->
|
else ->
|
||||||
MaterialValue(this, callable.asmMethod.returnType, returnType).coerce(expression.type)
|
MaterialValue(this, callable.asmMethod.returnType, callee.returnType).coerce(expression.type)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
open class A<T> {
|
open class A<T> {
|
||||||
open fun f(args : Array<T>) {}
|
open fun f(args : Array<T>) {}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
public abstract class AbstractClass<T> {
|
public abstract class AbstractClass<T> {
|
||||||
public abstract val some: T
|
public abstract val some: T
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
interface PsiElement {
|
interface PsiElement {
|
||||||
fun <T: PsiElement> findChildByType(i: Int): T? =
|
fun <T: PsiElement> findChildByType(i: Int): T? =
|
||||||
if (i == 42) JetOperationReferenceExpression() as T else throw Exception()
|
if (i == 42) JetOperationReferenceExpression() as T else throw Exception()
|
||||||
|
|||||||
Vendored
-2
@@ -1,6 +1,4 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
// IGNORE_BACKEND_FIR: JVM_IR
|
||||||
// IGNORE_BACKEND: JVM_IR
|
|
||||||
// For JVM_IR, NewInference is needed because of KT-26531. See functionExpressionWithThisReferenceNI.kt
|
|
||||||
|
|
||||||
fun Int.thisRef1() = fun () = this
|
fun Int.thisRef1() = fun () = this
|
||||||
fun Int.thisRef2() = fun (): Int {return this}
|
fun Int.thisRef2() = fun (): Int {return this}
|
||||||
|
|||||||
-1
@@ -1,4 +1,3 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
// TARGET_BACKEND: JVM
|
// TARGET_BACKEND: JVM
|
||||||
interface I {
|
interface I {
|
||||||
fun <T : String> f(x: T?) = x ?: "OK"
|
fun <T : String> f(x: T?) = x ?: "OK"
|
||||||
|
|||||||
-1
@@ -1,5 +1,4 @@
|
|||||||
// !LANGUAGE: +NewInference
|
// !LANGUAGE: +NewInference
|
||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
|
|
||||||
class Recursive<T : Recursive<T>> : Generic<PlaceHolder<T>>, MainSupertype
|
class Recursive<T : Recursive<T>> : Generic<PlaceHolder<T>>, MainSupertype
|
||||||
open class Simple<T> : Generic<T>, MainSupertype
|
open class Simple<T> : Generic<T>, MainSupertype
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
open class Bar<T>(val prop: String)
|
open class Bar<T>(val prop: String)
|
||||||
object Foo : Bar<Foo>("OK") {
|
object Foo : Bar<Foo>("OK") {
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user