[FE 1.0] Report INVISIBLE_MEMBER on all qualified expressions including safe call ones

^KT-47621 Fixed
This commit is contained in:
Victor Petukhov
2022-07-07 13:18:01 +02:00
committed by teamcity
parent e63e889a1f
commit fb21937eb1
8 changed files with 98 additions and 2 deletions
@@ -24152,6 +24152,12 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
runTest("compiler/testData/diagnostics/tests/properties/extensionPropertyMustHaveAccessorsOrBeAbstract.kt");
}
@Test
@TestMetadata("kt47621.kt")
public void testKt47621() throws Exception {
runTest("compiler/testData/diagnostics/tests/properties/kt47621.kt");
}
@Test
@TestMetadata("lateinitOnTopLevel.kt")
public void testLateinitOnTopLevel() throws Exception {
@@ -24152,6 +24152,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
runTest("compiler/testData/diagnostics/tests/properties/extensionPropertyMustHaveAccessorsOrBeAbstract.kt");
}
@Test
@TestMetadata("kt47621.kt")
public void testKt47621() throws Exception {
runTest("compiler/testData/diagnostics/tests/properties/kt47621.kt");
}
@Test
@TestMetadata("lateinitOnTopLevel.kt")
public void testLateinitOnTopLevel() throws Exception {
@@ -24152,6 +24152,12 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
runTest("compiler/testData/diagnostics/tests/properties/extensionPropertyMustHaveAccessorsOrBeAbstract.kt");
}
@Test
@TestMetadata("kt47621.kt")
public void testKt47621() throws Exception {
runTest("compiler/testData/diagnostics/tests/properties/kt47621.kt");
}
@Test
@TestMetadata("lateinitOnTopLevel.kt")
public void testLateinitOnTopLevel() throws Exception {
@@ -26,6 +26,7 @@ import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.diagnostics.DiagnosticFactory3
import org.jetbrains.kotlin.diagnostics.Errors
import org.jetbrains.kotlin.psi.KtDotQualifiedExpression
import org.jetbrains.kotlin.psi.KtQualifiedExpression
import org.jetbrains.kotlin.resolve.calls.checkers.CallChecker
import org.jetbrains.kotlin.resolve.calls.checkers.CallCheckerContext
import org.jetbrains.kotlin.resolve.calls.context.CallPosition
@@ -35,14 +36,14 @@ import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
import org.jetbrains.kotlin.synthetic.SyntheticJavaPropertyDescriptor
object ProtectedSyntheticExtensionCallChecker : CallChecker {
fun computeSuitableDescriptorAndError(
private fun computeSuitableDescriptorAndError(
descriptor: SyntheticJavaPropertyDescriptor,
reportOn: PsiElement,
context: CallCheckerContext
): Pair<FunctionDescriptor, DiagnosticFactory3<PsiElement, DeclarationDescriptor, DescriptorVisibility, DeclarationDescriptor>> {
val callPosition = context.resolutionContext.callPosition
val isLeftSide = callPosition is CallPosition.PropertyAssignment
&& (callPosition.leftPart as? KtDotQualifiedExpression)?.selectorExpression == reportOn
&& (callPosition.leftPart as? KtQualifiedExpression)?.selectorExpression == reportOn
val getMethod = descriptor.getMethod
val setMethod = descriptor.setMethod
val isImprovingDiagnosticsEnabled =
@@ -0,0 +1,23 @@
// WITH_STDLIB
// FILE: j/J.java
package j;
public class J {
public int getX() { return 1; }
protected void setX(int value) { throw new RuntimeException(); }
}
// FILE: main.kt
import j.*
class C : J() {
fun foo() {
<!INVISIBLE_SETTER!>J()<!UNNECESSARY_SAFE_CALL!>?.<!>x<!> = 1
}
}
fun box(): String {
C().foo()
return "OK"
}
@@ -0,0 +1,23 @@
// WITH_STDLIB
// FILE: j/J.java
package j;
public class J {
public int getX() { return 1; }
protected void setX(int value) { throw new RuntimeException(); }
}
// FILE: main.kt
import j.*
class C : J() {
fun foo() {
J()<!UNNECESSARY_SAFE_CALL!>?.<!><!INVISIBLE_SETTER!>x<!> = 1
}
}
fun box(): String {
C().foo()
return "OK"
}
@@ -0,0 +1,25 @@
package
public fun box(): kotlin.String
public final class C : j.J {
public constructor C()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final fun foo(): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun getX(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
protected/*protected and package*/ open override /*1*/ /*fake_override*/ fun setX(/*0*/ value: kotlin.Int): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
package j {
public open class J {
public constructor J()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open fun getX(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
protected/*protected and package*/ open fun setX(/*0*/ value: kotlin.Int): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
}
@@ -24158,6 +24158,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
runTest("compiler/testData/diagnostics/tests/properties/extensionPropertyMustHaveAccessorsOrBeAbstract.kt");
}
@Test
@TestMetadata("kt47621.kt")
public void testKt47621() throws Exception {
runTest("compiler/testData/diagnostics/tests/properties/kt47621.kt");
}
@Test
@TestMetadata("lateinitOnTopLevel.kt")
public void testLateinitOnTopLevel() throws Exception {