[NI] Create error type for CST of error types
KT-36092 Fixed
This commit is contained in:
Generated
+5
@@ -9866,6 +9866,11 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte
|
||||
runTest("compiler/testData/diagnostics/tests/inference/coerceFunctionLiteralToSuspend.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("commonSuperTypeOfErrorTypes.kt")
|
||||
public void testCommonSuperTypeOfErrorTypes() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/commonSuperTypeOfErrorTypes.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("completeInferenceIfManyFailed.kt")
|
||||
public void testCompleteInferenceIfManyFailed() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/completeInferenceIfManyFailed.kt");
|
||||
|
||||
+5
@@ -21,6 +21,7 @@ import org.jetbrains.kotlin.types.AbstractFlexibilityChecker.hasDifferentFlexibi
|
||||
import org.jetbrains.kotlin.types.AbstractNullabilityChecker.hasPathByNotMarkedNullableNodes
|
||||
import org.jetbrains.kotlin.types.checker.SimpleClassicTypeSystemContext
|
||||
import org.jetbrains.kotlin.types.model.*
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
|
||||
|
||||
object NewCommonSuperTypeCalculator {
|
||||
// TODO: Bridge for old calls
|
||||
@@ -96,6 +97,10 @@ object NewCommonSuperTypeCalculator {
|
||||
contextStubTypesEqualToAnything: AbstractTypeCheckerContext,
|
||||
contextStubTypesNotEqual: AbstractTypeCheckerContext
|
||||
): SimpleTypeMarker {
|
||||
if (types.all { it is ErrorType }) {
|
||||
return ErrorUtils.createErrorType("CST(${types.joinToString()}")
|
||||
}
|
||||
|
||||
// i.e. result type also should be marked nullable
|
||||
val notAllNotNull =
|
||||
types.any { !isStubRelatedType(it) && !AbstractNullabilityChecker.isSubtypeOfAny(contextStubTypesEqualToAnything, it) }
|
||||
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNCHECKED_CAST
|
||||
|
||||
class Foo<T>
|
||||
class Bar<S>
|
||||
|
||||
fun <T> consume(x: Foo<out T>, y: Foo<out T>) {}
|
||||
fun <T> materialize() = null as T
|
||||
|
||||
fun test() {
|
||||
consume(
|
||||
materialize<Foo<Bar<ErrorType>>>(),
|
||||
materialize<Foo<Bar<ErrorType>>>()
|
||||
)
|
||||
|
||||
<!INAPPLICABLE_CANDIDATE!>consume<!>(
|
||||
materialize<Foo<Bar<ErrorType>>>(),
|
||||
materialize<Foo<ErrorType>>()
|
||||
)
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNCHECKED_CAST
|
||||
|
||||
class Foo<T>
|
||||
class Bar<S>
|
||||
|
||||
fun <T> consume(x: Foo<out T>, y: Foo<out T>) {}
|
||||
fun <T> materialize() = null as T
|
||||
|
||||
fun test() {
|
||||
consume(
|
||||
materialize<Foo<Bar<<!UNRESOLVED_REFERENCE!>ErrorType<!>>>>(),
|
||||
materialize<Foo<Bar<<!UNRESOLVED_REFERENCE!>ErrorType<!>>>>()
|
||||
)
|
||||
|
||||
consume(
|
||||
materialize<Foo<Bar<<!UNRESOLVED_REFERENCE!>ErrorType<!>>>>(),
|
||||
materialize<Foo<<!UNRESOLVED_REFERENCE!>ErrorType<!>>>()
|
||||
)
|
||||
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package
|
||||
|
||||
public fun </*0*/ T> consume(/*0*/ x: Foo<out T>, /*1*/ y: Foo<out T>): kotlin.Unit
|
||||
public fun </*0*/ T> materialize(): T
|
||||
public fun test(): kotlin.Unit
|
||||
|
||||
public final class Bar</*0*/ S> {
|
||||
public constructor Bar</*0*/ S>()
|
||||
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 Foo</*0*/ T> {
|
||||
public constructor Foo</*0*/ T>()
|
||||
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
|
||||
}
|
||||
@@ -9873,6 +9873,11 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/coerceFunctionLiteralToSuspend.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("commonSuperTypeOfErrorTypes.kt")
|
||||
public void testCommonSuperTypeOfErrorTypes() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/commonSuperTypeOfErrorTypes.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("completeInferenceIfManyFailed.kt")
|
||||
public void testCompleteInferenceIfManyFailed() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/completeInferenceIfManyFailed.kt");
|
||||
|
||||
Generated
+5
@@ -9868,6 +9868,11 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing
|
||||
runTest("compiler/testData/diagnostics/tests/inference/coerceFunctionLiteralToSuspend.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("commonSuperTypeOfErrorTypes.kt")
|
||||
public void testCommonSuperTypeOfErrorTypes() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/commonSuperTypeOfErrorTypes.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("completeInferenceIfManyFailed.kt")
|
||||
public void testCompleteInferenceIfManyFailed() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/completeInferenceIfManyFailed.kt");
|
||||
|
||||
Reference in New Issue
Block a user