[FIR] KT-54587: Report the missing diagnostics

^KT-54587 Fixed

Merge-request: KT-MR-7791
Merged-by: Nikolay Lunyak <Nikolay.Lunyak@jetbrains.com>
This commit is contained in:
Nikolay Lunyak
2022-11-25 10:19:58 +00:00
committed by Space Team
parent 3f95b7e031
commit a454d42e65
10 changed files with 135 additions and 0 deletions
@@ -453,6 +453,18 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
runTest("compiler/testData/diagnostics/tests/kt53988.kt");
}
@Test
@TestMetadata("kt54587_1.kt")
public void testKt54587_1() throws Exception {
runTest("compiler/testData/diagnostics/tests/kt54587_1.kt");
}
@Test
@TestMetadata("kt54587_2.kt")
public void testKt54587_2() throws Exception {
runTest("compiler/testData/diagnostics/tests/kt54587_2.kt");
}
@Test
@TestMetadata("LValueAssignment.kt")
public void testLValueAssignment() throws Exception {
@@ -453,6 +453,18 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
runTest("compiler/testData/diagnostics/tests/kt53988.kt");
}
@Test
@TestMetadata("kt54587_1.kt")
public void testKt54587_1() throws Exception {
runTest("compiler/testData/diagnostics/tests/kt54587_1.kt");
}
@Test
@TestMetadata("kt54587_2.kt")
public void testKt54587_2() throws Exception {
runTest("compiler/testData/diagnostics/tests/kt54587_2.kt");
}
@Test
@TestMetadata("LValueAssignment.kt")
public void testLValueAssignment() throws Exception {
@@ -453,6 +453,18 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
runTest("compiler/testData/diagnostics/tests/kt53988.kt");
}
@Test
@TestMetadata("kt54587_1.kt")
public void testKt54587_1() throws Exception {
runTest("compiler/testData/diagnostics/tests/kt54587_1.kt");
}
@Test
@TestMetadata("kt54587_2.kt")
public void testKt54587_2() throws Exception {
runTest("compiler/testData/diagnostics/tests/kt54587_2.kt");
}
@Test
@TestMetadata("LValueAssignment.kt")
public void testLValueAssignment() throws Exception {
@@ -122,6 +122,15 @@ object FirDestructuringDeclarationChecker : FirPropertyChecker() {
context
)
}
is ConeInapplicableWrongReceiver -> {
reporter.reportOn(
source,
FirErrors.COMPONENT_FUNCTION_MISSING,
diagnostic.candidates.first().callInfo.name,
destructuringDeclarationType,
context
)
}
is ConeAmbiguityError -> {
reporter.reportOn(
source,
@@ -34,6 +34,7 @@ import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference
import org.jetbrains.kotlin.fir.resolve.calls.UnsafeCall
import org.jetbrains.kotlin.fir.resolve.diagnostics.ConeAmbiguityError
import org.jetbrains.kotlin.fir.resolve.diagnostics.ConeInapplicableCandidateError
import org.jetbrains.kotlin.fir.resolve.diagnostics.ConeInapplicableWrongReceiver
import org.jetbrains.kotlin.fir.resolve.diagnostics.ConeUnresolvedNameError
import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol
import org.jetbrains.kotlin.fir.symbols.impl.FirNamedFunctionSymbol
@@ -113,6 +114,9 @@ object FirForLoopChecker : FirBlockChecker() {
is ConeUnresolvedNameError -> {
reporter.reportOn(reportSource, missingFactory, context)
}
is ConeInapplicableWrongReceiver -> noneApplicableFactory?.let {
reporter.reportOn(reportSource, it, diagnostic.candidateSymbols, context)
}
is ConeInapplicableCandidateError -> {
if (unsafeCallFactory != null || noneApplicableFactory != null) {
diagnostic.candidate.diagnostics.filter { it.applicability == diagnostic.applicability }.forEach {
+12
View File
@@ -0,0 +1,12 @@
// FIR_IDENTICAL
class MyClass
class SomeClass
operator fun SomeClass.component1() {}
operator fun SomeClass.component2() {}
fun test() {
val (o, o2) = SomeClass()
val (o3, o4) = <!COMPONENT_FUNCTION_MISSING, COMPONENT_FUNCTION_MISSING!>MyClass()<!> // [COMPONENT_FUNCTION_MISSING] expected as in K1
}
+19
View File
@@ -0,0 +1,19 @@
package
public fun test(): kotlin.Unit
public operator fun SomeClass.component1(): kotlin.Unit
public operator fun SomeClass.component2(): kotlin.Unit
public final class MyClass {
public constructor MyClass()
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 toString(): kotlin.String
}
public final class SomeClass {
public constructor SomeClass()
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 toString(): kotlin.String
}
+17
View File
@@ -0,0 +1,17 @@
// FIR_IDENTICAL
package one
fun test(f: NextMissing) {
for(i in <!NEXT_NONE_APPLICABLE!>f<!>) {} //[NEXT_NONE_APPLICABLE] is expected as in K1
}
interface Doo
operator fun Doo.next() {}
interface NextMissing {
operator fun iterator(): NextMissing2
}
interface NextMissing2 {
operator fun hasNext(): Boolean
}
+26
View File
@@ -0,0 +1,26 @@
package
package one {
public fun test(/*0*/ f: one.NextMissing): kotlin.Unit
public operator fun one.Doo.next(): kotlin.Unit
public interface Doo {
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 toString(): kotlin.String
}
public interface NextMissing {
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 abstract operator fun iterator(): one.NextMissing2
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public interface NextMissing2 {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public abstract operator fun hasNext(): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
}
@@ -453,6 +453,18 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
runTest("compiler/testData/diagnostics/tests/kt53988.kt");
}
@Test
@TestMetadata("kt54587_1.kt")
public void testKt54587_1() throws Exception {
runTest("compiler/testData/diagnostics/tests/kt54587_1.kt");
}
@Test
@TestMetadata("kt54587_2.kt")
public void testKt54587_2() throws Exception {
runTest("compiler/testData/diagnostics/tests/kt54587_2.kt");
}
@Test
@TestMetadata("LValueAssignment.kt")
public void testLValueAssignment() throws Exception {