'createDelegate' operator renamed to 'toDelegateFor'
This commit is contained in:
committed by
Stanislav Erokhin
parent
e2ba288323
commit
2ee31916c7
@@ -141,8 +141,8 @@ public interface BindingContext {
|
|||||||
|
|
||||||
WritableSlice<VariableAccessorDescriptor, ResolvedCall<FunctionDescriptor>> DELEGATED_PROPERTY_RESOLVED_CALL = Slices.createSimpleSlice();
|
WritableSlice<VariableAccessorDescriptor, ResolvedCall<FunctionDescriptor>> DELEGATED_PROPERTY_RESOLVED_CALL = Slices.createSimpleSlice();
|
||||||
WritableSlice<VariableAccessorDescriptor, Call> DELEGATED_PROPERTY_CALL = Slices.createSimpleSlice();
|
WritableSlice<VariableAccessorDescriptor, Call> DELEGATED_PROPERTY_CALL = Slices.createSimpleSlice();
|
||||||
WritableSlice<VariableDescriptorWithAccessors, ResolvedCall<FunctionDescriptor>> CREATE_DELEGATE_RESOLVED_CALL = Slices.createSimpleSlice();
|
WritableSlice<VariableDescriptorWithAccessors, ResolvedCall<FunctionDescriptor>> TO_DELEGATE_FOR_RESOLVED_CALL = Slices.createSimpleSlice();
|
||||||
WritableSlice<VariableDescriptorWithAccessors, Call> CREATE_DELEGATE_CALL = Slices.createSimpleSlice();
|
WritableSlice<VariableDescriptorWithAccessors, Call> TO_DELEGATE_FOR_CALL = Slices.createSimpleSlice();
|
||||||
|
|
||||||
WritableSlice<VariableDescriptorWithAccessors, ResolvedCall<FunctionDescriptor>> DELEGATED_PROPERTY_PD_RESOLVED_CALL = Slices.createSimpleSlice();
|
WritableSlice<VariableDescriptorWithAccessors, ResolvedCall<FunctionDescriptor>> DELEGATED_PROPERTY_PD_RESOLVED_CALL = Slices.createSimpleSlice();
|
||||||
|
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ class DelegatedPropertyResolver(
|
|||||||
|
|
||||||
val byExpressionType = resolveDelegateExpression(delegateExpression, property, variableDescriptor, initializerScope, trace, outerDataFlowInfo)
|
val byExpressionType = resolveDelegateExpression(delegateExpression, property, variableDescriptor, initializerScope, trace, outerDataFlowInfo)
|
||||||
|
|
||||||
resolveCreateDelegateMethod(variableDescriptor, delegateExpression, byExpressionType, trace, delegateFunctionsScope, outerDataFlowInfo)
|
resolveToDelegateForMethod(variableDescriptor, delegateExpression, byExpressionType, trace, delegateFunctionsScope, outerDataFlowInfo)
|
||||||
val delegateType = getResolvedDelegateType(variableDescriptor, delegateExpression, byExpressionType, trace)
|
val delegateType = getResolvedDelegateType(variableDescriptor, delegateExpression, byExpressionType, trace)
|
||||||
|
|
||||||
resolveGetValueMethod(variableDescriptor, delegateExpression, delegateType, trace, delegateFunctionsScope, outerDataFlowInfo)
|
resolveGetValueMethod(variableDescriptor, delegateExpression, delegateType, trace, delegateFunctionsScope, outerDataFlowInfo)
|
||||||
@@ -103,10 +103,10 @@ class DelegatedPropertyResolver(
|
|||||||
byExpressionType: KotlinType,
|
byExpressionType: KotlinType,
|
||||||
trace: BindingTrace
|
trace: BindingTrace
|
||||||
): KotlinType {
|
): KotlinType {
|
||||||
val createDelegateResolvedCall = trace.bindingContext.get(CREATE_DELEGATE_RESOLVED_CALL, variableDescriptor)
|
val createDelegateResolvedCall = trace.bindingContext.get(TO_DELEGATE_FOR_RESOLVED_CALL, variableDescriptor)
|
||||||
if (createDelegateResolvedCall != null) {
|
if (createDelegateResolvedCall != null) {
|
||||||
return createDelegateResolvedCall.resultingDescriptor.returnType
|
return createDelegateResolvedCall.resultingDescriptor.returnType
|
||||||
?: throw AssertionError("No return type fore 'createDelegate' of ${delegateExpression.text}")
|
?: throw AssertionError("No return type fore 'toDelegateFor' of ${delegateExpression.text}")
|
||||||
}
|
}
|
||||||
return byExpressionType
|
return byExpressionType
|
||||||
}
|
}
|
||||||
@@ -119,7 +119,7 @@ class DelegatedPropertyResolver(
|
|||||||
delegateFunctionsScope: LexicalScope,
|
delegateFunctionsScope: LexicalScope,
|
||||||
dataFlowInfo: DataFlowInfo
|
dataFlowInfo: DataFlowInfo
|
||||||
): KotlinType? {
|
): KotlinType? {
|
||||||
resolveCreateDelegateMethod(variableDescriptor, delegateExpression, byExpressionType, trace, delegateFunctionsScope, dataFlowInfo)
|
resolveToDelegateForMethod(variableDescriptor, delegateExpression, byExpressionType, trace, delegateFunctionsScope, dataFlowInfo)
|
||||||
val delegateType = getResolvedDelegateType(variableDescriptor, delegateExpression, byExpressionType, trace)
|
val delegateType = getResolvedDelegateType(variableDescriptor, delegateExpression, byExpressionType, trace)
|
||||||
resolveGetSetValueMethod(variableDescriptor, delegateExpression, delegateType, trace, delegateFunctionsScope, dataFlowInfo, true)
|
resolveGetSetValueMethod(variableDescriptor, delegateExpression, delegateType, trace, delegateFunctionsScope, dataFlowInfo, true)
|
||||||
|
|
||||||
@@ -127,8 +127,8 @@ class DelegatedPropertyResolver(
|
|||||||
return if (resolvedCall != null) resolvedCall.resultingDescriptor.returnType else null
|
return if (resolvedCall != null) resolvedCall.resultingDescriptor.returnType else null
|
||||||
}
|
}
|
||||||
|
|
||||||
private val isOperatorCreateDelegateSupported: Boolean
|
private val isOperatorToDelegateForSupported: Boolean
|
||||||
get() = languageVersionSettings.supportsFeature(LanguageFeature.OperatorCreateDelegate)
|
get() = languageVersionSettings.supportsFeature(LanguageFeature.OperatorToDelegateFor)
|
||||||
|
|
||||||
private fun resolveGetValueMethod(
|
private fun resolveGetValueMethod(
|
||||||
variableDescriptor: VariableDescriptorWithAccessors,
|
variableDescriptor: VariableDescriptorWithAccessors,
|
||||||
@@ -268,7 +268,7 @@ class DelegatedPropertyResolver(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun resolveCreateDelegateMethod(
|
private fun resolveToDelegateForMethod(
|
||||||
propertyDescriptor: VariableDescriptorWithAccessors,
|
propertyDescriptor: VariableDescriptorWithAccessors,
|
||||||
byExpression: KtExpression,
|
byExpression: KtExpression,
|
||||||
byExpressionType: KotlinType,
|
byExpressionType: KotlinType,
|
||||||
@@ -276,27 +276,27 @@ class DelegatedPropertyResolver(
|
|||||||
delegateFunctionsScope: LexicalScope,
|
delegateFunctionsScope: LexicalScope,
|
||||||
dataFlowInfo: DataFlowInfo
|
dataFlowInfo: DataFlowInfo
|
||||||
) {
|
) {
|
||||||
if (!isOperatorCreateDelegateSupported) return
|
if (!isOperatorToDelegateForSupported) return
|
||||||
if (trace.bindingContext.get(BindingContext.CREATE_DELEGATE_CALL, propertyDescriptor) != null) return
|
if (trace.bindingContext.get(BindingContext.TO_DELEGATE_FOR_CALL, propertyDescriptor) != null) return
|
||||||
|
|
||||||
val createDelegateResults = getCreateDelegateMethod(propertyDescriptor, byExpression, byExpressionType,
|
val toDelegateForResults = getToDelegateForMethod(propertyDescriptor, byExpression, byExpressionType,
|
||||||
trace, delegateFunctionsScope, dataFlowInfo)
|
trace, delegateFunctionsScope, dataFlowInfo)
|
||||||
if (!createDelegateResults.isSuccess) {
|
if (!toDelegateForResults.isSuccess) {
|
||||||
val call = trace.bindingContext.get(BindingContext.CREATE_DELEGATE_CALL, propertyDescriptor)
|
val call = trace.bindingContext.get(BindingContext.TO_DELEGATE_FOR_CALL, propertyDescriptor)
|
||||||
?: throw AssertionError("'getDelegatedPropertyConventionMethod' didn't record a call")
|
?: throw AssertionError("'getDelegatedPropertyConventionMethod' didn't record a call")
|
||||||
reportDelegateOperatorResolutionError(trace, call, createDelegateResults, byExpression, byExpressionType,
|
reportDelegateOperatorResolutionError(trace, call, toDelegateForResults, byExpression, byExpressionType,
|
||||||
operatorRequired = false)
|
operatorRequired = false)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
val resultingDescriptor = createDelegateResults.resultingDescriptor
|
val resultingDescriptor = toDelegateForResults.resultingDescriptor
|
||||||
if (!resultingDescriptor.isOperator) {
|
if (!resultingDescriptor.isOperator) {
|
||||||
// TODO resolved 'createDelegate' function, which is not an operator - warning?
|
// TODO resolved 'createDelegate' function, which is not an operator - warning?
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
val resultingCall = createDelegateResults.resultingCall
|
val resultingCall = toDelegateForResults.resultingCall
|
||||||
trace.record(CREATE_DELEGATE_RESOLVED_CALL, propertyDescriptor, resultingCall)
|
trace.record(TO_DELEGATE_FOR_RESOLVED_CALL, propertyDescriptor, resultingCall)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Resolve getValue() or setValue() methods from delegate */
|
/* Resolve getValue() or setValue() methods from delegate */
|
||||||
@@ -345,7 +345,7 @@ class DelegatedPropertyResolver(
|
|||||||
return resolutionResult.second
|
return resolutionResult.second
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getCreateDelegateMethod(
|
private fun getToDelegateForMethod(
|
||||||
propertyDescriptor: VariableDescriptorWithAccessors,
|
propertyDescriptor: VariableDescriptorWithAccessors,
|
||||||
delegateExpression: KtExpression,
|
delegateExpression: KtExpression,
|
||||||
delegateExpressionType: KotlinType,
|
delegateExpressionType: KotlinType,
|
||||||
@@ -363,14 +363,14 @@ class DelegatedPropertyResolver(
|
|||||||
createExpressionForProperty()
|
createExpressionForProperty()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
val functionName = OperatorNameConventions.CREATE_DELEGATE
|
val functionName = OperatorNameConventions.TO_DELEGATE_FOR
|
||||||
val receiver = ExpressionReceiver.create(delegateExpression, delegateExpressionType, trace.bindingContext)
|
val receiver = ExpressionReceiver.create(delegateExpression, delegateExpressionType, trace.bindingContext)
|
||||||
|
|
||||||
val (createDelegateCall, createDelegateResolutionResult) =
|
val (toDelegateForCall, toDelegateForResults) =
|
||||||
fakeCallResolver.makeAndResolveFakeCallInContext(receiver, context, arguments, functionName, delegateExpression)
|
fakeCallResolver.makeAndResolveFakeCallInContext(receiver, context, arguments, functionName, delegateExpression)
|
||||||
trace.record(BindingContext.CREATE_DELEGATE_CALL, propertyDescriptor, createDelegateCall)
|
trace.record(BindingContext.TO_DELEGATE_FOR_CALL, propertyDescriptor, toDelegateForCall)
|
||||||
|
|
||||||
return createDelegateResolutionResult
|
return toDelegateForResults
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: diagnostics rendering does not belong here
|
//TODO: diagnostics rendering does not belong here
|
||||||
@@ -480,17 +480,17 @@ class DelegatedPropertyResolver(
|
|||||||
typeVariableSubstitutor: TypeSubstitutor,
|
typeVariableSubstitutor: TypeSubstitutor,
|
||||||
traceToResolveConventionMethods: TemporaryBindingTrace
|
traceToResolveConventionMethods: TemporaryBindingTrace
|
||||||
): KotlinType {
|
): KotlinType {
|
||||||
if (isOperatorCreateDelegateSupported) {
|
if (isOperatorToDelegateForSupported) {
|
||||||
val createDelegateResults = getCreateDelegateMethod(
|
val toDelegateForResults = getToDelegateForMethod(
|
||||||
variableDescriptor, delegateExpression, byExpressionType,
|
variableDescriptor, delegateExpression, byExpressionType,
|
||||||
traceToResolveConventionMethods, delegateFunctionsScope, dataFlowInfo
|
traceToResolveConventionMethods, delegateFunctionsScope, dataFlowInfo
|
||||||
)
|
)
|
||||||
if (conventionMethodFound(createDelegateResults)) {
|
if (conventionMethodFound(toDelegateForResults)) {
|
||||||
val createDelegateDescriptor = createDelegateResults.resultingDescriptor
|
val toDelegateForDescriptor = toDelegateForResults.resultingDescriptor
|
||||||
val createDelegateReturnType = createDelegateDescriptor.returnType
|
val toDelegateForReturnType = toDelegateForDescriptor.returnType
|
||||||
if (createDelegateDescriptor.isOperator) {
|
if (toDelegateForDescriptor.isOperator) {
|
||||||
addConstraintForThisValue(constraintSystem, typeVariableSubstitutor, createDelegateDescriptor)
|
addConstraintForThisValue(constraintSystem, typeVariableSubstitutor, toDelegateForDescriptor)
|
||||||
return createDelegateReturnType
|
return toDelegateForReturnType
|
||||||
?: throw AssertionError("No return type fore 'createDelegate' of ${delegateExpression.text}")
|
?: throw AssertionError("No return type fore 'createDelegate' of ${delegateExpression.text}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,8 +48,8 @@ object OperatorModifierChecker {
|
|||||||
checkSupportsFeature(LanguageFeature.Coroutines, languageVersionSettings, diagnosticHolder, modifier)
|
checkSupportsFeature(LanguageFeature.Coroutines, languageVersionSettings, diagnosticHolder, modifier)
|
||||||
in REM_TO_MOD_OPERATION_NAMES.keys ->
|
in REM_TO_MOD_OPERATION_NAMES.keys ->
|
||||||
checkSupportsFeature(LanguageFeature.OperatorRem, languageVersionSettings, diagnosticHolder, modifier)
|
checkSupportsFeature(LanguageFeature.OperatorRem, languageVersionSettings, diagnosticHolder, modifier)
|
||||||
OperatorNameConventions.CREATE_DELEGATE ->
|
OperatorNameConventions.TO_DELEGATE_FOR ->
|
||||||
checkSupportsFeature(LanguageFeature.OperatorCreateDelegate, languageVersionSettings, diagnosticHolder, modifier)
|
checkSupportsFeature(LanguageFeature.OperatorToDelegateFor, languageVersionSettings, diagnosticHolder, modifier)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (functionDescriptor.name in REM_TO_MOD_OPERATION_NAMES.values
|
if (functionDescriptor.name in REM_TO_MOD_OPERATION_NAMES.values
|
||||||
|
|||||||
-32
@@ -1,32 +0,0 @@
|
|||||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
|
||||||
|
|
||||||
import kotlin.reflect.KProperty
|
|
||||||
|
|
||||||
<!INAPPLICABLE_OPERATOR_MODIFIER!>operator<!> fun createDelegate(x: Any?, p: KProperty<*>) {}
|
|
||||||
|
|
||||||
operator fun Any.createDelegate(x: Any?, p: KProperty<*>) {}
|
|
||||||
|
|
||||||
operator fun Any.createDelegate(x: Any?, p: Any) {}
|
|
||||||
|
|
||||||
<!INAPPLICABLE_OPERATOR_MODIFIER!>operator<!> fun Any.createDelegate(x: Any?, p: Int) {}
|
|
||||||
|
|
||||||
class Host1 {
|
|
||||||
operator fun createDelegate(x: Any?, p: KProperty<*>) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
class Host2 {
|
|
||||||
operator fun Any.createDelegate(x: Any?, p: KProperty<*>) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
class Host3 {
|
|
||||||
<!INAPPLICABLE_OPERATOR_MODIFIER!>operator<!> fun createDelegate(x: Any?, p: KProperty<*>, foo: Int) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
class Host4 {
|
|
||||||
<!INAPPLICABLE_OPERATOR_MODIFIER!>operator<!> fun createDelegate(x: Any?, p: KProperty<*>, foo: Int = 0) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
class Host5 {
|
|
||||||
<!INAPPLICABLE_OPERATOR_MODIFIER!>operator<!> fun createDelegate(x: Any?, p: KProperty<*>, vararg foo: Int) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
+1
-1
@@ -4,7 +4,7 @@ class Cell<out V>(val value: V)
|
|||||||
|
|
||||||
class GenericDelegate<V>(val value: V)
|
class GenericDelegate<V>(val value: V)
|
||||||
|
|
||||||
operator fun <T> T.createDelegate(a: Any?, p: Any?) = GenericDelegate(this)
|
operator fun <T> T.toDelegateFor(a: Any?, p: Any?) = GenericDelegate(this)
|
||||||
|
|
||||||
operator fun <W> GenericDelegate<W>.getValue(a: Any?, p: Any?) = Cell(value)
|
operator fun <W> GenericDelegate<W>.getValue(a: Any?, p: Any?) = Cell(value)
|
||||||
|
|
||||||
+1
-1
@@ -3,8 +3,8 @@ package
|
|||||||
public val test1: Cell<kotlin.String>
|
public val test1: Cell<kotlin.String>
|
||||||
public val test2: Cell<kotlin.Any>
|
public val test2: Cell<kotlin.Any>
|
||||||
public val test3: Cell<kotlin.String>
|
public val test3: Cell<kotlin.String>
|
||||||
public operator fun </*0*/ T> T.createDelegate(/*0*/ a: kotlin.Any?, /*1*/ p: kotlin.Any?): GenericDelegate<T>
|
|
||||||
public operator fun </*0*/ W> GenericDelegate<W>.getValue(/*0*/ a: kotlin.Any?, /*1*/ p: kotlin.Any?): Cell<W>
|
public operator fun </*0*/ W> GenericDelegate<W>.getValue(/*0*/ a: kotlin.Any?, /*1*/ p: kotlin.Any?): Cell<W>
|
||||||
|
public operator fun </*0*/ T> T.toDelegateFor(/*0*/ a: kotlin.Any?, /*1*/ p: kotlin.Any?): GenericDelegate<T>
|
||||||
|
|
||||||
public final class Cell</*0*/ out V> {
|
public final class Cell</*0*/ out V> {
|
||||||
public constructor Cell</*0*/ out V>(/*0*/ value: V)
|
public constructor Cell</*0*/ out V>(/*0*/ value: V)
|
||||||
+1
-1
@@ -7,7 +7,7 @@ class StringDelegate(val s: String) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NB no operator
|
// NB no operator
|
||||||
fun String.createDelegate(a: Any?, p: KProperty<*>) = StringDelegate(this)
|
fun String.toDelegateFor(a: Any?, p: KProperty<*>) = StringDelegate(this)
|
||||||
|
|
||||||
operator fun String.getValue(a: Any?, p: KProperty<*>) = this
|
operator fun String.getValue(a: Any?, p: KProperty<*>) = this
|
||||||
|
|
||||||
+1
-1
@@ -3,8 +3,8 @@ package
|
|||||||
public val test1: kotlin.String
|
public val test1: kotlin.String
|
||||||
public val test2: kotlin.Int
|
public val test2: kotlin.Int
|
||||||
public val test3: kotlin.String
|
public val test3: kotlin.String
|
||||||
public fun kotlin.String.createDelegate(/*0*/ a: kotlin.Any?, /*1*/ p: kotlin.reflect.KProperty<*>): StringDelegate
|
|
||||||
public operator fun kotlin.String.getValue(/*0*/ a: kotlin.Any?, /*1*/ p: kotlin.reflect.KProperty<*>): kotlin.String
|
public operator fun kotlin.String.getValue(/*0*/ a: kotlin.Any?, /*1*/ p: kotlin.reflect.KProperty<*>): kotlin.String
|
||||||
|
public fun kotlin.String.toDelegateFor(/*0*/ a: kotlin.Any?, /*1*/ p: kotlin.reflect.KProperty<*>): StringDelegate
|
||||||
|
|
||||||
public final class StringDelegate {
|
public final class StringDelegate {
|
||||||
public constructor StringDelegate(/*0*/ s: kotlin.String)
|
public constructor StringDelegate(/*0*/ s: kotlin.String)
|
||||||
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
import kotlin.reflect.KProperty
|
import kotlin.reflect.KProperty
|
||||||
|
|
||||||
operator fun String.createDelegate(a: Any?, p: KProperty<*>) = this
|
operator fun String.toDelegateFor(a: Any?, p: KProperty<*>) = this
|
||||||
operator fun String.getValue(a: Any?, p: KProperty<*>) = this
|
operator fun String.getValue(a: Any?, p: KProperty<*>) = this
|
||||||
|
|
||||||
val test1: String by "OK"
|
val test1: String by "OK"
|
||||||
+1
-1
@@ -2,5 +2,5 @@ package
|
|||||||
|
|
||||||
public val test1: kotlin.String
|
public val test1: kotlin.String
|
||||||
public val test2: kotlin.String
|
public val test2: kotlin.String
|
||||||
public operator fun kotlin.String.createDelegate(/*0*/ a: kotlin.Any?, /*1*/ p: kotlin.reflect.KProperty<*>): kotlin.String
|
|
||||||
public operator fun kotlin.String.getValue(/*0*/ a: kotlin.Any?, /*1*/ p: kotlin.reflect.KProperty<*>): kotlin.String
|
public operator fun kotlin.String.getValue(/*0*/ a: kotlin.Any?, /*1*/ p: kotlin.reflect.KProperty<*>): kotlin.String
|
||||||
|
public operator fun kotlin.String.toDelegateFor(/*0*/ a: kotlin.Any?, /*1*/ p: kotlin.reflect.KProperty<*>): kotlin.String
|
||||||
+32
@@ -0,0 +1,32 @@
|
|||||||
|
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||||
|
|
||||||
|
import kotlin.reflect.KProperty
|
||||||
|
|
||||||
|
<!INAPPLICABLE_OPERATOR_MODIFIER!>operator<!> fun toDelegateFor(x: Any?, p: KProperty<*>) {}
|
||||||
|
|
||||||
|
operator fun Any.toDelegateFor(x: Any?, p: KProperty<*>) {}
|
||||||
|
|
||||||
|
operator fun Any.toDelegateFor(x: Any?, p: Any) {}
|
||||||
|
|
||||||
|
<!INAPPLICABLE_OPERATOR_MODIFIER!>operator<!> fun Any.toDelegateFor(x: Any?, p: Int) {}
|
||||||
|
|
||||||
|
class Host1 {
|
||||||
|
operator fun toDelegateFor(x: Any?, p: KProperty<*>) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Host2 {
|
||||||
|
operator fun Any.toDelegateFor(x: Any?, p: KProperty<*>) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Host3 {
|
||||||
|
<!INAPPLICABLE_OPERATOR_MODIFIER!>operator<!> fun toDelegateFor(x: Any?, p: KProperty<*>, foo: Int) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Host4 {
|
||||||
|
<!INAPPLICABLE_OPERATOR_MODIFIER!>operator<!> fun toDelegateFor(x: Any?, p: KProperty<*>, foo: Int = 0) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Host5 {
|
||||||
|
<!INAPPLICABLE_OPERATOR_MODIFIER!>operator<!> fun toDelegateFor(x: Any?, p: KProperty<*>, vararg foo: Int) {}
|
||||||
|
}
|
||||||
|
|
||||||
+9
-9
@@ -1,15 +1,15 @@
|
|||||||
package
|
package
|
||||||
|
|
||||||
public operator fun createDelegate(/*0*/ x: kotlin.Any?, /*1*/ p: kotlin.reflect.KProperty<*>): kotlin.Unit
|
public operator fun toDelegateFor(/*0*/ x: kotlin.Any?, /*1*/ p: kotlin.reflect.KProperty<*>): kotlin.Unit
|
||||||
public operator fun kotlin.Any.createDelegate(/*0*/ x: kotlin.Any?, /*1*/ p: kotlin.Any): kotlin.Unit
|
public operator fun kotlin.Any.toDelegateFor(/*0*/ x: kotlin.Any?, /*1*/ p: kotlin.Any): kotlin.Unit
|
||||||
public operator fun kotlin.Any.createDelegate(/*0*/ x: kotlin.Any?, /*1*/ p: kotlin.Int): kotlin.Unit
|
public operator fun kotlin.Any.toDelegateFor(/*0*/ x: kotlin.Any?, /*1*/ p: kotlin.Int): kotlin.Unit
|
||||||
public operator fun kotlin.Any.createDelegate(/*0*/ x: kotlin.Any?, /*1*/ p: kotlin.reflect.KProperty<*>): kotlin.Unit
|
public operator fun kotlin.Any.toDelegateFor(/*0*/ x: kotlin.Any?, /*1*/ p: kotlin.reflect.KProperty<*>): kotlin.Unit
|
||||||
|
|
||||||
public final class Host1 {
|
public final class Host1 {
|
||||||
public constructor Host1()
|
public constructor Host1()
|
||||||
public final operator fun createDelegate(/*0*/ x: kotlin.Any?, /*1*/ p: kotlin.reflect.KProperty<*>): kotlin.Unit
|
|
||||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
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 hashCode(): kotlin.Int
|
||||||
|
public final operator fun toDelegateFor(/*0*/ x: kotlin.Any?, /*1*/ p: kotlin.reflect.KProperty<*>): kotlin.Unit
|
||||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -18,29 +18,29 @@ public final class Host2 {
|
|||||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
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 hashCode(): kotlin.Int
|
||||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
public final operator fun kotlin.Any.createDelegate(/*0*/ x: kotlin.Any?, /*1*/ p: kotlin.reflect.KProperty<*>): kotlin.Unit
|
public final operator fun kotlin.Any.toDelegateFor(/*0*/ x: kotlin.Any?, /*1*/ p: kotlin.reflect.KProperty<*>): kotlin.Unit
|
||||||
}
|
}
|
||||||
|
|
||||||
public final class Host3 {
|
public final class Host3 {
|
||||||
public constructor Host3()
|
public constructor Host3()
|
||||||
public final operator fun createDelegate(/*0*/ x: kotlin.Any?, /*1*/ p: kotlin.reflect.KProperty<*>, /*2*/ foo: kotlin.Int): kotlin.Unit
|
|
||||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
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 hashCode(): kotlin.Int
|
||||||
|
public final operator fun toDelegateFor(/*0*/ x: kotlin.Any?, /*1*/ p: kotlin.reflect.KProperty<*>, /*2*/ foo: kotlin.Int): kotlin.Unit
|
||||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
}
|
}
|
||||||
|
|
||||||
public final class Host4 {
|
public final class Host4 {
|
||||||
public constructor Host4()
|
public constructor Host4()
|
||||||
public final operator fun createDelegate(/*0*/ x: kotlin.Any?, /*1*/ p: kotlin.reflect.KProperty<*>, /*2*/ foo: kotlin.Int = ...): kotlin.Unit
|
|
||||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
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 hashCode(): kotlin.Int
|
||||||
|
public final operator fun toDelegateFor(/*0*/ x: kotlin.Any?, /*1*/ p: kotlin.reflect.KProperty<*>, /*2*/ foo: kotlin.Int = ...): kotlin.Unit
|
||||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
}
|
}
|
||||||
|
|
||||||
public final class Host5 {
|
public final class Host5 {
|
||||||
public constructor Host5()
|
public constructor Host5()
|
||||||
public final operator fun createDelegate(/*0*/ x: kotlin.Any?, /*1*/ p: kotlin.reflect.KProperty<*>, /*2*/ vararg foo: kotlin.Int /*kotlin.IntArray*/): kotlin.Unit
|
|
||||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
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 hashCode(): kotlin.Int
|
||||||
|
public final operator fun toDelegateFor(/*0*/ x: kotlin.Any?, /*1*/ p: kotlin.reflect.KProperty<*>, /*2*/ vararg foo: kotlin.Int /*kotlin.IntArray*/): kotlin.Unit
|
||||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
}
|
}
|
||||||
+2
-2
@@ -1,11 +1,11 @@
|
|||||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||||
// !LANGUAGE: -OperatorCreateDelegate
|
// !LANGUAGE: -OperatorToDelegateFor
|
||||||
|
|
||||||
class WrongDelegate(val x: Int) {
|
class WrongDelegate(val x: Int) {
|
||||||
operator fun getValue(thisRef: Any?, prop: Any): Int = x
|
operator fun getValue(thisRef: Any?, prop: Any): Int = x
|
||||||
}
|
}
|
||||||
|
|
||||||
<!UNSUPPORTED_FEATURE(only available since Kotlin 1.1: operator createDelegate)!>operator<!> fun String.createDelegate(thisRef: Any?, prop: Any) = WrongDelegate(this.length)
|
<!UNSUPPORTED_FEATURE!>operator<!> fun String.toDelegateFor(thisRef: Any?, prop: Any) = WrongDelegate(this.length)
|
||||||
|
|
||||||
operator fun String.getValue(thisRef: Any?, prop: Any) = this
|
operator fun String.getValue(thisRef: Any?, prop: Any) = this
|
||||||
|
|
||||||
+1
-1
@@ -3,8 +3,8 @@ package
|
|||||||
public val test1: kotlin.String
|
public val test1: kotlin.String
|
||||||
public val test2: kotlin.Int
|
public val test2: kotlin.Int
|
||||||
public val test3: kotlin.String
|
public val test3: kotlin.String
|
||||||
public operator fun kotlin.String.createDelegate(/*0*/ thisRef: kotlin.Any?, /*1*/ prop: kotlin.Any): WrongDelegate
|
|
||||||
public operator fun kotlin.String.getValue(/*0*/ thisRef: kotlin.Any?, /*1*/ prop: kotlin.Any): kotlin.String
|
public operator fun kotlin.String.getValue(/*0*/ thisRef: kotlin.Any?, /*1*/ prop: kotlin.Any): kotlin.String
|
||||||
|
public operator fun kotlin.String.toDelegateFor(/*0*/ thisRef: kotlin.Any?, /*1*/ prop: kotlin.Any): WrongDelegate
|
||||||
|
|
||||||
public final class WrongDelegate {
|
public final class WrongDelegate {
|
||||||
public constructor WrongDelegate(/*0*/ x: kotlin.Int)
|
public constructor WrongDelegate(/*0*/ x: kotlin.Int)
|
||||||
@@ -5524,12 +5524,6 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("createDelegateOperatorDeclaration.kt")
|
|
||||||
public void testCreateDelegateOperatorDeclaration() throws Exception {
|
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/delegatedProperty/createDelegateOperatorDeclaration.kt");
|
|
||||||
doTest(fileName);
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("defaultGetter.kt")
|
@TestMetadata("defaultGetter.kt")
|
||||||
public void testDefaultGetter() throws Exception {
|
public void testDefaultGetter() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/delegatedProperty/defaultGetter.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/delegatedProperty/defaultGetter.kt");
|
||||||
@@ -5758,39 +5752,6 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/diagnostics/tests/delegatedProperty/createDelegate")
|
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
|
||||||
public static class CreateDelegate extends AbstractDiagnosticsTest {
|
|
||||||
public void testAllFilesPresentInCreateDelegate() throws Exception {
|
|
||||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/delegatedProperty/createDelegate"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("genericCreateDelegate.kt")
|
|
||||||
public void testGenericCreateDelegate() throws Exception {
|
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/delegatedProperty/createDelegate/genericCreateDelegate.kt");
|
|
||||||
doTest(fileName);
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("noOperatorModifierOnCreateDelegate.kt")
|
|
||||||
public void testNoOperatorModifierOnCreateDelegate() throws Exception {
|
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/delegatedProperty/createDelegate/noOperatorModifierOnCreateDelegate.kt");
|
|
||||||
doTest(fileName);
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("simpleCreateDelegate.kt")
|
|
||||||
public void testSimpleCreateDelegate() throws Exception {
|
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/delegatedProperty/createDelegate/simpleCreateDelegate.kt");
|
|
||||||
doTest(fileName);
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("unsupportedOperatorCreateDelegate.kt")
|
|
||||||
public void testUnsupportedOperatorCreateDelegate() throws Exception {
|
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/delegatedProperty/createDelegate/unsupportedOperatorCreateDelegate.kt");
|
|
||||||
doTest(fileName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/diagnostics/tests/delegatedProperty/inference")
|
@TestMetadata("compiler/testData/diagnostics/tests/delegatedProperty/inference")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
@@ -5871,6 +5832,45 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("compiler/testData/diagnostics/tests/delegatedProperty/toDelegateFor")
|
||||||
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
public static class ToDelegateFor extends AbstractDiagnosticsTest {
|
||||||
|
public void testAllFilesPresentInToDelegateFor() throws Exception {
|
||||||
|
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/delegatedProperty/toDelegateFor"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("genericToDelegateFor.kt")
|
||||||
|
public void testGenericToDelegateFor() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/delegatedProperty/toDelegateFor/genericToDelegateFor.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("noOperatorModifierOnToDelegateFor.kt")
|
||||||
|
public void testNoOperatorModifierOnToDelegateFor() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/delegatedProperty/toDelegateFor/noOperatorModifierOnToDelegateFor.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("simpleToDelegateFor.kt")
|
||||||
|
public void testSimpleToDelegateFor() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/delegatedProperty/toDelegateFor/simpleToDelegateFor.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("toDelegateForOperatorDeclaration.kt")
|
||||||
|
public void testToDelegateForOperatorDeclaration() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/delegatedProperty/toDelegateFor/toDelegateForOperatorDeclaration.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("unsupportedOperatorToDelegateFor.kt")
|
||||||
|
public void testUnsupportedOperatorToDelegateFor() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/delegatedProperty/toDelegateFor/unsupportedOperatorToDelegateFor.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/diagnostics/tests/delegation")
|
@TestMetadata("compiler/testData/diagnostics/tests/delegation")
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ enum class LanguageFeature(val sinceVersion: LanguageVersion?) {
|
|||||||
DivisionByZeroInConstantExpressions(KOTLIN_1_1),
|
DivisionByZeroInConstantExpressions(KOTLIN_1_1),
|
||||||
InlineConstVals(KOTLIN_1_1),
|
InlineConstVals(KOTLIN_1_1),
|
||||||
OperatorRem(KOTLIN_1_1),
|
OperatorRem(KOTLIN_1_1),
|
||||||
OperatorCreateDelegate(KOTLIN_1_1),
|
OperatorToDelegateFor(KOTLIN_1_1),
|
||||||
|
|
||||||
// Experimental features
|
// Experimental features
|
||||||
MultiPlatformProjects(null),
|
MultiPlatformProjects(null),
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ object OperatorNameConventions {
|
|||||||
@JvmField val GET_VALUE = Name.identifier("getValue")
|
@JvmField val GET_VALUE = Name.identifier("getValue")
|
||||||
@JvmField val SET_VALUE = Name.identifier("setValue")
|
@JvmField val SET_VALUE = Name.identifier("setValue")
|
||||||
@JvmField val PROPERTY_DELEGATED = Name.identifier("propertyDelegated")
|
@JvmField val PROPERTY_DELEGATED = Name.identifier("propertyDelegated")
|
||||||
@JvmField val CREATE_DELEGATE = Name.identifier("createDelegate")
|
@JvmField val TO_DELEGATE_FOR = Name.identifier("toDelegateFor")
|
||||||
|
|
||||||
@JvmField val EQUALS = Name.identifier("equals")
|
@JvmField val EQUALS = Name.identifier("equals")
|
||||||
@JvmField val COMPARE_TO = Name.identifier("compareTo")
|
@JvmField val COMPARE_TO = Name.identifier("compareTo")
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ import org.jetbrains.kotlin.util.OperatorNameConventions.CONTAINS
|
|||||||
import org.jetbrains.kotlin.util.OperatorNameConventions.COROUTINE_HANDLE_EXCEPTION
|
import org.jetbrains.kotlin.util.OperatorNameConventions.COROUTINE_HANDLE_EXCEPTION
|
||||||
import org.jetbrains.kotlin.util.OperatorNameConventions.COROUTINE_HANDLE_RESULT
|
import org.jetbrains.kotlin.util.OperatorNameConventions.COROUTINE_HANDLE_RESULT
|
||||||
import org.jetbrains.kotlin.util.OperatorNameConventions.COROUTINE_INTERCEPT_RESUME
|
import org.jetbrains.kotlin.util.OperatorNameConventions.COROUTINE_INTERCEPT_RESUME
|
||||||
import org.jetbrains.kotlin.util.OperatorNameConventions.CREATE_DELEGATE
|
import org.jetbrains.kotlin.util.OperatorNameConventions.TO_DELEGATE_FOR
|
||||||
import org.jetbrains.kotlin.util.OperatorNameConventions.DEC
|
import org.jetbrains.kotlin.util.OperatorNameConventions.DEC
|
||||||
import org.jetbrains.kotlin.util.OperatorNameConventions.EQUALS
|
import org.jetbrains.kotlin.util.OperatorNameConventions.EQUALS
|
||||||
import org.jetbrains.kotlin.util.OperatorNameConventions.GET
|
import org.jetbrains.kotlin.util.OperatorNameConventions.GET
|
||||||
@@ -186,7 +186,7 @@ object OperatorChecks : AbstractModifierChecks() {
|
|||||||
},
|
},
|
||||||
Checks(GET_VALUE, MemberOrExtension, NoDefaultAndVarargsCheck, ValueParameterCountCheck.AtLeast(2), IsKPropertyCheck),
|
Checks(GET_VALUE, MemberOrExtension, NoDefaultAndVarargsCheck, ValueParameterCountCheck.AtLeast(2), IsKPropertyCheck),
|
||||||
Checks(SET_VALUE, MemberOrExtension, NoDefaultAndVarargsCheck, ValueParameterCountCheck.AtLeast(3), IsKPropertyCheck),
|
Checks(SET_VALUE, MemberOrExtension, NoDefaultAndVarargsCheck, ValueParameterCountCheck.AtLeast(3), IsKPropertyCheck),
|
||||||
Checks(CREATE_DELEGATE, MemberOrExtension, NoDefaultAndVarargsCheck, ValueParameterCountCheck.Equals(2), IsKPropertyCheck),
|
Checks(TO_DELEGATE_FOR, MemberOrExtension, NoDefaultAndVarargsCheck, ValueParameterCountCheck.Equals(2), IsKPropertyCheck),
|
||||||
Checks(INVOKE, MemberOrExtension),
|
Checks(INVOKE, MemberOrExtension),
|
||||||
Checks(CONTAINS, MemberOrExtension, SingleValueParameter, NoDefaultAndVarargsCheck, ReturnsBoolean),
|
Checks(CONTAINS, MemberOrExtension, SingleValueParameter, NoDefaultAndVarargsCheck, ReturnsBoolean),
|
||||||
Checks(ITERATOR, MemberOrExtension, NoValueParameters),
|
Checks(ITERATOR, MemberOrExtension, NoValueParameters),
|
||||||
|
|||||||
Reference in New Issue
Block a user