[FE 1.0] Don't report CAST_NEVER_SUCCEEDS on stub types
^KT-49829 Fixed
This commit is contained in:
committed by
teamcity
parent
37d163d417
commit
8e2b90b5db
+6
@@ -13944,6 +13944,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
|
||||
runTest("compiler/testData/diagnostics/tests/inference/builderInference/kt47744.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt49829.kt")
|
||||
public void testKt49829() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/builderInference/kt49829.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("labaledCall.kt")
|
||||
public void testLabaledCall() throws Exception {
|
||||
|
||||
+6
@@ -13944,6 +13944,12 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
|
||||
runTest("compiler/testData/diagnostics/tests/inference/builderInference/kt47744.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt49829.kt")
|
||||
public void testKt49829() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/builderInference/kt49829.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("labaledCall.kt")
|
||||
public void testLabaledCall() throws Exception {
|
||||
|
||||
+2
-1
@@ -76,6 +76,7 @@ import org.jetbrains.kotlin.types.checker.KotlinTypeChecker;
|
||||
import org.jetbrains.kotlin.types.expressions.ControlStructureTypingUtils.ResolveConstruct;
|
||||
import org.jetbrains.kotlin.types.expressions.typeInfoFactory.TypeInfoFactoryKt;
|
||||
import org.jetbrains.kotlin.types.expressions.unqualifiedSuper.UnqualifiedSuperKt;
|
||||
import org.jetbrains.kotlin.types.typeUtil.TypeUtilsKt;
|
||||
import org.jetbrains.kotlin.util.OperatorNameConventions;
|
||||
|
||||
import java.util.Collection;
|
||||
@@ -372,7 +373,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!CastDiagnosticsUtil.isCastPossible(actualType, targetType, components.platformToKotlinClassMapper)) {
|
||||
if (!CastDiagnosticsUtil.isCastPossible(actualType, targetType, components.platformToKotlinClassMapper) && !TypeUtilsKt.isStubType(actualType)) {
|
||||
context.trace.report(CAST_NEVER_SUCCEEDS.on(expression.getOperationReference()));
|
||||
return;
|
||||
}
|
||||
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// WITH_STDLIB
|
||||
// For FIR: see KT-50293
|
||||
|
||||
fun main() {
|
||||
val list = buildList {
|
||||
add("one")
|
||||
add("two")
|
||||
|
||||
val secondParameter = get(1)
|
||||
println(secondParameter <!USELESS_CAST!>as String<!>) // WARNING: [CAST_NEVER_SUCCEEDS] This cast can never succeed
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// WITH_STDLIB
|
||||
// For FIR: see KT-50293
|
||||
|
||||
fun main() {
|
||||
val list = buildList {
|
||||
add("one")
|
||||
add("two")
|
||||
|
||||
val secondParameter = get(1)
|
||||
println(secondParameter as String) // WARNING: [CAST_NEVER_SUCCEEDS] This cast can never succeed
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
package
|
||||
|
||||
public fun main(): kotlin.Unit
|
||||
Generated
+6
@@ -13950,6 +13950,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/builderInference/kt47744.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt49829.kt")
|
||||
public void testKt49829() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/builderInference/kt49829.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("labaledCall.kt")
|
||||
public void testLabaledCall() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user