diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/UsePropertyAccessSyntaxIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/UsePropertyAccessSyntaxIntention.kt index 82b3c2fc699..5d6714ea434 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/UsePropertyAccessSyntaxIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/UsePropertyAccessSyntaxIntention.kt @@ -27,6 +27,7 @@ import org.jetbrains.kotlin.idea.resolve.ResolutionFacade import org.jetbrains.kotlin.idea.resolve.frontendService import org.jetbrains.kotlin.idea.util.getResolutionScope import org.jetbrains.kotlin.idea.util.shouldNotConvertToProperty +import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.name.FqNameUnsafe import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.psi.* @@ -144,6 +145,8 @@ class UsePropertyAccessSyntaxIntention : val resolutionScope = callExpression.getResolutionScope(bindingContext, resolutionFacade) val property = findSyntheticProperty(function, resolutionFacade.getFrontendService(SyntheticScopes::class.java)) ?: return null + if (KtTokens.KEYWORDS.types.any { it.toString() == property.name.asString() }) return null + val dataFlowInfo = bindingContext.getDataFlowInfoBefore(callee) val qualifiedExpression = callExpression.getQualifiedExpressionForSelectorOrThis() val expectedType = bindingContext[BindingContext.EXPECTED_EXPRESSION_TYPE, qualifiedExpression] ?: TypeUtils.NO_EXPECTED_TYPE diff --git a/idea/testData/intentions/usePropertyAccessSyntax/getReservedWord1.1.java b/idea/testData/intentions/usePropertyAccessSyntax/getReservedWord1.1.java new file mode 100644 index 00000000000..3af321d224f --- /dev/null +++ b/idea/testData/intentions/usePropertyAccessSyntax/getReservedWord1.1.java @@ -0,0 +1,11 @@ +public class Foo { + private String object; + + public String getObject() { + return object; + } + + public void setObject(String object) { + this.object = object; + } +} \ No newline at end of file diff --git a/idea/testData/intentions/usePropertyAccessSyntax/getReservedWord1.kt b/idea/testData/intentions/usePropertyAccessSyntax/getReservedWord1.kt new file mode 100644 index 00000000000..96cc0e40855 --- /dev/null +++ b/idea/testData/intentions/usePropertyAccessSyntax/getReservedWord1.kt @@ -0,0 +1,5 @@ +// IS_APPLICABLE: false + +fun test() { + Foo().getObject() +} \ No newline at end of file diff --git a/idea/testData/intentions/usePropertyAccessSyntax/getReservedWord2.1.java b/idea/testData/intentions/usePropertyAccessSyntax/getReservedWord2.1.java new file mode 100644 index 00000000000..0286d72fca3 --- /dev/null +++ b/idea/testData/intentions/usePropertyAccessSyntax/getReservedWord2.1.java @@ -0,0 +1,11 @@ +public class Foo { + private String typeof; + + public String getTypeof() { + return typeof; + } + + public void setTypeof(String typeof) { + this.typeof = typeof; + } +} \ No newline at end of file diff --git a/idea/testData/intentions/usePropertyAccessSyntax/getReservedWord2.kt b/idea/testData/intentions/usePropertyAccessSyntax/getReservedWord2.kt new file mode 100644 index 00000000000..19a94ecd547 --- /dev/null +++ b/idea/testData/intentions/usePropertyAccessSyntax/getReservedWord2.kt @@ -0,0 +1,5 @@ +// IS_APPLICABLE: false + +fun test() { + Foo().getTypeof() +} \ No newline at end of file diff --git a/idea/testData/intentions/usePropertyAccessSyntax/setReservedWord1.1.java b/idea/testData/intentions/usePropertyAccessSyntax/setReservedWord1.1.java new file mode 100644 index 00000000000..3af321d224f --- /dev/null +++ b/idea/testData/intentions/usePropertyAccessSyntax/setReservedWord1.1.java @@ -0,0 +1,11 @@ +public class Foo { + private String object; + + public String getObject() { + return object; + } + + public void setObject(String object) { + this.object = object; + } +} \ No newline at end of file diff --git a/idea/testData/intentions/usePropertyAccessSyntax/setReservedWord1.kt b/idea/testData/intentions/usePropertyAccessSyntax/setReservedWord1.kt new file mode 100644 index 00000000000..ab3ed8fe599 --- /dev/null +++ b/idea/testData/intentions/usePropertyAccessSyntax/setReservedWord1.kt @@ -0,0 +1,5 @@ +// IS_APPLICABLE: false + +fun test() { + Foo().setObject("") +} \ No newline at end of file diff --git a/idea/testData/intentions/usePropertyAccessSyntax/setReservedWord2.1.java b/idea/testData/intentions/usePropertyAccessSyntax/setReservedWord2.1.java new file mode 100644 index 00000000000..0286d72fca3 --- /dev/null +++ b/idea/testData/intentions/usePropertyAccessSyntax/setReservedWord2.1.java @@ -0,0 +1,11 @@ +public class Foo { + private String typeof; + + public String getTypeof() { + return typeof; + } + + public void setTypeof(String typeof) { + this.typeof = typeof; + } +} \ No newline at end of file diff --git a/idea/testData/intentions/usePropertyAccessSyntax/setReservedWord2.kt b/idea/testData/intentions/usePropertyAccessSyntax/setReservedWord2.kt new file mode 100644 index 00000000000..305f3e9f637 --- /dev/null +++ b/idea/testData/intentions/usePropertyAccessSyntax/setReservedWord2.kt @@ -0,0 +1,5 @@ +// IS_APPLICABLE: false + +fun test() { + Foo().setTypeof("") +} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java index 6892a6706f3..055bf81d38b 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java @@ -15336,6 +15336,16 @@ public class IntentionTestGenerated extends AbstractIntentionTest { runTest("idea/testData/intentions/usePropertyAccessSyntax/getImplicitReceiver.kt"); } + @TestMetadata("getReservedWord1.kt") + public void testGetReservedWord1() throws Exception { + runTest("idea/testData/intentions/usePropertyAccessSyntax/getReservedWord1.kt"); + } + + @TestMetadata("getReservedWord2.kt") + public void testGetReservedWord2() throws Exception { + runTest("idea/testData/intentions/usePropertyAccessSyntax/getReservedWord2.kt"); + } + @TestMetadata("getSafeCall.kt") public void testGetSafeCall() throws Exception { runTest("idea/testData/intentions/usePropertyAccessSyntax/getSafeCall.kt"); @@ -15396,6 +15406,16 @@ public class IntentionTestGenerated extends AbstractIntentionTest { runTest("idea/testData/intentions/usePropertyAccessSyntax/setImplicitReceiver.kt"); } + @TestMetadata("setReservedWord1.kt") + public void testSetReservedWord1() throws Exception { + runTest("idea/testData/intentions/usePropertyAccessSyntax/setReservedWord1.kt"); + } + + @TestMetadata("setReservedWord2.kt") + public void testSetReservedWord2() throws Exception { + runTest("idea/testData/intentions/usePropertyAccessSyntax/setReservedWord2.kt"); + } + @TestMetadata("setSafeCall.kt") public void testSetSafeCall() throws Exception { runTest("idea/testData/intentions/usePropertyAccessSyntax/setSafeCall.kt");