Delegated Properties: allowing type parameters for get/set methods
#KT-6253 Fixed
This commit is contained in:
+15
-7
@@ -184,7 +184,7 @@ public class DelegatedPropertyResolver {
|
||||
if (trace.getBindingContext().get(DELEGATED_PROPERTY_CALL, accessor) != null) return;
|
||||
|
||||
OverloadResolutionResults<FunctionDescriptor> functionResults = getDelegatedPropertyConventionMethod(
|
||||
propertyDescriptor, delegateExpression, delegateType, trace, scope, isGet);
|
||||
propertyDescriptor, delegateExpression, delegateType, trace, scope, isGet, true);
|
||||
Call call = trace.getBindingContext().get(DELEGATED_PROPERTY_CALL, accessor);
|
||||
assert call != null : "'getDelegatedPropertyConventionMethod' didn't record a call";
|
||||
|
||||
@@ -218,14 +218,18 @@ public class DelegatedPropertyResolver {
|
||||
@NotNull JetType delegateType,
|
||||
@NotNull BindingTrace trace,
|
||||
@NotNull JetScope scope,
|
||||
boolean isGet
|
||||
boolean isGet,
|
||||
boolean isComplete
|
||||
) {
|
||||
PropertyAccessorDescriptor accessor = isGet ? propertyDescriptor.getGetter() : propertyDescriptor.getSetter();
|
||||
assert accessor != null : "Delegated property should have getter/setter " + propertyDescriptor + " " + delegateExpression.getText();
|
||||
|
||||
JetType expectedType = isComplete && isGet && !(propertyDescriptor.getType() instanceof DeferredType)
|
||||
? propertyDescriptor.getType() : TypeUtils.NO_EXPECTED_TYPE;
|
||||
|
||||
ExpressionTypingContext context = ExpressionTypingContext.newContext(
|
||||
expressionTypingServices, trace, scope,
|
||||
DataFlowInfo.EMPTY, TypeUtils.NO_EXPECTED_TYPE);
|
||||
DataFlowInfo.EMPTY, expectedType);
|
||||
|
||||
boolean hasThis = propertyDescriptor.getExtensionReceiverParameter() != null || propertyDescriptor.getDispatchReceiverParameter() != null;
|
||||
|
||||
@@ -318,7 +322,9 @@ public class DelegatedPropertyResolver {
|
||||
TemporaryBindingTrace.create(trace, "Trace to resolve delegated property convention methods");
|
||||
OverloadResolutionResults<FunctionDescriptor>
|
||||
getMethodResults = getDelegatedPropertyConventionMethod(
|
||||
propertyDescriptor, delegateExpression, returnType, traceToResolveConventionMethods, accessorScope, true);
|
||||
propertyDescriptor, delegateExpression, returnType, traceToResolveConventionMethods, accessorScope,
|
||||
true, false
|
||||
);
|
||||
|
||||
if (conventionMethodFound(getMethodResults)) {
|
||||
FunctionDescriptor descriptor = getMethodResults.getResultingDescriptor();
|
||||
@@ -335,9 +341,11 @@ public class DelegatedPropertyResolver {
|
||||
// But if the type isn't known yet, the constraint shouldn't be added (we try to infer the type of 'v' here as well).
|
||||
if (propertyDescriptor.getReturnType() instanceof DeferredType) return;
|
||||
|
||||
OverloadResolutionResults<FunctionDescriptor> setMethodResults =
|
||||
getDelegatedPropertyConventionMethod(
|
||||
propertyDescriptor, delegateExpression, returnType, traceToResolveConventionMethods, accessorScope, false);
|
||||
OverloadResolutionResults<FunctionDescriptor>
|
||||
setMethodResults = getDelegatedPropertyConventionMethod(
|
||||
propertyDescriptor, delegateExpression, returnType, traceToResolveConventionMethods, accessorScope,
|
||||
false, false
|
||||
);
|
||||
|
||||
if (conventionMethodFound(setMethodResults)) {
|
||||
FunctionDescriptor descriptor = setMethodResults.getResultingDescriptor();
|
||||
|
||||
Reference in New Issue
Block a user