[Manglers] Uniform handling of the error type in signature mangled names in all manglers

^KT-63723
This commit is contained in:
Dmitriy Dolovov
2023-12-13 21:30:06 +01:00
committed by Space Team
parent 089b7f31b5
commit 194efac68c
9 changed files with 76 additions and 56 deletions
@@ -134,6 +134,10 @@ open class FirMangleComputer(
override fun mangleType(tBuilder: StringBuilder, type: ConeKotlinType, declarationSiteSession: FirSession) {
when (type) {
is ConeErrorType -> {
tBuilder.appendSignature(MangleConstant.ERROR_MARK)
}
is ConeLookupTagBasedType -> {
when (val symbol = type.lookupTag.toSymbol(declarationSiteSession)) {
is FirTypeAliasSymbol -> {
@@ -13,6 +13,7 @@ import org.jetbrains.kotlin.ir.descriptors.IrPropertyDelegateDescriptor
import org.jetbrains.kotlin.renderer.DescriptorRenderer
import org.jetbrains.kotlin.types.*
import org.jetbrains.kotlin.types.checker.SimpleClassicTypeSystemContext
import org.jetbrains.kotlin.types.error.ErrorClassDescriptor
import org.jetbrains.kotlin.types.model.TypeSystemContext
import org.jetbrains.kotlin.types.typeUtil.isUnit
@@ -92,6 +93,10 @@ open class DescriptorMangleComputer(builder: StringBuilder, mode: MangleMode) :
is SimpleType -> {
when (val classifier = type.constructor.declarationDescriptor) {
is ErrorClassDescriptor -> {
tBuilder.appendSignature(MangleConstant.ERROR_MARK)
return
}
is ClassDescriptor -> with(copy(MangleMode.FQNAME)) { classifier.visit() }
is TypeParameterDescriptor -> tBuilder.mangleTypeParameterReference(classifier)
else -> error("Unexpected classifier: $classifier")
@@ -0,0 +1,29 @@
FILE fqName:<root> fileName:/unresolvedReference.kt
PROPERTY name:test1 visibility:public modality:FINAL [val]
FIELD PROPERTY_BACKING_FIELD name:test1 type:IrErrorType(null) visibility:private [final,static]
EXPRESSION_BODY
ERROR_CALL 'Unresolved reference: <Unresolved name: unresolved>#' type=IrErrorType(null)
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-test1> visibility:public modality:FINAL <> () returnType:IrErrorType(null)
correspondingProperty: PROPERTY name:test1 visibility:public modality:FINAL [val]
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun <get-test1> (): IrErrorType(null) declared in <root>'
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:test1 type:IrErrorType(null) visibility:private [final,static]' type=IrErrorType(null) origin=null
PROPERTY name:test2 visibility:public modality:FINAL [val]
FIELD PROPERTY_BACKING_FIELD name:test2 type:IrErrorType(null) visibility:private [final,static]
EXPRESSION_BODY
ERROR_CALL 'Unresolved reference: <Unresolved name: unresolved>#' type=IrErrorType(null)
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-test2> visibility:public modality:FINAL <> () returnType:IrErrorType(null)
correspondingProperty: PROPERTY name:test2 visibility:public modality:FINAL [val]
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun <get-test2> (): IrErrorType(null) declared in <root>'
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:test2 type:IrErrorType(null) visibility:private [final,static]' type=IrErrorType(null) origin=null
PROPERTY name:test3 visibility:public modality:FINAL [val]
FIELD PROPERTY_BACKING_FIELD name:test3 type:IrErrorType(null) visibility:private [final,static]
EXPRESSION_BODY
ERROR_CALL 'Unresolved reference: <Unresolved name: unresolved>#' type=IrErrorType(null)
CONST Int type=kotlin.Int value=56
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-test3> visibility:public modality:FINAL <> () returnType:IrErrorType(null)
correspondingProperty: PROPERTY name:test3 visibility:public modality:FINAL [val]
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun <get-test3> (): IrErrorType(null) declared in <root>'
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:test3 type:IrErrorType(null) visibility:private [final,static]' type=IrErrorType(null) origin=null
@@ -0,0 +1,11 @@
val test1: ErrorType
field = error("") /* ErrorCallExpression */
get
val test2: ErrorType
field = error("") /* ErrorCallExpression */
get
val test3: ErrorType
field = error("") /* ErrorCallExpression */56;
get
@@ -28,12 +28,3 @@ FILE fqName:<root> fileName:/unresolvedReference.kt
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun <get-test3> (): IrErrorType([Error type: Not found recorded type for 42.unresolved(56)]) declared in <root>'
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:test3 type:IrErrorType([Error type: Not found recorded type for 42.unresolved(56)]) visibility:private [final,static]' type=IrErrorType([Error type: Not found recorded type for 42.unresolved(56)]) origin=null
PROPERTY name:test4 visibility:public modality:FINAL [val]
FIELD PROPERTY_BACKING_FIELD name:test4 type:IrErrorType([Error type: Not found recorded type for 42 *]) visibility:private [final,static]
EXPRESSION_BODY
ERROR_EXPR '42 *' type=IrErrorType([Error type: Error expression type])
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-test4> visibility:public modality:FINAL <> () returnType:IrErrorType([Error type: Not found recorded type for 42 *])
correspondingProperty: PROPERTY name:test4 visibility:public modality:FINAL [val]
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun <get-test4> (): IrErrorType([Error type: Not found recorded type for 42 *]) declared in <root>'
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:test4 type:IrErrorType([Error type: Not found recorded type for 42 *]) visibility:private [final,static]' type=IrErrorType([Error type: Not found recorded type for 42 *]) origin=null
+4 -8
View File
@@ -1,10 +1,8 @@
// IGNORE_BACKEND_K2: JVM_IR
// IGNORE_BACKEND: JS_IR
// !IGNORE_ERRORS
// IGNORE_ERRORS
// IGNORE_FIR_DIAGNOSTICS
// DIAGNOSTICS: -UNRESOLVED_REFERENCE -OVERLOAD_RESOLUTION_AMBIGUITY
// KT-61141: org.jetbrains.kotlin.psi2ir.generators.ErrorExpressionException: null: KtNameReferenceExpression: unresolved
// IGNORE_BACKEND: NATIVE
// ERROR_POLICY: SEMANTIC
// SKIP_KLIB_TEST
val test1 = unresolved
@@ -12,5 +10,3 @@ val test2: Unresolved =
unresolved()
val test3 = 42.unresolved(56)
val test4 = 42 *<!SYNTAX!><!>
@@ -9,7 +9,3 @@ val test2: ErrorType
val test3: ErrorType
field = error("") /* ErrorCallExpression */42; 56;
get
val test4: ErrorType
field = error("") /* ErrorExpression */
get
@@ -5,12 +5,12 @@
val test1: ErrorType
// CHECK JVM_IR:
// Mangled name: #<get-test1>(){}<ERROR CLASS>
// Mangled name for the signature computed from Ir: <get-test1>(){}<ERROR CLASS>
// Mangled name for the signature computed from Descriptor: <get-test1>(){}<Error class: unknown class>
// Public signature by IR: /test1.<get-test1>|3342025465423582211[0]
// Public signature by IR debug description: <get-test1>(){}<ERROR CLASS>
// Public signature by Frontend: /test1.<get-test1>|-4817139884021780494[0]
// Public signature by Frontend debug description: <get-test1>(){}<Error class: unknown class>
// Public signature: /test1.<get-test1>|3342025465423582211[0]
// Public signature debug description: <get-test1>(){}<ERROR CLASS>
// CHECK JS_IR NATIVE:
// Mangled name: #<get-test1>(){}
// Public signature: /test1.<get-test1>|-5735092642142423279[0]
// Public signature debug description: <get-test1>(){}
get
// CHECK:
@@ -20,12 +20,12 @@ val test1: ErrorType
val test2: ErrorType
// CHECK JVM_IR:
// Mangled name: #<get-test2>(){}<ERROR CLASS>
// Mangled name for the signature computed from Ir: <get-test2>(){}<ERROR CLASS>
// Mangled name for the signature computed from Descriptor: <get-test2>(){}<Error class: unknown class>
// Public signature by IR: /test2.<get-test2>|-7934828597056891230[0]
// Public signature by IR debug description: <get-test2>(){}<ERROR CLASS>
// Public signature by Frontend: /test2.<get-test2>|1859255286326922853[0]
// Public signature by Frontend debug description: <get-test2>(){}<Error class: unknown class>
// Public signature: /test2.<get-test2>|-7934828597056891230[0]
// Public signature debug description: <get-test2>(){}<ERROR CLASS>
// CHECK JS_IR NATIVE:
// Mangled name: #<get-test2>(){}
// Public signature: /test2.<get-test2>|-5218942532816206869[0]
// Public signature debug description: <get-test2>(){}
get
// CHECK:
@@ -35,26 +35,10 @@ val test2: ErrorType
val test3: ErrorType
// CHECK JVM_IR:
// Mangled name: #<get-test3>(){}<ERROR CLASS>
// Mangled name for the signature computed from Ir: <get-test3>(){}<ERROR CLASS>
// Mangled name for the signature computed from Descriptor: <get-test3>(){}<Error class: unknown class>
// Public signature by IR: /test3.<get-test3>|3662345001344960274[0]
// Public signature by IR debug description: <get-test3>(){}<ERROR CLASS>
// Public signature by Frontend: /test3.<get-test3>|-2322568342617474229[0]
// Public signature by Frontend debug description: <get-test3>(){}<Error class: unknown class>
// Public signature: /test3.<get-test3>|3662345001344960274[0]
// Public signature debug description: <get-test3>(){}<ERROR CLASS>
// CHECK JS_IR NATIVE:
// Mangled name: #<get-test3>(){}
// Public signature: /test3.<get-test3>|-7333791615083236686[0]
// Public signature debug description: <get-test3>(){}
get
// CHECK:
// Mangled name: {}test4
// Public signature: /test4|-9115637610245762085[0]
// Public signature debug description: {}test4
val test4: ErrorType
// CHECK JVM_IR:
// Mangled name: #<get-test4>(){}<ERROR CLASS>
// Mangled name for the signature computed from Ir: <get-test4>(){}<ERROR CLASS>
// Mangled name for the signature computed from Descriptor: <get-test4>(){}<Error class: unknown class>
// Public signature by IR: /test4.<get-test4>|-8718941795621950036[0]
// Public signature by IR debug description: <get-test4>(){}<ERROR CLASS>
// Public signature by Frontend: /test4.<get-test4>|-5181690683324812065[0]
// Public signature by Frontend debug description: <get-test4>(){}<Error class: unknown class>
get
@@ -26,6 +26,7 @@ import org.jetbrains.kotlin.psi2ir.Psi2IrTranslator
import org.jetbrains.kotlin.psi2ir.generators.DeclarationStubGeneratorImpl
import org.jetbrains.kotlin.test.TargetBackend
import org.jetbrains.kotlin.test.backend.ir.IrBackendInput
import org.jetbrains.kotlin.test.directives.CodegenTestDirectives
import org.jetbrains.kotlin.test.frontend.classic.ClassicFrontendOutputArtifact
import org.jetbrains.kotlin.test.model.BackendKinds
import org.jetbrains.kotlin.test.model.Frontend2BackendConverter
@@ -69,7 +70,10 @@ class ClassicFrontend2NativeIrConverter(
val sourceFiles: List<KtFile> = psiFiles.values.toList()
val translator = Psi2IrTranslator(
configuration.languageVersionSettings,
Psi2IrConfiguration(ignoreErrors = false, configuration.partialLinkageConfig.isEnabled),
Psi2IrConfiguration(
ignoreErrors = CodegenTestDirectives.IGNORE_ERRORS in module.directives,
configuration.partialLinkageConfig.isEnabled
),
configuration.irMessageLogger::checkNoUnboundSymbols
)
val manglerDesc = KonanManglerDesc