[FE 1.0] Report errors for recursive types from completion as well
Such diagnostics could be missed at least for plus assignment's right side because it wasn't report for the second time of analysis ^KT-48546 Fixed
This commit is contained in:
committed by
teamcity
parent
27fa632630
commit
2307122089
+24
@@ -8080,6 +8080,18 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
|
||||
runTest("compiler/testData/diagnostics/tests/delegatedProperty/kt4640.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt48546.kt")
|
||||
public void testKt48546() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/delegatedProperty/kt48546.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt48546Strict.kt")
|
||||
public void testKt48546Strict() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/delegatedProperty/kt48546Strict.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("localVariable.kt")
|
||||
public void testLocalVariable() throws Exception {
|
||||
@@ -8524,6 +8536,12 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
|
||||
runTest("compiler/testData/diagnostics/tests/delegation/kt44843.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt48546.kt")
|
||||
public void testKt48546() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/delegation/kt48546.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt49477.kt")
|
||||
public void testKt49477() throws Exception {
|
||||
@@ -25050,6 +25068,12 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
|
||||
runTest("compiler/testData/diagnostics/tests/resolve/inferenceInLinkedLambdasDependentOnExpectedType.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt28109.kt")
|
||||
public void testKt28109() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/resolve/kt28109.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt36264.kt")
|
||||
public void testKt36264() throws Exception {
|
||||
|
||||
+12
@@ -8080,6 +8080,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
|
||||
runTest("compiler/testData/diagnostics/tests/delegatedProperty/kt4640.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt48546.kt")
|
||||
public void testKt48546() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/delegatedProperty/kt48546.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("localVariable.kt")
|
||||
public void testLocalVariable() throws Exception {
|
||||
@@ -8524,6 +8530,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
|
||||
runTest("compiler/testData/diagnostics/tests/delegation/kt44843.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt48546.kt")
|
||||
public void testKt48546() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/delegation/kt48546.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt49477.kt")
|
||||
public void testKt49477() throws Exception {
|
||||
|
||||
+12
@@ -8080,6 +8080,12 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
|
||||
runTest("compiler/testData/diagnostics/tests/delegatedProperty/kt4640.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt48546.kt")
|
||||
public void testKt48546() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/delegatedProperty/kt48546.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("localVariable.kt")
|
||||
public void testLocalVariable() throws Exception {
|
||||
@@ -8524,6 +8530,12 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
|
||||
runTest("compiler/testData/diagnostics/tests/delegation/kt44843.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt48546.kt")
|
||||
public void testKt48546() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/delegation/kt48546.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt49477.kt")
|
||||
public void testKt49477() throws Exception {
|
||||
|
||||
+1
@@ -75,6 +75,7 @@ class DiagnosticReporterByTrackingStrategy(
|
||||
trace,
|
||||
(diagnostic as NoValueForParameter).parameterDescriptor
|
||||
)
|
||||
TypeCheckerHasRanIntoRecursion::class.java -> tracingStrategy.recursiveType(trace)
|
||||
InstantiationOfAbstractClass::class.java -> tracingStrategy.instantiationOfAbstractClass(trace)
|
||||
AbstractSuperCall::class.java -> {
|
||||
val superExpression = (diagnostic as AbstractSuperCall).receiver.psiExpression as? KtSuperExpression
|
||||
|
||||
+7
@@ -137,6 +137,13 @@ public abstract class AbstractTracingStrategy implements TracingStrategy {
|
||||
trace.report(CREATING_AN_INSTANCE_OF_ABSTRACT_CLASS.on(call.getCallElement()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recursiveType(@NotNull BindingTrace trace) {
|
||||
KtExpression expression = call.getCalleeExpression();
|
||||
if (expression == null) return;
|
||||
trace.report(TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM.getErrorFactory().on(expression));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void abstractSuperCall(@NotNull BindingTrace trace) {
|
||||
trace.report(ABSTRACT_SUPER_CALL.on(reference));
|
||||
|
||||
@@ -81,6 +81,9 @@ public interface TracingStrategy {
|
||||
@NotNull Collection<? extends ResolvedCall<D>> descriptors
|
||||
) {}
|
||||
|
||||
@Override
|
||||
public void recursiveType(@NotNull BindingTrace trace) {}
|
||||
|
||||
@Override
|
||||
public void instantiationOfAbstractClass(@NotNull BindingTrace trace) {}
|
||||
|
||||
@@ -144,6 +147,8 @@ public interface TracingStrategy {
|
||||
@NotNull Collection<? extends ResolvedCall<D>> descriptors
|
||||
);
|
||||
|
||||
void recursiveType(@NotNull BindingTrace trace);
|
||||
|
||||
void instantiationOfAbstractClass(@NotNull BindingTrace trace);
|
||||
|
||||
void abstractSuperCall(@NotNull BindingTrace trace);
|
||||
|
||||
+5
@@ -584,6 +584,11 @@ public class ControlStructureTypingUtils {
|
||||
logError();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recursiveType(@NotNull BindingTrace trace) {
|
||||
logError();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <D extends CallableDescriptor> void unresolvedReferenceWrongReceiver(
|
||||
@NotNull BindingTrace trace, @NotNull Collection<? extends ResolvedCall<D>> candidates
|
||||
|
||||
+6
@@ -26,6 +26,8 @@ import org.jetbrains.kotlin.resolve.calls.tower.forceResolution
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.TypeUtils
|
||||
import org.jetbrains.kotlin.types.UnwrappedType
|
||||
import org.jetbrains.kotlin.types.error.ErrorType
|
||||
import org.jetbrains.kotlin.types.error.ErrorTypeKind
|
||||
import org.jetbrains.kotlin.types.model.safeSubstitute
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.same
|
||||
|
||||
@@ -269,6 +271,10 @@ class KotlinCallCompleter(
|
||||
}
|
||||
|
||||
constraintSystem.errors.forEach(diagnosticsHolder::addError)
|
||||
|
||||
if (returnType is ErrorType && returnType.kind == ErrorTypeKind.RECURSIVE_TYPE) {
|
||||
diagnosticsHolder.addDiagnostic(TypeCheckerHasRanIntoRecursion(resolvedCallAtom))
|
||||
}
|
||||
}
|
||||
|
||||
private fun prepareCandidateForCompletion(
|
||||
|
||||
+4
@@ -116,6 +116,10 @@ class WrongCountOfTypeArguments(
|
||||
override fun report(reporter: DiagnosticReporter) = reporter.onTypeArguments(this)
|
||||
}
|
||||
|
||||
class TypeCheckerHasRanIntoRecursion : KotlinCallDiagnostic(INAPPLICABLE) {
|
||||
override fun report(reporter: DiagnosticReporter) = reporter.onCall(this)
|
||||
}
|
||||
|
||||
// Callable reference resolution
|
||||
class CallableReferenceNotCompatible(
|
||||
argument: CallableReferenceResolutionAtom,
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
// WITH_STDLIB
|
||||
|
||||
object DelegateTest {
|
||||
var result = ""
|
||||
val f by lazy {
|
||||
result += <!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE, TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM_ERROR!>f<!>.<!DEBUG_INFO_MISSING_UNRESOLVED!>toString<!>() // Compiler crash
|
||||
"hello"
|
||||
}
|
||||
}
|
||||
|
||||
object DelegateTest2 {
|
||||
var result = ""
|
||||
val f by lazy {
|
||||
result += <!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE, TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM_ERROR!>f<!>
|
||||
"hello"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
// WITH_STDLIB
|
||||
|
||||
object DelegateTest {
|
||||
var result = ""
|
||||
val f by lazy {
|
||||
result += <!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE, TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM_ERROR!>f<!>.<!DEBUG_INFO_MISSING_UNRESOLVED!>toString<!>() // Compiler crash
|
||||
"hello"
|
||||
}
|
||||
}
|
||||
|
||||
object DelegateTest2 {
|
||||
var result = ""
|
||||
val f by lazy {
|
||||
result += <!TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM_ERROR!>f<!>
|
||||
"hello"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package
|
||||
|
||||
public object DelegateTest {
|
||||
private constructor DelegateTest()
|
||||
public final val f: kotlin.String
|
||||
public final var result: kotlin.String
|
||||
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
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
object DelegateTest {
|
||||
var result = ""
|
||||
val f by lazy {
|
||||
result += <!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>f<!>.<!DEBUG_INFO_MISSING_UNRESOLVED!>toString<!>() // Compiler crash
|
||||
result += <!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE, TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM_ERROR!>f<!>.<!DEBUG_INFO_MISSING_UNRESOLVED!>toString<!>() // Compiler crash
|
||||
"hello"
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,6 @@ suspend fun fib(n: Long) =
|
||||
async {
|
||||
when {
|
||||
n < 2 -> n
|
||||
else -> <!TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM_ERROR!><!DEBUG_INFO_MISSING_UNRESOLVED!>fib<!>(<!DEBUG_INFO_MISSING_UNRESOLVED!>n<!> <!DEBUG_INFO_MISSING_UNRESOLVED!>-<!> 1)<!>.<!DEBUG_INFO_MISSING_UNRESOLVED!>await<!>() <!DEBUG_INFO_MISSING_UNRESOLVED!>+<!> fib(n - 2).<!DEBUG_INFO_MISSING_UNRESOLVED!>await<!>()
|
||||
else -> <!TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM_ERROR!><!DEBUG_INFO_MISSING_UNRESOLVED!>fib<!>(<!DEBUG_INFO_MISSING_UNRESOLVED!>n<!> <!DEBUG_INFO_MISSING_UNRESOLVED!>-<!> 1)<!>.<!DEBUG_INFO_MISSING_UNRESOLVED!>await<!>() <!DEBUG_INFO_MISSING_UNRESOLVED!>+<!> <!TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM_ERROR!>fib<!>(n - 2).<!DEBUG_INFO_MISSING_UNRESOLVED!>await<!>()
|
||||
}
|
||||
}
|
||||
|
||||
Generated
+12
@@ -8086,6 +8086,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
||||
runTest("compiler/testData/diagnostics/tests/delegatedProperty/kt4640.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt48546.kt")
|
||||
public void testKt48546() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/delegatedProperty/kt48546.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("localVariable.kt")
|
||||
public void testLocalVariable() throws Exception {
|
||||
@@ -8530,6 +8536,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
||||
runTest("compiler/testData/diagnostics/tests/delegation/kt44843.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt48546.kt")
|
||||
public void testKt48546() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/delegation/kt48546.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt49477.kt")
|
||||
public void testKt49477() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user