From a545ec41a0303971ac06be0e0a9093edce99687e Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Tue, 21 Apr 2020 19:22:47 +0300 Subject: [PATCH] FIR serializer: consider exotic types as errors (breaks 4 BB tests) --- .../fir/serialization/FirElementSerializer.kt | 22 ++----------------- .../diagnostics/functions/inference/kt6176.kt | 1 + ...nctionWithExpressionBodyWithJavaGeneric.kt | 1 + .../codegen/box/lazyCodegen/ifElse.kt | 1 + .../commonSupertypeContravariant2.kt | 1 + 5 files changed, 6 insertions(+), 20 deletions(-) diff --git a/compiler/fir/fir-serialization/src/org/jetbrains/kotlin/fir/serialization/FirElementSerializer.kt b/compiler/fir/fir-serialization/src/org/jetbrains/kotlin/fir/serialization/FirElementSerializer.kt index 9b754c45412..9df05672e22 100644 --- a/compiler/fir/fir-serialization/src/org/jetbrains/kotlin/fir/serialization/FirElementSerializer.kt +++ b/compiler/fir/fir-serialization/src/org/jetbrains/kotlin/fir/serialization/FirElementSerializer.kt @@ -550,10 +550,6 @@ class FirElementSerializer private constructor( val builder = ProtoBuf.Type.newBuilder() when (type) { - is ConeIntegerLiteralType -> { - // Questionable, I'm not sure we should expect this type here - return typeProto(type.getApproximatedType()) - } is ConeKotlinErrorType -> { extension.serializeErrorType(type, builder) return builder @@ -569,20 +565,6 @@ class FirElementSerializer private constructor( } return lowerBound } - is ConeCapturedType -> { - val lowerType = type.lowerType - return if (lowerType != null) { - typeProto(lowerType) - } else { - typeProto(type.constructor.supertypes!!.first()) - } - } - is ConeDefinitelyNotNullType -> { - return typeProto(type.original) - } - is ConeIntersectionType -> { - return typeProto(type.intersectedTypes.first()) - } is ConeClassLikeType -> { if (type.isSuspendFunctionType(session)) { val runtimeFunctionType = transformSuspendFunctionToRuntimeFunctionType(type) @@ -600,8 +582,8 @@ class FirElementSerializer private constructor( builder.typeParameter = getTypeParameterId(typeParameter) } } - is ConeLookupTagBasedType, is ConeStubType -> { - throw AssertionError("Should not be here") + else -> { + throw AssertionError("Should not be here: ${type::class.java}") } } diff --git a/compiler/testData/codegen/box/diagnostics/functions/inference/kt6176.kt b/compiler/testData/codegen/box/diagnostics/functions/inference/kt6176.kt index 15a7a2e94e2..48e4e8d2375 100644 --- a/compiler/testData/codegen/box/diagnostics/functions/inference/kt6176.kt +++ b/compiler/testData/codegen/box/diagnostics/functions/inference/kt6176.kt @@ -1,3 +1,4 @@ +// IGNORE_BACKEND_FIR: JVM_IR // !DIAGNOSTICS: -DEBUG_INFO_SMARTCAST fun foo(f: () -> R): R = f() diff --git a/compiler/testData/codegen/box/javaInterop/notNullAssertions/enhancedNullability/inFunctionWithExpressionBodyWithJavaGeneric.kt b/compiler/testData/codegen/box/javaInterop/notNullAssertions/enhancedNullability/inFunctionWithExpressionBodyWithJavaGeneric.kt index e85957c8e19..6a1a76f985f 100644 --- a/compiler/testData/codegen/box/javaInterop/notNullAssertions/enhancedNullability/inFunctionWithExpressionBodyWithJavaGeneric.kt +++ b/compiler/testData/codegen/box/javaInterop/notNullAssertions/enhancedNullability/inFunctionWithExpressionBodyWithJavaGeneric.kt @@ -1,3 +1,4 @@ +// IGNORE_BACKEND_FIR: JVM_IR // !LANGUAGE: +StrictJavaNullabilityAssertions // TARGET_BACKEND: JVM // SKIP_JDK6 diff --git a/compiler/testData/codegen/box/lazyCodegen/ifElse.kt b/compiler/testData/codegen/box/lazyCodegen/ifElse.kt index 0f683860b24..c1c12b79d10 100644 --- a/compiler/testData/codegen/box/lazyCodegen/ifElse.kt +++ b/compiler/testData/codegen/box/lazyCodegen/ifElse.kt @@ -1,3 +1,4 @@ +// IGNORE_BACKEND_FIR: JVM_IR class A (val p: String, p1: String, p2: String) { var cond1 :String = "" diff --git a/compiler/testData/codegen/box/regressions/commonSupertypeContravariant2.kt b/compiler/testData/codegen/box/regressions/commonSupertypeContravariant2.kt index 959eaf527aa..15b8f2e9c6e 100644 --- a/compiler/testData/codegen/box/regressions/commonSupertypeContravariant2.kt +++ b/compiler/testData/codegen/box/regressions/commonSupertypeContravariant2.kt @@ -1,3 +1,4 @@ +// IGNORE_BACKEND_FIR: JVM_IR interface In class A : In class B : In