[NI] Store setValue with fresh type variables before substitution

This commit is contained in:
Mikhail Zarechenskiy
2017-08-14 13:52:54 +03:00
committed by Stanislav Erokhin
parent 55d1130dfc
commit e040a317cc
4 changed files with 50 additions and 0 deletions
@@ -556,6 +556,14 @@ class DelegatedPropertyResolver(
isGet = true, isComplete = true
)
if (variableDescriptor.isVar && variableDescriptor.returnType !is DeferredType) {
getGetSetValueMethod(
variableDescriptor, delegateExpression, typeInfoForGetValueReceiver.type ?: return null,
traceToResolveConventionMethods, scopeForDelegate, typeInfoForGetValueReceiver.dataFlowInfo,
isGet = false, isComplete = true
)
}
val call = delegateExpression.getCall(traceToResolveConventionMethods.bindingContext)
val pretendReturnType = call.getResolvedCall(traceToResolveConventionMethods.bindingContext)?.resultingDescriptor?.returnType
return pretendReturnType?.takeUnless { it.contains { it.constructor is TypeVariableTypeConstructor } }
@@ -0,0 +1,10 @@
import kotlin.reflect.KProperty
class MyMetadata<in T, R>(val default: R) {
operator fun getValue(thisRef: T, desc: KProperty<*>): R = TODO()
operator fun setValue(thisRef: T, desc: KProperty<*>, value: R) {}
}
interface Something
class MyReceiver
var MyReceiver.something: Something? by MyMetadata(default = null)
@@ -0,0 +1,26 @@
package
public var MyReceiver.something: Something?
public final class MyMetadata</*0*/ in T, /*1*/ R> {
public constructor MyMetadata</*0*/ in T, /*1*/ R>(/*0*/ default: R)
public final val default: R
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final operator fun getValue(/*0*/ thisRef: T, /*1*/ desc: kotlin.reflect.KProperty<*>): R
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public final operator fun setValue(/*0*/ thisRef: T, /*1*/ desc: kotlin.reflect.KProperty<*>, /*2*/ value: R): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public final class MyReceiver {
public constructor MyReceiver()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public interface Something {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -16702,6 +16702,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
doTest(fileName);
}
@TestMetadata("delegationWithReceiver.kt")
public void testDelegationWithReceiver() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/regressions/delegationWithReceiver.kt");
doTest(fileName);
}
@TestMetadata("DoubleDefine.kt")
public void testDoubleDefine() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/regressions/DoubleDefine.kt");