diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java index bf9a1d8346d..45c40572c38 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java @@ -551,7 +551,7 @@ public interface Errors { DiagnosticFactory1>> ITERATOR_AMBIGUITY = DiagnosticFactory1.create(ERROR); DiagnosticFactory2 DELEGATE_SPECIAL_FUNCTION_MISSING = DiagnosticFactory2.create(ERROR); - DiagnosticFactory3 DELEGATE_RESOLVED_TO_DEPRECATED_CONVENTION = DiagnosticFactory3.create(WARNING); + DiagnosticFactory3 DELEGATE_RESOLVED_TO_DEPRECATED_CONVENTION = DiagnosticFactory3.create(WARNING); DiagnosticFactory2>> DELEGATE_SPECIAL_FUNCTION_AMBIGUITY = DiagnosticFactory2.create(ERROR); DiagnosticFactory2>> DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE = DiagnosticFactory2.create(ERROR); DiagnosticFactory3 DELEGATE_SPECIAL_FUNCTION_RETURN_TYPE_MISMATCH = DiagnosticFactory3.create(ERROR); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DelegatedPropertyResolver.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DelegatedPropertyResolver.java index 60d8b82e9b2..2a205ef8766 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DelegatedPropertyResolver.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DelegatedPropertyResolver.java @@ -208,9 +208,6 @@ public class DelegatedPropertyResolver { } FunctionDescriptor resultingDescriptor = functionResults.getResultingDescriptor(); - if (!resultingDescriptor.isOperator()) { - OperatorValidator.Companion.report(delegateExpression, resultingDescriptor, trace); - } ResolvedCall resultingCall = functionResults.getResultingCall(); PsiElement declaration = DescriptorToSourceUtils.descriptorToDeclaration(propertyDescriptor); @@ -219,6 +216,11 @@ public class DelegatedPropertyResolver { JetPropertyDelegate delegate = property.getDelegate(); if (delegate != null) { PsiElement byKeyword = delegate.getByKeywordNode().getPsi(); + + if (!resultingDescriptor.isOperator()) { + OperatorValidator.Companion.report(byKeyword, resultingDescriptor, trace); + } + symbolUsageValidator.validateCall(resultingCall, resultingCall.getResultingDescriptor(), trace, byKeyword); } } @@ -276,8 +278,19 @@ public class DelegatedPropertyResolver { fakeCallResolver.makeAndResolveFakeCallInContext(receiver, context, arguments, oldFunctionName, delegateExpression); if (additionalResolutionResult.getSecond().isSuccess()) { FunctionDescriptor resultingDescriptor = additionalResolutionResult.getSecond().getResultingDescriptor(); - trace.report(DELEGATE_RESOLVED_TO_DEPRECATED_CONVENTION.on( - delegateExpression, resultingDescriptor, delegateType, functionName.asString())); + + PsiElement declaration = DescriptorToSourceUtils.descriptorToDeclaration(propertyDescriptor); + if (declaration instanceof JetProperty) { + JetProperty property = (JetProperty) declaration; + JetPropertyDelegate delegate = property.getDelegate(); + if (delegate != null) { + PsiElement byKeyword = delegate.getByKeywordNode().getPsi(); + + trace.report(DELEGATE_RESOLVED_TO_DEPRECATED_CONVENTION.on( + byKeyword, resultingDescriptor, delegateType, functionName.asString())); + } + } + trace.record(BindingContext.DELEGATED_PROPERTY_CALL, accessor, additionalResolutionResult.getFirst()); return additionalResolutionResult.getSecond(); } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/validation/OperatorValidator.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/validation/OperatorValidator.kt index 03665d38bb3..0fdc2cbed1c 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/validation/OperatorValidator.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/validation/OperatorValidator.kt @@ -69,7 +69,7 @@ public class OperatorValidator : SymbolUsageValidator { } companion object { - fun report(element: JetElement, descriptor: FunctionDescriptor, sink: DiagnosticSink) { + fun report(element: PsiElement, descriptor: FunctionDescriptor, sink: DiagnosticSink) { if (!checkNotErrorOrDynamic(descriptor)) return val containingDeclaration = descriptor.containingDeclaration diff --git a/compiler/testData/diagnostics/tests/DeprecatedGetSetPropertyDelegateConvention.kt b/compiler/testData/diagnostics/tests/DeprecatedGetSetPropertyDelegateConvention.kt index 450bba24e38..af3c117da9d 100644 --- a/compiler/testData/diagnostics/tests/DeprecatedGetSetPropertyDelegateConvention.kt +++ b/compiler/testData/diagnostics/tests/DeprecatedGetSetPropertyDelegateConvention.kt @@ -33,8 +33,8 @@ operator fun CustomDelegate3.setValue(thisRef: Any?, prop: Proper class Example { - var a by CustomDelegate() - val aval by CustomDelegate() + var a by CustomDelegate() + val aval by CustomDelegate() var b by OkDelegate() var c by CustomDelegate2() var d by CustomDelegate3() @@ -50,4 +50,4 @@ class Example { fun requireString(s: String) {} fun requireInt(n: Int) {} -} +} \ No newline at end of file diff --git a/idea/testData/quickfix/modifiers/deprecatedDelegatesGetSetExtension.kt b/idea/testData/quickfix/modifiers/deprecatedDelegatesGetSetExtension.kt index 9915f8babb4..8f6d1073dfb 100644 --- a/idea/testData/quickfix/modifiers/deprecatedDelegatesGetSetExtension.kt +++ b/idea/testData/quickfix/modifiers/deprecatedDelegatesGetSetExtension.kt @@ -4,5 +4,5 @@ class CustomDelegate operator fun CustomDelegate.get(thisRef: Any?, prop: PropertyMetadata): String = "" class Example { - val a: String by CustomDelegate() + val a: String by CustomDelegate() } diff --git a/idea/testData/quickfix/modifiers/deprecatedDelegatesGetSetMember.kt b/idea/testData/quickfix/modifiers/deprecatedDelegatesGetSetMember.kt index 7c5f04d074a..7118faeb80d 100644 --- a/idea/testData/quickfix/modifiers/deprecatedDelegatesGetSetMember.kt +++ b/idea/testData/quickfix/modifiers/deprecatedDelegatesGetSetMember.kt @@ -5,5 +5,5 @@ class CustomDelegate { } class Example { - var a: String by CustomDelegate() + var a: String by CustomDelegate() }