Pull Up: Apply type substitution to parameters propagated to the target class

This commit is contained in:
Alexey Sedunov
2015-09-09 12:44:12 +03:00
parent 49f0101b70
commit 8a2e2e93e7
2 changed files with 8 additions and 2 deletions
@@ -52,6 +52,7 @@ import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall
import org.jetbrains.kotlin.resolve.calls.resolvedCallUtil.getExplicitReceiverValue
import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver
import org.jetbrains.kotlin.resolve.source.getPsi
import org.jetbrains.kotlin.types.Variance
import java.util.*
class KotlinPullUpHelper(
@@ -533,7 +534,12 @@ class KotlinPullUpHelper(
}
with(constructor.getValueParameterList()!!) {
info.usedParameters.forEach { addParameter(it) }
info.usedParameters.forEach {
val newParameter = addParameter(it)
val originalType = data.sourceClassContext[BindingContext.VALUE_PARAMETER, it]!!.type
newParameter.setType(data.sourceToTargetClassSubstitutor.substitute(originalType, Variance.INVARIANT) ?: originalType, false)
newParameter.typeReference!!.addToShorteningWaitSet()
}
}
targetToSourceConstructors[constructorElement]!!.forEach {
val superCall: JetCallElement? = when (it) {
@@ -3,7 +3,7 @@ interface I
interface Z<T>
abstract class A<T: I, U: I, V>(x: X, y: Y) {
abstract class A<T: I, U: I, V>(x: T, y: Any?) {
// INFO: {"checked": "true"}
val foo1: T
// INFO: {"checked": "true"}