Extraction Engine: Do not add variance to type parameters in generated declaration

This commit is contained in:
Alexey Sedunov
2015-09-14 13:28:36 +03:00
parent 4f7b978bbc
commit 34b279a7a8
4 changed files with 43 additions and 1 deletions
@@ -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
}
@@ -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
}
@@ -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");