Extraction Engine: Do not add variance to type parameters in generated declaration
This commit is contained in:
+7
-1
@@ -70,7 +70,13 @@ fun ExtractionGeneratorConfiguration.getDeclarationText(
|
||||
return CallableBuilder(builderTarget).let { builder ->
|
||||
builder.modifier(descriptor.visibility)
|
||||
|
||||
builder.typeParams(descriptor.typeParameters.map { it.originalDeclaration.getText()!! })
|
||||
builder.typeParams(
|
||||
descriptor.typeParameters.map {
|
||||
val typeParameter = it.originalDeclaration
|
||||
val bound = typeParameter.extendsBound
|
||||
typeParameter.name + (bound?.let { " : " + it.text } ?: "")
|
||||
}
|
||||
)
|
||||
|
||||
fun JetType.typeAsString(): String {
|
||||
return if (isSpecial()) DEBUG_TYPE_REFERENCE_STRING else descriptorRenderer.renderType(this)
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
// PARAM_DESCRIPTOR: val e: T? defined in EntityClass.foo
|
||||
// PARAM_TYPES: T?, Entity?
|
||||
// SIBLING:
|
||||
abstract public class EntityClass<out T: Entity>() {
|
||||
fun foo() {
|
||||
val e: T? = null
|
||||
<selection>e?.value</selection>
|
||||
}
|
||||
}
|
||||
|
||||
open class Entity {
|
||||
var value: String? = null
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
// PARAM_DESCRIPTOR: val e: T? defined in EntityClass.foo
|
||||
// PARAM_TYPES: T?, Entity?
|
||||
// SIBLING:
|
||||
abstract public class EntityClass<out T: Entity>() {
|
||||
fun foo() {
|
||||
val e: T? = null
|
||||
__dummyTestFun__(e)
|
||||
}
|
||||
}
|
||||
|
||||
private fun <T : Entity> __dummyTestFun__(e: T?) {
|
||||
e?.value
|
||||
}
|
||||
|
||||
open class Entity {
|
||||
var value: String? = null
|
||||
}
|
||||
+6
@@ -2292,6 +2292,12 @@ public class JetExtractionTestGenerated extends AbstractJetExtractionTest {
|
||||
doExtractFunctionTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("noVarianceInFun.kt")
|
||||
public void testNoVarianceInFun() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/extractFunction/typeParameters/noVarianceInFun.kt");
|
||||
doExtractFunctionTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("simpleTypeParameter.kt")
|
||||
public void testSimpleTypeParameter() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/extractFunction/typeParameters/simpleTypeParameter.kt");
|
||||
|
||||
Reference in New Issue
Block a user