Type uncapturing
This commit is contained in:
@@ -2459,7 +2459,8 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
for (Map.Entry<TypeParameterDescriptor, KotlinType> entry : typeArguments.entrySet()) {
|
||||
TypeParameterDescriptor key = entry.getKey();
|
||||
|
||||
KotlinType type = entry.getValue();
|
||||
KotlinType type = TypeUtils.uncaptureTypeForInlineMapping(entry.getValue());
|
||||
|
||||
TypeParameterDescriptor parameterDescriptor = TypeUtils.getTypeParameterDescriptorOrNull(type);
|
||||
if (parameterDescriptor == null) {
|
||||
// type is not generic
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
//NO_CHECK_LAMBDA_INLINING
|
||||
|
||||
import test.*
|
||||
import java.util.*
|
||||
|
||||
public fun Array<in String>.slice1() = copyOfRange1 { 1 }
|
||||
|
||||
fun box(): String {
|
||||
val comparable = arrayOf("123").slice1()
|
||||
val method = comparable.javaClass.getMethod("test", Any::class.java)
|
||||
val genericParameterTypes = method.genericParameterTypes
|
||||
if (genericParameterTypes.size != 1) return "fail 1: ${genericParameterTypes.size}"
|
||||
var name = (genericParameterTypes[0] as Class<*>).name
|
||||
if (name != "java.lang.Object") return "fail 2: ${name}"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package test
|
||||
|
||||
interface F<T> {
|
||||
fun test(p: T) : Int
|
||||
}
|
||||
|
||||
inline fun <T: Any?> Array<T>.copyOfRange1(crossinline toIndex: () -> Int) =
|
||||
object : F<T> {
|
||||
override fun test(p: T): Int {
|
||||
return toIndex()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
//NO_CHECK_LAMBDA_INLINING
|
||||
|
||||
import test.*
|
||||
import java.util.*
|
||||
|
||||
public fun Array<out CharSequence>.slice1() = copyOfRange1 { 1 }
|
||||
|
||||
fun box(): String {
|
||||
val comparable = arrayOf("123").slice1()
|
||||
val method = comparable.javaClass.getMethod("test", Any::class.java)
|
||||
val genericParameterTypes = method.genericParameterTypes
|
||||
if (genericParameterTypes.size != 1) return "fail 1: ${genericParameterTypes.size}"
|
||||
var name = (genericParameterTypes[0] as Class<*>).name
|
||||
if (name != "java.lang.CharSequence") return "fail 2: ${name}"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package test
|
||||
|
||||
interface F<T> {
|
||||
fun test(p: T) : Int
|
||||
}
|
||||
|
||||
inline fun <T> Array<T>.copyOfRange1(crossinline toIndex: () -> Int) =
|
||||
object : F<T> {
|
||||
override fun test(p: T): Int {
|
||||
return toIndex()
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
//NO_CHECK_LAMBDA_INLINING
|
||||
|
||||
import test.*
|
||||
import java.util.*
|
||||
|
||||
public fun Array<*>.slice1() = copyOfRange1 { 1 }
|
||||
|
||||
fun box(): String {
|
||||
val comparable = arrayOf("123").slice1()
|
||||
val method = comparable.javaClass.getMethod("test", Any::class.java)
|
||||
val genericParameterTypes = method.genericParameterTypes
|
||||
if (genericParameterTypes.size != 1) return "fail 1: ${genericParameterTypes.size}"
|
||||
var name = (genericParameterTypes[0] as Class<*>).name
|
||||
if (name != "java.lang.Object") return "fail 2: ${name}"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package test
|
||||
|
||||
interface F<T> {
|
||||
fun test(p: T) : Int
|
||||
}
|
||||
|
||||
inline fun <T> Array<T>.copyOfRange1(crossinline toIndex: () -> Int) =
|
||||
object : F<T> {
|
||||
override fun test(p: T): Int {
|
||||
return toIndex()
|
||||
}
|
||||
}
|
||||
+18
@@ -1429,6 +1429,18 @@ public class BlackBoxInlineCodegenTestGenerated extends AbstractBlackBoxInlineCo
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxInline/signature"), Pattern.compile("^(.+)\\.1.kt$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("inProjectionSubstitution.1.kt")
|
||||
public void testInProjectionSubstitution() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/signature/inProjectionSubstitution.1.kt");
|
||||
doTestMultiFileWithInlineCheck(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("outProjectionSubstitution.1.kt")
|
||||
public void testOutProjectionSubstitution() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/signature/outProjectionSubstitution.1.kt");
|
||||
doTestMultiFileWithInlineCheck(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("recursion.1.kt")
|
||||
public void testRecursion() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/signature/recursion.1.kt");
|
||||
@@ -1447,6 +1459,12 @@ public class BlackBoxInlineCodegenTestGenerated extends AbstractBlackBoxInlineCo
|
||||
doTestMultiFileWithInlineCheck(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("starProjectionSubstitution.1.kt")
|
||||
public void testStarProjectionSubstitution() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/signature/starProjectionSubstitution.1.kt");
|
||||
doTestMultiFileWithInlineCheck(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("typeParameterInLambda.1.kt")
|
||||
public void testTypeParameterInLambda() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/signature/typeParameterInLambda.1.kt");
|
||||
|
||||
+18
@@ -1429,6 +1429,18 @@ public class CompileKotlinAgainstInlineKotlinTestGenerated extends AbstractCompi
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxInline/signature"), Pattern.compile("^(.+)\\.1.kt$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("inProjectionSubstitution.1.kt")
|
||||
public void testInProjectionSubstitution() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/signature/inProjectionSubstitution.1.kt");
|
||||
doBoxTestWithInlineCheck(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("outProjectionSubstitution.1.kt")
|
||||
public void testOutProjectionSubstitution() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/signature/outProjectionSubstitution.1.kt");
|
||||
doBoxTestWithInlineCheck(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("recursion.1.kt")
|
||||
public void testRecursion() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/signature/recursion.1.kt");
|
||||
@@ -1447,6 +1459,12 @@ public class CompileKotlinAgainstInlineKotlinTestGenerated extends AbstractCompi
|
||||
doBoxTestWithInlineCheck(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("starProjectionSubstitution.1.kt")
|
||||
public void testStarProjectionSubstitution() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/signature/starProjectionSubstitution.1.kt");
|
||||
doBoxTestWithInlineCheck(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("typeParameterInLambda.1.kt")
|
||||
public void testTypeParameterInLambda() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/signature/typeParameterInLambda.1.kt");
|
||||
|
||||
Reference in New Issue
Block a user