From 4f1155b06f895795c2dc9f7de92fe8fb5e5b6c36 Mon Sep 17 00:00:00 2001 From: Dmitriy Dolovov Date: Wed, 22 Mar 2023 13:59:33 +0100 Subject: [PATCH] [PL] ABI compatibility tests for reworked partial linkage --- .../testData/klibABI/__utils__/__utils__.kt | 161 ++++++++--- .../testData/klibABI/addEnumEntry/lib1/l1.kt | 3 + .../klibABI/addEnumEntry/lib1/l1.kt.1 | 3 + .../lib1/module.info | 0 .../testData/klibABI/addEnumEntry/lib2/l2.kt | 4 + .../lib2/module.info | 0 .../testData/klibABI/addEnumEntry/main/m.kt | 7 + .../main/module.info | 2 +- .../project.info | 7 +- .../klibABI/addSealedSubclass/lib1/l1.kt | 45 +++ .../klibABI/addSealedSubclass/lib1/l1.kt.1 | 45 +++ .../lib1/module.info | 0 .../klibABI/addSealedSubclass/lib2/l2.kt | 40 +++ .../lib2/module.info | 0 .../klibABI/addSealedSubclass/main/m.kt | 39 +++ .../main/module.info | 2 +- .../project.info | 7 +- .../klibABI/changeClassVisibility/lib1/l1.kt | 26 ++ .../changeClassVisibility/lib1/l1.kt.1 | 32 +++ .../lib1/module.info | 0 .../klibABI/changeClassVisibility/lib2/l2.kt | 85 ++++++ .../lib2/module.info | 0 .../klibABI/changeClassVisibility/main/m.kt | 117 ++++++++ .../main/module.info | 0 .../project.info | 0 .../changeFunctionVisibility/lib1/l1.kt | 7 + .../changeFunctionVisibility/lib1/l1.kt.1 | 7 + .../changeFunctionVisibility/lib2/l2.kt | 9 + .../changeFunctionVisibility/main/m.kt | 86 ++++-- .../changeFunctionVisibility/project.info | 1 - .../changePropertyVisibility/lib1/l1.kt | 22 ++ .../changePropertyVisibility/lib1/l1.kt.1 | 22 ++ .../changePropertyVisibility/lib2/l2.kt | 32 +++ .../changePropertyVisibility/main/m.kt | 203 ++++++++----- .../changePropertyVisibility/project.info | 1 - .../klibABI/classTransformations/lib1/l1.kt | 143 +++++++++ .../klibABI/classTransformations/lib1/l1.kt.1 | 143 +++++++++ .../lib1/module.info | 0 .../klibABI/classTransformations/lib2/l2.kt | 222 ++++++++++++++ .../lib2/module.info | 0 .../klibABI/classTransformations/main/m.kt | 210 ++++++++++++++ .../main/module.info | 0 .../project.info | 0 .../functionTransformations/lib1/l1.kt | 99 +++++++ .../functionTransformations/lib1/l1.kt.1 | 99 +++++++ .../lib1/module.info | 0 .../functionTransformations/lib2/l2.kt | 163 +++++++++++ .../lib2/module.info | 0 .../klibABI/functionTransformations/main/m.kt | 122 ++++++++ .../main/module.info | 0 .../project.info | 0 .../klibABI/inheritanceIssues/lib1/l1.kt | 64 +++++ .../klibABI/inheritanceIssues/lib1/l1.kt.1 | 64 +++++ .../lib1/module.info | 0 .../klibABI/inheritanceIssues/lib2/l2.kt | 253 ++++++++++++++++ .../lib2/module.info | 0 .../klibABI/inheritanceIssues/main/m.kt | 234 +++++++++++++++ .../main/module.info | 0 .../project.info | 0 .../lib1/l1.kt.0 | 26 ++ .../lib1/l1.kt.1 | 26 ++ .../lib1/module.info | 0 .../lib2/l2.kt | 68 +++++ .../lib2/module.info | 0 .../main/m.kt | 43 +++ .../main/module.info | 0 .../project.info | 0 .../lib1/l1.kt.0 | 7 - .../lib1/l1.kt.1 | 7 - .../lib2/l2.kt | 21 -- .../main/m.kt | 16 -- .../lib1/l1.kt.0 | 6 - .../lib1/l1.kt.1 | 6 - .../lib2/l2.kt | 15 - .../main/m.kt | 13 - .../lib1/l1.kt.0 | 10 - .../lib1/l1.kt.1 | 10 - .../lib1/module.info | 12 - .../lib2/l2.kt | 38 --- .../main/m.kt | 23 -- .../main/module.info | 2 - .../lib1/l1.kt.0 | 6 - .../lib1/l1.kt.1 | 6 - .../lib1/module.info | 12 - .../lib2/l2.kt | 15 - .../main/m.kt | 13 - .../main/module.info | 2 - .../nonExhaustivenessOfWhenClause/lib1/l1.kt | 27 ++ .../lib1/l1.kt.1 | 29 ++ .../lib1/module.info | 0 .../nonExhaustivenessOfWhenClause/lib2/l2.kt | 29 ++ .../lib2/module.info | 0 .../nonExhaustivenessOfWhenClause/main/m.kt | 30 ++ .../main/module.info | 2 +- .../project.info | 7 +- .../propertyTransformations/lib1/l1.kt | 34 +++ .../propertyTransformations/lib1/l1.kt.1 | 34 +++ .../lib1/module.info | 0 .../propertyTransformations/lib2/l2.kt | 45 +++ .../lib2/module.info | 0 .../klibABI/propertyTransformations/main/m.kt | 34 +++ .../main/module.info | 0 .../project.info | 0 .../lib1/l1.kt | 21 ++ .../lib1/l1.kt.1 | 23 ++ .../lib1/module.info | 0 .../lib2/l2.kt | 74 +++++ .../lib2/module.info | 0 .../referencingUnusableDeclarations/main/m.kt | 49 ++++ .../main/module.info | 0 .../project.info | 0 .../lib1/l1.kt.0 | 11 + .../lib1/l1.kt.1 | 4 + .../lib1/module.info | 0 .../lib2/l2.kt | 13 + .../lib2/l2.kt.1 | 6 + .../lib2/module.info | 0 .../main/m.kt | 13 + .../main/module.info | 0 .../project.info | 0 .../lib1/l1.kt.0 | 5 - .../lib1/l1.kt.1 | 3 - .../lib1/module.info | 12 - .../lib2/l2.kt | 7 - .../lib2/l2.kt.1 | 5 - .../main/m.kt | 8 - .../main/module.info | 2 - .../lib1/l1.kt.0 | 5 - .../lib1/l1.kt.1 | 3 - .../lib1/module.info | 12 - .../lib2/l2.kt | 7 - .../lib2/l2.kt.1 | 5 - .../lib2/module.info | 6 - .../main/m.kt | 8 - .../main/module.info | 2 - .../lib1/l1.kt.0 | 5 - .../lib1/l1.kt.1 | 3 - .../lib1/module.info | 12 - .../lib2/l2.kt | 7 - .../lib2/l2.kt.1 | 5 - .../lib2/module.info | 6 - .../main/m.kt | 8 - .../main/module.info | 2 - .../lib1/l1.kt.0 | 5 - .../lib1/l1.kt.1 | 3 - .../lib1/module.info | 12 - .../lib2/l2.kt | 7 - .../lib2/l2.kt.1 | 5 - .../lib2/module.info | 6 - .../main/m.kt | 8 - .../main/module.info | 2 - .../klibABI/removeCallable/lib1/l1.kt | 23 ++ .../klibABI/removeCallable/lib1/l1.kt.1 | 23 ++ .../lib1/module.info | 0 .../klibABI/removeCallable/lib2/l2.kt | 19 ++ .../lib2/module.info | 0 .../testData/klibABI/removeCallable/main/m.kt | 21 ++ .../main/module.info | 0 .../project.info | 0 .../testData/klibABI/removeClass/lib1/l1.kt | 15 + .../testData/klibABI/removeClass/lib1/l1.kt.1 | 15 + .../lib1/module.info | 0 .../testData/klibABI/removeClass/lib2/l2.kt | 271 ++++++++++++++++++ .../lib2/module.info | 0 .../testData/klibABI/removeClass/main/m.kt | 70 +++++ .../main/module.info | 0 .../project.info | 0 .../removeClassAsConstructorCall/lib1/l1.kt | 1 - .../removeClassAsConstructorCall/lib1/l1.kt.1 | 1 - .../removeClassAsConstructorCall/lib2/l2.kt | 3 - .../removeClassAsConstructorCall/main/m.kt | 5 - .../removeClassAsParameterType/lib1/l1.kt | 2 - .../removeClassAsParameterType/lib1/l1.kt.1 | 1 - .../removeClassAsParameterType/lib2/l2.kt | 7 - .../removeClassAsParameterType/main/m.kt | 7 - .../removeClassAsReturnType/lib1/l1.kt | 9 - .../removeClassAsReturnType/lib1/l1.kt.1 | 4 - .../removeClassAsReturnType/lib2/l2.kt | 63 ---- .../klibABI/removeClassAsReturnType/main/m.kt | 15 - .../removeClassAsSuperTypeArgument/lib1/l1.kt | 7 - .../lib1/l1.kt.1 | 3 - .../removeClassAsSuperTypeArgument/lib2/l2.kt | 19 -- .../removeClassAsSuperTypeArgument/main/m.kt | 7 - .../removeClassAsTypeArgument/lib1/l1.kt | 7 - .../removeClassAsTypeArgument/lib1/l1.kt.1 | 3 - .../removeClassAsTypeArgument/lib2/l2.kt | 15 - .../removeClassAsTypeArgument/main/m.kt | 7 - .../removeClassAsVariableType/lib1/l1.kt | 1 - .../removeClassAsVariableType/lib1/l1.kt.1 | 1 - .../removeClassAsVariableType/lib2/l2.kt | 41 --- .../removeClassAsVariableType/main/m.kt | 9 - .../klibABI/removeEnumEntry/lib1/l1.kt | 3 + .../klibABI/removeEnumEntry/lib1/l1.kt.1 | 3 + .../lib1/module.info | 0 .../klibABI/removeEnumEntry/lib2/l2.kt | 5 + .../lib2/module.info | 0 .../klibABI/removeEnumEntry/main/m.kt | 7 + .../main/module.info | 0 .../project.info | 0 .../klibABI/removeFunction/lib1/l1.kt | 7 - .../klibABI/removeFunction/lib1/l1.kt.1 | 5 - .../klibABI/removeFunction/lib2/l2.kt | 2 - .../testData/klibABI/removeFunction/main/m.kt | 8 - .../klibABI/removeInlinedClass/lib1/l1.kt | 1 - .../klibABI/removeInlinedClass/lib1/l1.kt.1 | 1 - .../klibABI/removeInlinedClass/lib2/l2.kt | 32 --- .../klibABI/removeInlinedClass/main/m.kt | 11 - .../klibABI/removeInlinedFunction/lib1/l1.kt | 1 - .../removeInlinedFunction/lib1/l1.kt.1 | 1 - .../klibABI/removeInlinedFunction/lib2/l2.kt | 1 - .../klibABI/removeInlinedFunction/main/m.kt | 5 - .../removeInlinedFunction/project.info | 7 - .../klibABI/removeInlinedProperty/lib1/l1.kt | 1 - .../removeInlinedProperty/lib1/l1.kt.1 | 1 - .../klibABI/removeInlinedProperty/lib2/l2.kt | 1 - .../klibABI/removeInlinedProperty/main/m.kt | 5 - .../removeInlinedProperty/project.info | 7 - .../klibABI/removeOpenFunction/lib1/l1.kt | 7 - .../klibABI/removeOpenFunction/lib1/l1.kt.1 | 2 - .../klibABI/removeOpenFunction/lib2/l2.kt | 7 - .../klibABI/removeOpenFunction/main/m.kt | 5 - .../klibABI/removeOpenFunction/project.info | 7 - .../klibABI/removeOpenProperty/lib1/l1.kt | 7 - .../klibABI/removeOpenProperty/lib1/l1.kt.1 | 2 - .../klibABI/removeOpenProperty/lib2/l2.kt | 7 - .../removeOpenProperty/lib2/module.info | 2 - .../klibABI/removeOpenProperty/main/m.kt | 5 - .../klibABI/removeOpenProperty/project.info | 7 - .../klibABI/removeProperty/lib1/l1.kt | 12 - .../klibABI/removeProperty/lib1/l1.kt.1 | 9 - .../klibABI/removeProperty/lib2/l2.kt | 3 - .../klibABI/removeProperty/lib2/module.info | 2 - .../testData/klibABI/removeProperty/main/m.kt | 10 - .../klibABI/removeProperty/project.info | 7 - .../klibABI/removeSealedSubclass/lib1/l1.kt | 45 +++ .../klibABI/removeSealedSubclass/lib1/l1.kt.1 | 45 +++ .../lib1/module.info | 0 .../klibABI/removeSealedSubclass/lib2/l2.kt | 45 +++ .../lib2/module.info | 0 .../klibABI/removeSealedSubclass/main/m.kt | 39 +++ .../main/module.info | 0 .../project.info | 0 .../klibABI/typeAliasChanges/lib1/l1.kt | 9 + .../klibABI/typeAliasChanges/lib1/l1.kt.1 | 9 + .../lib1/module.info | 0 .../klibABI/typeAliasChanges/lib2/l2.kt | 50 ++++ .../lib2/module.info | 0 .../klibABI/typeAliasChanges/main/m.kt | 36 +++ .../main/module.info | 0 .../project.info | 0 .../klibABI/typeAliasRHSTypeChange/lib1/l1.kt | 3 - .../typeAliasRHSTypeChange/lib1/l1.kt.1 | 3 - .../klibABI/typeAliasRHSTypeChange/lib2/l2.kt | 8 - .../typeAliasRHSTypeChange/lib2/module.info | 2 - .../klibABI/typeAliasRHSTypeChange/main/m.kt | 6 - .../typeAliasRHSTypeChange/project.info | 7 - .../jetbrains/kotlin/klib/KlibABITestUtils.kt | 21 +- .../js/test/ir/AbstractJsKLibABITestCase.kt | 15 +- .../ir/JsKLibABINoICTestCaseGenerated.java | 150 ++++------ .../ir/JsKLibABIWithICTestCaseGenerated.java | 150 ++++------ .../blackboxtest/KlibABITestGenerated.java | 168 +++++------ .../blackboxtest/AbstractNativeKlibABITest.kt | 10 + 262 files changed, 4278 insertions(+), 1359 deletions(-) create mode 100644 compiler/testData/klibABI/addEnumEntry/lib1/l1.kt create mode 100644 compiler/testData/klibABI/addEnumEntry/lib1/l1.kt.1 rename compiler/testData/klibABI/{removeClassAsConstructorCall => addEnumEntry}/lib1/module.info (100%) create mode 100644 compiler/testData/klibABI/addEnumEntry/lib2/l2.kt rename compiler/testData/klibABI/{nonAbstractFunctionInAbstractClassBecomesAbstract => addEnumEntry}/lib2/module.info (100%) create mode 100644 compiler/testData/klibABI/addEnumEntry/main/m.kt rename compiler/testData/klibABI/{removeProperty => addEnumEntry}/main/module.info (81%) rename compiler/testData/klibABI/{removeAbstractFunctionFromInterface => addEnumEntry}/project.info (56%) create mode 100644 compiler/testData/klibABI/addSealedSubclass/lib1/l1.kt create mode 100644 compiler/testData/klibABI/addSealedSubclass/lib1/l1.kt.1 rename compiler/testData/klibABI/{removeClassAsParameterType => addSealedSubclass}/lib1/module.info (100%) create mode 100644 compiler/testData/klibABI/addSealedSubclass/lib2/l2.kt rename compiler/testData/klibABI/{nonAbstractFunctionInInterfaceBecomesAbstract => addSealedSubclass}/lib2/module.info (100%) create mode 100644 compiler/testData/klibABI/addSealedSubclass/main/m.kt rename compiler/testData/klibABI/{typeAliasRHSTypeChange => addSealedSubclass}/main/module.info (81%) rename compiler/testData/klibABI/{removeAbstractPropertyFromInterface => addSealedSubclass}/project.info (56%) create mode 100644 compiler/testData/klibABI/changeClassVisibility/lib1/l1.kt create mode 100644 compiler/testData/klibABI/changeClassVisibility/lib1/l1.kt.1 rename compiler/testData/klibABI/{removeClassAsReturnType => changeClassVisibility}/lib1/module.info (100%) create mode 100644 compiler/testData/klibABI/changeClassVisibility/lib2/l2.kt rename compiler/testData/klibABI/{nonAbstractPropertyInAbstractClassBecomesAbstract => changeClassVisibility}/lib2/module.info (100%) create mode 100644 compiler/testData/klibABI/changeClassVisibility/main/m.kt rename compiler/testData/klibABI/{removeClassAsConstructorCall => changeClassVisibility}/main/module.info (100%) rename compiler/testData/klibABI/{nonAbstractFunctionInAbstractClassBecomesAbstract => changeClassVisibility}/project.info (100%) create mode 100644 compiler/testData/klibABI/classTransformations/lib1/l1.kt create mode 100644 compiler/testData/klibABI/classTransformations/lib1/l1.kt.1 rename compiler/testData/klibABI/{removeClassAsSuperTypeArgument => classTransformations}/lib1/module.info (100%) create mode 100644 compiler/testData/klibABI/classTransformations/lib2/l2.kt rename compiler/testData/klibABI/{nonAbstractPropertyInInterfaceBecomesAbstract => classTransformations}/lib2/module.info (100%) create mode 100644 compiler/testData/klibABI/classTransformations/main/m.kt rename compiler/testData/klibABI/{removeClassAsParameterType => classTransformations}/main/module.info (100%) rename compiler/testData/klibABI/{nonAbstractFunctionInInterfaceBecomesAbstract => classTransformations}/project.info (100%) create mode 100644 compiler/testData/klibABI/functionTransformations/lib1/l1.kt create mode 100644 compiler/testData/klibABI/functionTransformations/lib1/l1.kt.1 rename compiler/testData/klibABI/{removeClassAsTypeArgument => functionTransformations}/lib1/module.info (100%) create mode 100644 compiler/testData/klibABI/functionTransformations/lib2/l2.kt rename compiler/testData/klibABI/{removeClassAsConstructorCall => functionTransformations}/lib2/module.info (100%) create mode 100644 compiler/testData/klibABI/functionTransformations/main/m.kt rename compiler/testData/klibABI/{removeClassAsReturnType => functionTransformations}/main/module.info (100%) rename compiler/testData/klibABI/{nonAbstractPropertyInAbstractClassBecomesAbstract => functionTransformations}/project.info (100%) create mode 100644 compiler/testData/klibABI/inheritanceIssues/lib1/l1.kt create mode 100644 compiler/testData/klibABI/inheritanceIssues/lib1/l1.kt.1 rename compiler/testData/klibABI/{removeClassAsVariableType => inheritanceIssues}/lib1/module.info (100%) create mode 100644 compiler/testData/klibABI/inheritanceIssues/lib2/l2.kt rename compiler/testData/klibABI/{removeClassAsParameterType => inheritanceIssues}/lib2/module.info (100%) create mode 100644 compiler/testData/klibABI/inheritanceIssues/main/m.kt rename compiler/testData/klibABI/{removeClassAsSuperTypeArgument => inheritanceIssues}/main/module.info (100%) rename compiler/testData/klibABI/{nonAbstractPropertyInInterfaceBecomesAbstract => inheritanceIssues}/project.info (100%) create mode 100644 compiler/testData/klibABI/nonAbstractCallableBecomesAbstract/lib1/l1.kt.0 create mode 100644 compiler/testData/klibABI/nonAbstractCallableBecomesAbstract/lib1/l1.kt.1 rename compiler/testData/klibABI/{nonAbstractFunctionInAbstractClassBecomesAbstract => nonAbstractCallableBecomesAbstract}/lib1/module.info (100%) create mode 100644 compiler/testData/klibABI/nonAbstractCallableBecomesAbstract/lib2/l2.kt rename compiler/testData/klibABI/{removeClassAsReturnType => nonAbstractCallableBecomesAbstract}/lib2/module.info (100%) create mode 100644 compiler/testData/klibABI/nonAbstractCallableBecomesAbstract/main/m.kt rename compiler/testData/klibABI/{nonAbstractFunctionInAbstractClassBecomesAbstract => nonAbstractCallableBecomesAbstract}/main/module.info (100%) rename compiler/testData/klibABI/{removeClassAsConstructorCall => nonAbstractCallableBecomesAbstract}/project.info (100%) delete mode 100644 compiler/testData/klibABI/nonAbstractFunctionInAbstractClassBecomesAbstract/lib1/l1.kt.0 delete mode 100644 compiler/testData/klibABI/nonAbstractFunctionInAbstractClassBecomesAbstract/lib1/l1.kt.1 delete mode 100644 compiler/testData/klibABI/nonAbstractFunctionInAbstractClassBecomesAbstract/lib2/l2.kt delete mode 100644 compiler/testData/klibABI/nonAbstractFunctionInAbstractClassBecomesAbstract/main/m.kt delete mode 100644 compiler/testData/klibABI/nonAbstractFunctionInInterfaceBecomesAbstract/lib1/l1.kt.0 delete mode 100644 compiler/testData/klibABI/nonAbstractFunctionInInterfaceBecomesAbstract/lib1/l1.kt.1 delete mode 100644 compiler/testData/klibABI/nonAbstractFunctionInInterfaceBecomesAbstract/lib2/l2.kt delete mode 100644 compiler/testData/klibABI/nonAbstractFunctionInInterfaceBecomesAbstract/main/m.kt delete mode 100644 compiler/testData/klibABI/nonAbstractPropertyInAbstractClassBecomesAbstract/lib1/l1.kt.0 delete mode 100644 compiler/testData/klibABI/nonAbstractPropertyInAbstractClassBecomesAbstract/lib1/l1.kt.1 delete mode 100644 compiler/testData/klibABI/nonAbstractPropertyInAbstractClassBecomesAbstract/lib1/module.info delete mode 100644 compiler/testData/klibABI/nonAbstractPropertyInAbstractClassBecomesAbstract/lib2/l2.kt delete mode 100644 compiler/testData/klibABI/nonAbstractPropertyInAbstractClassBecomesAbstract/main/m.kt delete mode 100644 compiler/testData/klibABI/nonAbstractPropertyInAbstractClassBecomesAbstract/main/module.info delete mode 100644 compiler/testData/klibABI/nonAbstractPropertyInInterfaceBecomesAbstract/lib1/l1.kt.0 delete mode 100644 compiler/testData/klibABI/nonAbstractPropertyInInterfaceBecomesAbstract/lib1/l1.kt.1 delete mode 100644 compiler/testData/klibABI/nonAbstractPropertyInInterfaceBecomesAbstract/lib1/module.info delete mode 100644 compiler/testData/klibABI/nonAbstractPropertyInInterfaceBecomesAbstract/lib2/l2.kt delete mode 100644 compiler/testData/klibABI/nonAbstractPropertyInInterfaceBecomesAbstract/main/m.kt delete mode 100644 compiler/testData/klibABI/nonAbstractPropertyInInterfaceBecomesAbstract/main/module.info create mode 100644 compiler/testData/klibABI/nonExhaustivenessOfWhenClause/lib1/l1.kt create mode 100644 compiler/testData/klibABI/nonExhaustivenessOfWhenClause/lib1/l1.kt.1 rename compiler/testData/klibABI/{removeFunction => nonExhaustivenessOfWhenClause}/lib1/module.info (100%) create mode 100644 compiler/testData/klibABI/nonExhaustivenessOfWhenClause/lib2/l2.kt rename compiler/testData/klibABI/{removeClassAsSuperTypeArgument => nonExhaustivenessOfWhenClause}/lib2/module.info (100%) create mode 100644 compiler/testData/klibABI/nonExhaustivenessOfWhenClause/main/m.kt rename compiler/testData/klibABI/{removeOpenProperty => nonExhaustivenessOfWhenClause}/main/module.info (81%) rename compiler/testData/klibABI/{removeAbstractPropertyFromAbstractClass => nonExhaustivenessOfWhenClause}/project.info (56%) create mode 100644 compiler/testData/klibABI/propertyTransformations/lib1/l1.kt create mode 100644 compiler/testData/klibABI/propertyTransformations/lib1/l1.kt.1 rename compiler/testData/klibABI/{removeInlinedClass => propertyTransformations}/lib1/module.info (100%) create mode 100644 compiler/testData/klibABI/propertyTransformations/lib2/l2.kt rename compiler/testData/klibABI/{removeClassAsTypeArgument => propertyTransformations}/lib2/module.info (100%) create mode 100644 compiler/testData/klibABI/propertyTransformations/main/m.kt rename compiler/testData/klibABI/{removeClassAsTypeArgument => propertyTransformations}/main/module.info (100%) rename compiler/testData/klibABI/{removeClassAsParameterType => propertyTransformations}/project.info (100%) create mode 100644 compiler/testData/klibABI/referencingUnusableDeclarations/lib1/l1.kt create mode 100644 compiler/testData/klibABI/referencingUnusableDeclarations/lib1/l1.kt.1 rename compiler/testData/klibABI/{removeInlinedFunction => referencingUnusableDeclarations}/lib1/module.info (100%) create mode 100644 compiler/testData/klibABI/referencingUnusableDeclarations/lib2/l2.kt rename compiler/testData/klibABI/{removeClassAsVariableType => referencingUnusableDeclarations}/lib2/module.info (100%) create mode 100644 compiler/testData/klibABI/referencingUnusableDeclarations/main/m.kt rename compiler/testData/klibABI/{removeClassAsVariableType => referencingUnusableDeclarations}/main/module.info (100%) rename compiler/testData/klibABI/{removeClassAsReturnType => referencingUnusableDeclarations}/project.info (100%) create mode 100644 compiler/testData/klibABI/removeAbstractCallableFromAbstractClassOrInterface/lib1/l1.kt.0 create mode 100644 compiler/testData/klibABI/removeAbstractCallableFromAbstractClassOrInterface/lib1/l1.kt.1 rename compiler/testData/klibABI/{nonAbstractFunctionInInterfaceBecomesAbstract => removeAbstractCallableFromAbstractClassOrInterface}/lib1/module.info (100%) create mode 100644 compiler/testData/klibABI/removeAbstractCallableFromAbstractClassOrInterface/lib2/l2.kt create mode 100644 compiler/testData/klibABI/removeAbstractCallableFromAbstractClassOrInterface/lib2/l2.kt.1 rename compiler/testData/klibABI/{removeAbstractFunctionFromAbstractClass => removeAbstractCallableFromAbstractClassOrInterface}/lib2/module.info (100%) create mode 100644 compiler/testData/klibABI/removeAbstractCallableFromAbstractClassOrInterface/main/m.kt rename compiler/testData/klibABI/{nonAbstractFunctionInInterfaceBecomesAbstract => removeAbstractCallableFromAbstractClassOrInterface}/main/module.info (100%) rename compiler/testData/klibABI/{removeAbstractFunctionFromAbstractClass => removeAbstractCallableFromAbstractClassOrInterface}/project.info (100%) delete mode 100644 compiler/testData/klibABI/removeAbstractFunctionFromAbstractClass/lib1/l1.kt.0 delete mode 100644 compiler/testData/klibABI/removeAbstractFunctionFromAbstractClass/lib1/l1.kt.1 delete mode 100644 compiler/testData/klibABI/removeAbstractFunctionFromAbstractClass/lib1/module.info delete mode 100644 compiler/testData/klibABI/removeAbstractFunctionFromAbstractClass/lib2/l2.kt delete mode 100644 compiler/testData/klibABI/removeAbstractFunctionFromAbstractClass/lib2/l2.kt.1 delete mode 100644 compiler/testData/klibABI/removeAbstractFunctionFromAbstractClass/main/m.kt delete mode 100644 compiler/testData/klibABI/removeAbstractFunctionFromAbstractClass/main/module.info delete mode 100644 compiler/testData/klibABI/removeAbstractFunctionFromInterface/lib1/l1.kt.0 delete mode 100644 compiler/testData/klibABI/removeAbstractFunctionFromInterface/lib1/l1.kt.1 delete mode 100644 compiler/testData/klibABI/removeAbstractFunctionFromInterface/lib1/module.info delete mode 100644 compiler/testData/klibABI/removeAbstractFunctionFromInterface/lib2/l2.kt delete mode 100644 compiler/testData/klibABI/removeAbstractFunctionFromInterface/lib2/l2.kt.1 delete mode 100644 compiler/testData/klibABI/removeAbstractFunctionFromInterface/lib2/module.info delete mode 100644 compiler/testData/klibABI/removeAbstractFunctionFromInterface/main/m.kt delete mode 100644 compiler/testData/klibABI/removeAbstractFunctionFromInterface/main/module.info delete mode 100644 compiler/testData/klibABI/removeAbstractPropertyFromAbstractClass/lib1/l1.kt.0 delete mode 100644 compiler/testData/klibABI/removeAbstractPropertyFromAbstractClass/lib1/l1.kt.1 delete mode 100644 compiler/testData/klibABI/removeAbstractPropertyFromAbstractClass/lib1/module.info delete mode 100644 compiler/testData/klibABI/removeAbstractPropertyFromAbstractClass/lib2/l2.kt delete mode 100644 compiler/testData/klibABI/removeAbstractPropertyFromAbstractClass/lib2/l2.kt.1 delete mode 100644 compiler/testData/klibABI/removeAbstractPropertyFromAbstractClass/lib2/module.info delete mode 100644 compiler/testData/klibABI/removeAbstractPropertyFromAbstractClass/main/m.kt delete mode 100644 compiler/testData/klibABI/removeAbstractPropertyFromAbstractClass/main/module.info delete mode 100644 compiler/testData/klibABI/removeAbstractPropertyFromInterface/lib1/l1.kt.0 delete mode 100644 compiler/testData/klibABI/removeAbstractPropertyFromInterface/lib1/l1.kt.1 delete mode 100644 compiler/testData/klibABI/removeAbstractPropertyFromInterface/lib1/module.info delete mode 100644 compiler/testData/klibABI/removeAbstractPropertyFromInterface/lib2/l2.kt delete mode 100644 compiler/testData/klibABI/removeAbstractPropertyFromInterface/lib2/l2.kt.1 delete mode 100644 compiler/testData/klibABI/removeAbstractPropertyFromInterface/lib2/module.info delete mode 100644 compiler/testData/klibABI/removeAbstractPropertyFromInterface/main/m.kt delete mode 100644 compiler/testData/klibABI/removeAbstractPropertyFromInterface/main/module.info create mode 100644 compiler/testData/klibABI/removeCallable/lib1/l1.kt create mode 100644 compiler/testData/klibABI/removeCallable/lib1/l1.kt.1 rename compiler/testData/klibABI/{removeInlinedProperty => removeCallable}/lib1/module.info (100%) create mode 100644 compiler/testData/klibABI/removeCallable/lib2/l2.kt rename compiler/testData/klibABI/{removeFunction => removeCallable}/lib2/module.info (100%) create mode 100644 compiler/testData/klibABI/removeCallable/main/m.kt rename compiler/testData/klibABI/{removeFunction => removeCallable}/main/module.info (100%) rename compiler/testData/klibABI/{removeClassAsSuperTypeArgument => removeCallable}/project.info (100%) create mode 100644 compiler/testData/klibABI/removeClass/lib1/l1.kt create mode 100644 compiler/testData/klibABI/removeClass/lib1/l1.kt.1 rename compiler/testData/klibABI/{removeOpenFunction => removeClass}/lib1/module.info (100%) create mode 100644 compiler/testData/klibABI/removeClass/lib2/l2.kt rename compiler/testData/klibABI/{removeInlinedClass => removeClass}/lib2/module.info (100%) create mode 100644 compiler/testData/klibABI/removeClass/main/m.kt rename compiler/testData/klibABI/{removeInlinedClass => removeClass}/main/module.info (100%) rename compiler/testData/klibABI/{removeClassAsTypeArgument => removeClass}/project.info (100%) delete mode 100644 compiler/testData/klibABI/removeClassAsConstructorCall/lib1/l1.kt delete mode 100644 compiler/testData/klibABI/removeClassAsConstructorCall/lib1/l1.kt.1 delete mode 100644 compiler/testData/klibABI/removeClassAsConstructorCall/lib2/l2.kt delete mode 100644 compiler/testData/klibABI/removeClassAsConstructorCall/main/m.kt delete mode 100644 compiler/testData/klibABI/removeClassAsParameterType/lib1/l1.kt delete mode 100644 compiler/testData/klibABI/removeClassAsParameterType/lib1/l1.kt.1 delete mode 100644 compiler/testData/klibABI/removeClassAsParameterType/lib2/l2.kt delete mode 100644 compiler/testData/klibABI/removeClassAsParameterType/main/m.kt delete mode 100644 compiler/testData/klibABI/removeClassAsReturnType/lib1/l1.kt delete mode 100644 compiler/testData/klibABI/removeClassAsReturnType/lib1/l1.kt.1 delete mode 100644 compiler/testData/klibABI/removeClassAsReturnType/lib2/l2.kt delete mode 100644 compiler/testData/klibABI/removeClassAsReturnType/main/m.kt delete mode 100644 compiler/testData/klibABI/removeClassAsSuperTypeArgument/lib1/l1.kt delete mode 100644 compiler/testData/klibABI/removeClassAsSuperTypeArgument/lib1/l1.kt.1 delete mode 100644 compiler/testData/klibABI/removeClassAsSuperTypeArgument/lib2/l2.kt delete mode 100644 compiler/testData/klibABI/removeClassAsSuperTypeArgument/main/m.kt delete mode 100644 compiler/testData/klibABI/removeClassAsTypeArgument/lib1/l1.kt delete mode 100644 compiler/testData/klibABI/removeClassAsTypeArgument/lib1/l1.kt.1 delete mode 100644 compiler/testData/klibABI/removeClassAsTypeArgument/lib2/l2.kt delete mode 100644 compiler/testData/klibABI/removeClassAsTypeArgument/main/m.kt delete mode 100644 compiler/testData/klibABI/removeClassAsVariableType/lib1/l1.kt delete mode 100644 compiler/testData/klibABI/removeClassAsVariableType/lib1/l1.kt.1 delete mode 100644 compiler/testData/klibABI/removeClassAsVariableType/lib2/l2.kt delete mode 100644 compiler/testData/klibABI/removeClassAsVariableType/main/m.kt create mode 100644 compiler/testData/klibABI/removeEnumEntry/lib1/l1.kt create mode 100644 compiler/testData/klibABI/removeEnumEntry/lib1/l1.kt.1 rename compiler/testData/klibABI/{removeOpenProperty => removeEnumEntry}/lib1/module.info (100%) create mode 100644 compiler/testData/klibABI/removeEnumEntry/lib2/l2.kt rename compiler/testData/klibABI/{removeInlinedFunction => removeEnumEntry}/lib2/module.info (100%) create mode 100644 compiler/testData/klibABI/removeEnumEntry/main/m.kt rename compiler/testData/klibABI/{removeInlinedFunction => removeEnumEntry}/main/module.info (100%) rename compiler/testData/klibABI/{removeClassAsVariableType => removeEnumEntry}/project.info (100%) delete mode 100644 compiler/testData/klibABI/removeFunction/lib1/l1.kt delete mode 100644 compiler/testData/klibABI/removeFunction/lib1/l1.kt.1 delete mode 100644 compiler/testData/klibABI/removeFunction/lib2/l2.kt delete mode 100644 compiler/testData/klibABI/removeFunction/main/m.kt delete mode 100644 compiler/testData/klibABI/removeInlinedClass/lib1/l1.kt delete mode 100644 compiler/testData/klibABI/removeInlinedClass/lib1/l1.kt.1 delete mode 100644 compiler/testData/klibABI/removeInlinedClass/lib2/l2.kt delete mode 100644 compiler/testData/klibABI/removeInlinedClass/main/m.kt delete mode 100644 compiler/testData/klibABI/removeInlinedFunction/lib1/l1.kt delete mode 100644 compiler/testData/klibABI/removeInlinedFunction/lib1/l1.kt.1 delete mode 100644 compiler/testData/klibABI/removeInlinedFunction/lib2/l2.kt delete mode 100644 compiler/testData/klibABI/removeInlinedFunction/main/m.kt delete mode 100644 compiler/testData/klibABI/removeInlinedFunction/project.info delete mode 100644 compiler/testData/klibABI/removeInlinedProperty/lib1/l1.kt delete mode 100644 compiler/testData/klibABI/removeInlinedProperty/lib1/l1.kt.1 delete mode 100644 compiler/testData/klibABI/removeInlinedProperty/lib2/l2.kt delete mode 100644 compiler/testData/klibABI/removeInlinedProperty/main/m.kt delete mode 100644 compiler/testData/klibABI/removeInlinedProperty/project.info delete mode 100644 compiler/testData/klibABI/removeOpenFunction/lib1/l1.kt delete mode 100644 compiler/testData/klibABI/removeOpenFunction/lib1/l1.kt.1 delete mode 100644 compiler/testData/klibABI/removeOpenFunction/lib2/l2.kt delete mode 100644 compiler/testData/klibABI/removeOpenFunction/main/m.kt delete mode 100644 compiler/testData/klibABI/removeOpenFunction/project.info delete mode 100644 compiler/testData/klibABI/removeOpenProperty/lib1/l1.kt delete mode 100644 compiler/testData/klibABI/removeOpenProperty/lib1/l1.kt.1 delete mode 100644 compiler/testData/klibABI/removeOpenProperty/lib2/l2.kt delete mode 100644 compiler/testData/klibABI/removeOpenProperty/lib2/module.info delete mode 100644 compiler/testData/klibABI/removeOpenProperty/main/m.kt delete mode 100644 compiler/testData/klibABI/removeOpenProperty/project.info delete mode 100644 compiler/testData/klibABI/removeProperty/lib1/l1.kt delete mode 100644 compiler/testData/klibABI/removeProperty/lib1/l1.kt.1 delete mode 100644 compiler/testData/klibABI/removeProperty/lib2/l2.kt delete mode 100644 compiler/testData/klibABI/removeProperty/lib2/module.info delete mode 100644 compiler/testData/klibABI/removeProperty/main/m.kt delete mode 100644 compiler/testData/klibABI/removeProperty/project.info create mode 100644 compiler/testData/klibABI/removeSealedSubclass/lib1/l1.kt create mode 100644 compiler/testData/klibABI/removeSealedSubclass/lib1/l1.kt.1 rename compiler/testData/klibABI/{removeProperty => removeSealedSubclass}/lib1/module.info (100%) create mode 100644 compiler/testData/klibABI/removeSealedSubclass/lib2/l2.kt rename compiler/testData/klibABI/{removeInlinedProperty => removeSealedSubclass}/lib2/module.info (100%) create mode 100644 compiler/testData/klibABI/removeSealedSubclass/main/m.kt rename compiler/testData/klibABI/{removeInlinedProperty => removeSealedSubclass}/main/module.info (100%) rename compiler/testData/klibABI/{removeFunction => removeSealedSubclass}/project.info (100%) create mode 100644 compiler/testData/klibABI/typeAliasChanges/lib1/l1.kt create mode 100644 compiler/testData/klibABI/typeAliasChanges/lib1/l1.kt.1 rename compiler/testData/klibABI/{typeAliasRHSTypeChange => typeAliasChanges}/lib1/module.info (100%) create mode 100644 compiler/testData/klibABI/typeAliasChanges/lib2/l2.kt rename compiler/testData/klibABI/{removeOpenFunction => typeAliasChanges}/lib2/module.info (100%) create mode 100644 compiler/testData/klibABI/typeAliasChanges/main/m.kt rename compiler/testData/klibABI/{removeOpenFunction => typeAliasChanges}/main/module.info (100%) rename compiler/testData/klibABI/{removeInlinedClass => typeAliasChanges}/project.info (100%) delete mode 100644 compiler/testData/klibABI/typeAliasRHSTypeChange/lib1/l1.kt delete mode 100644 compiler/testData/klibABI/typeAliasRHSTypeChange/lib1/l1.kt.1 delete mode 100644 compiler/testData/klibABI/typeAliasRHSTypeChange/lib2/l2.kt delete mode 100644 compiler/testData/klibABI/typeAliasRHSTypeChange/lib2/module.info delete mode 100644 compiler/testData/klibABI/typeAliasRHSTypeChange/main/m.kt delete mode 100644 compiler/testData/klibABI/typeAliasRHSTypeChange/project.info diff --git a/compiler/testData/klibABI/__utils__/__utils__.kt b/compiler/testData/klibABI/__utils__/__utils__.kt index d5eff25477f..6c391a5d0ef 100644 --- a/compiler/testData/klibABI/__utils__/__utils__.kt +++ b/compiler/testData/klibABI/__utils__/__utils__.kt @@ -2,25 +2,40 @@ package abitestutils -import abitestutils.ThrowableKind.* +import abitestutils.TestMode.* -/** API **/ +/** Public API **/ interface TestBuilder { - fun prefixed(prefix: String): ErrorMessagePattern - fun nonImplementedCallable(callableTypeAndName: String, classifierTypeAndName: String): ErrorMessagePattern + val testMode: TestMode - fun expectFailure(errorMessagePattern: ErrorMessagePattern, block: Block) + /** N.B. It is expected that [messageWithoutHashes] contains IR linkage error message without hashes in ID signatures. */ + fun linkage(messageWithoutHashes: String): FailurePattern + fun nonImplementedCallable(callableTypeAndName: String, classifierTypeAndName: String): FailurePattern + fun noWhenBranch(): FailurePattern + fun custom(checker: (Throwable) -> Boolean): FailurePattern + + fun expectFailure(failurePattern: FailurePattern, block: Block) fun expectSuccess(block: Block) // OK is expected fun expectSuccess(expectedOutcome: T, block: Block) } -const val OK_STATUS = "OK" - -sealed interface ErrorMessagePattern +sealed interface FailurePattern private typealias Block = () -> T +enum class TestMode(val isJs: Boolean = false, val isNative: Boolean = false) { + JS_NO_IC(isJs = true), + JS_WITH_IC(isJs = true), + NATIVE_CACHE_NO(isNative = true), + NATIVE_CACHE_STATIC_ONLY_DIST(isNative = true), + NATIVE_CACHE_STATIC_EVERYWHERE(isNative = true); + + init { + check(isJs xor isNative) + } +} + fun abiTest(init: TestBuilder.() -> Unit): String { val builder = TestBuilderImpl() builder.init() @@ -30,16 +45,23 @@ fun abiTest(init: TestBuilder.() -> Unit): String { /** Implementation **/ +private const val OK_STATUS = "OK" + private class TestBuilderImpl : TestBuilder { + override val testMode = TestMode.__UNKNOWN__ + private val tests = mutableListOf() - override fun prefixed(prefix: String) = PrefixOfErrorMessage(prefix) + override fun linkage(messageWithoutHashes: String) = GeneralIrLinkageError(messageWithoutHashes) override fun nonImplementedCallable(callableTypeAndName: String, classifierTypeAndName: String) = - NonImplementedCallable(callableTypeAndName, classifierTypeAndName) + NonImplementedCallableIrLinkageError(callableTypeAndName, classifierTypeAndName) - override fun expectFailure(errorMessagePattern: ErrorMessagePattern, block: Block) { - tests += FailingTest(errorMessagePattern, block) + override fun noWhenBranch() = NoWhenBranchFailure + override fun custom(checker: (Throwable) -> Boolean) = CustomThrowableFailure(checker) + + override fun expectFailure(failurePattern: FailurePattern, block: Block) { + tests += FailingTest(failurePattern as AbstractFailurePattern, block) } override fun expectSuccess(block: Block) = expectSuccess(OK_STATUS, block) @@ -57,14 +79,10 @@ private class TestBuilderImpl : TestBuilder { val testFailureDetails: TestFailureDetails? = when (test) { is FailingTest -> { try { - test.block() - TestSuccessfulButMustFail + val result = test.block() + TestSuccessfulButMustFail(result) } catch (t: Throwable) { - when (t.throwableKind) { - IR_LINKAGE_ERROR -> test.checkIrLinkageErrorMessage(t) - EXCEPTION -> TestFailedWithException(t) - NON_EXCEPTION -> throw t // Something totally unexpected. Rethrow. - } + test.failurePattern.validateFailure(t) } } @@ -76,40 +94,52 @@ private class TestBuilderImpl : TestBuilder { else TestMismatchedExpectation(test.expectedOutcome, result) } catch (t: Throwable) { - if (t.throwableKind == NON_EXCEPTION) - throw t // Something totally unexpected. Rethrow. - else - TestFailedWithException(t) + TestFailedWithException(t) } } } - if (testFailureDetails != null) TestFailure(serialNumber, testFailureDetails) else null + if (testFailureDetails != null) TestFailure(serialNumber, test.sourceLocation, testFailureDetails) else null } return if (testFailures.isEmpty()) OK_STATUS else testFailures.joinToString(prefix = "\n", separator = "\n", postfix = "\n") } } -private sealed interface AbstractErrorMessagePattern : ErrorMessagePattern { - fun checkIrLinkageErrorMessage(errorMessage: String?): TestFailureDetails? +private sealed interface AbstractFailurePattern : FailurePattern { + fun validateFailure(t: Throwable): TestFailureDetails? } -private class PrefixOfErrorMessage(prefix: String) : AbstractErrorMessagePattern { +private sealed class AbstractIrLinkageErrorPattern : AbstractFailurePattern { + final override fun validateFailure(t: Throwable) = + if (t.isLinkageError) + checkIrLinkageErrorMessage(t.message) // OK, this is IR linkage error. Validate the message. + else + TestFailedWithException(t) // Unexpected type of exception. + + abstract fun checkIrLinkageErrorMessage(errorMessage: String?): TestFailureDetails? +} + +private class GeneralIrLinkageError(private val expectedMessageWithoutHashes: String) : AbstractIrLinkageErrorPattern() { init { - check(prefix.isNotBlank()) { "Prefix is blank: [$prefix]" } + check(expectedMessageWithoutHashes.isNotBlank()) { "Message is blank: [$expectedMessageWithoutHashes]" } } - private val fullPrefix = "$prefix because it uses unlinked symbols" - override fun checkIrLinkageErrorMessage(errorMessage: String?) = - if (errorMessage?.startsWith(fullPrefix) == true) + if (errorMessage?.replace(SIGNATURE_WITH_HASH) { it.groupValues[1] + "'" } == expectedMessageWithoutHashes) null // Success. else - TestMismatchedExpectation(fullPrefix, errorMessage) + TestMismatchedExpectation(expectedMessageWithoutHashes, errorMessage) + + companion object { + val SIGNATURE_WITH_HASH = Regex("(symbol '/[\\da-zA-Z.<>_\\-]+)(\\|\\S+)'") + } } -private class NonImplementedCallable(callableTypeAndName: String, classifierTypeAndName: String) : AbstractErrorMessagePattern { +private class NonImplementedCallableIrLinkageError( + callableTypeAndName: String, + classifierTypeAndName: String +) : AbstractIrLinkageErrorPattern() { init { check(callableTypeAndName.isNotBlank() && ' ' in callableTypeAndName) { "Invalid callable type & name: [$callableTypeAndName]" } check(classifierTypeAndName.isNotBlank() && ' ' in classifierTypeAndName) { "Invalid classifier type & name: [$classifierTypeAndName]" } @@ -124,28 +154,65 @@ private class NonImplementedCallable(callableTypeAndName: String, classifierType TestMismatchedExpectation(fullMessage, errorMessage) } -private sealed interface Test -private class FailingTest(val errorMessagePattern: ErrorMessagePattern, val block: Block) : Test -private class SuccessfulTest(val expectedOutcome: Any, val block: Block) : Test +private class CustomThrowableFailure(private val checker: (Throwable) -> Boolean) : AbstractFailurePattern { + override fun validateFailure(t: Throwable) = + if (checker(t)) + null // Expected failure. + else + TestFailedWithException(t) // Unexpected type of exception. +} -private class TestFailure(val serialNumber: Int, val details: TestFailureDetails) { - override fun toString() = "#$serialNumber: ${details.description}" +@Suppress("PrivatePropertyName") +private val NoWhenBranchFailure = CustomThrowableFailure { it is NoWhenBranchMatchedException } + +private sealed class Test { + val sourceLocation: String? = computeSourceLocation() +} + +private class FailingTest(val failurePattern: AbstractFailurePattern, val block: Block) : Test() +private class SuccessfulTest(val expectedOutcome: Any, val block: Block) : Test() + +private class TestFailure(val serialNumber: Int, val sourceLocation: String?, val details: TestFailureDetails) { + override fun toString() = buildString { + append('#').append(serialNumber) + if (sourceLocation != null) append(" (").append(sourceLocation).append(")") + append(": ").append(details.description) + } } private sealed class TestFailureDetails(val description: String) -private object TestSuccessfulButMustFail : TestFailureDetails("Test is successful but was expected to fail.") +private class TestSuccessfulButMustFail(actualOutcome: Any?) : TestFailureDetails("Test was expected to fail, but passed successfully: $actualOutcome") private class TestFailedWithException(t: Throwable) : TestFailureDetails("Test unexpectedly failed with exception: $t") private class TestMismatchedExpectation(expectedOutcome: Any, actualOutcome: Any?) : TestFailureDetails("EXPECTED: $expectedOutcome, ACTUAL: $actualOutcome") -private enum class ThrowableKind { IR_LINKAGE_ERROR, EXCEPTION, NON_EXCEPTION } +private val Throwable.isLinkageError: Boolean + get() = this::class.simpleName == "IrLinkageError" -private val Throwable.throwableKind: ThrowableKind - get() = when { - this::class.simpleName == "IrLinkageError" -> IR_LINKAGE_ERROR - this is Exception -> EXCEPTION - else -> NON_EXCEPTION +fun computeSourceLocation(): String? { + fun extractSourceLocation(stackTraceLine: String): String? { + return stackTraceLine.substringAfterLast('(', missingDelimiterValue = "") + .substringBefore(')', missingDelimiterValue = "") + .takeIf { it.isNotEmpty() } + ?.split(':', limit = 2) + ?.takeIf { it.size == 2 && it[0].isNotEmpty() && it[1].isNotEmpty() } + ?.let { "${it[0].substringAfterLast('/').substringAfterLast('\\')}:${it[1]}" } } -private fun FailingTest.checkIrLinkageErrorMessage(t: Throwable) = - (errorMessagePattern as AbstractErrorMessagePattern).checkIrLinkageErrorMessage(t.message) + var beenInTestBuilderImpl = false + + // Capture the stack trace to find out the line number where the test was exactly configured. + return Throwable().stackTraceToString() + .lineSequence() + .dropWhile { stackTraceLine -> + val isInTestBuilderImpl = TestBuilderImpl::class.simpleName!! in stackTraceLine + if (isInTestBuilderImpl) { + beenInTestBuilderImpl = true + true + } else { + !beenInTestBuilderImpl + } + } + .mapNotNull(::extractSourceLocation) + .firstOrNull() +} diff --git a/compiler/testData/klibABI/addEnumEntry/lib1/l1.kt b/compiler/testData/klibABI/addEnumEntry/lib1/l1.kt new file mode 100644 index 00000000000..d58d8b73d16 --- /dev/null +++ b/compiler/testData/klibABI/addEnumEntry/lib1/l1.kt @@ -0,0 +1,3 @@ +enum class E { + UNCHANGED1, /*ADDED,*/ UNCHANGED2 +} diff --git a/compiler/testData/klibABI/addEnumEntry/lib1/l1.kt.1 b/compiler/testData/klibABI/addEnumEntry/lib1/l1.kt.1 new file mode 100644 index 00000000000..7b79ed0a880 --- /dev/null +++ b/compiler/testData/klibABI/addEnumEntry/lib1/l1.kt.1 @@ -0,0 +1,3 @@ +enum class E { + UNCHANGED1, ADDED, UNCHANGED2 +} diff --git a/compiler/testData/klibABI/removeClassAsConstructorCall/lib1/module.info b/compiler/testData/klibABI/addEnumEntry/lib1/module.info similarity index 100% rename from compiler/testData/klibABI/removeClassAsConstructorCall/lib1/module.info rename to compiler/testData/klibABI/addEnumEntry/lib1/module.info diff --git a/compiler/testData/klibABI/addEnumEntry/lib2/l2.kt b/compiler/testData/klibABI/addEnumEntry/lib2/l2.kt new file mode 100644 index 00000000000..197c1eefe6b --- /dev/null +++ b/compiler/testData/klibABI/addEnumEntry/lib2/l2.kt @@ -0,0 +1,4 @@ +fun compute(e: E): String = when (e) { + E.UNCHANGED1 -> "OK" + E.UNCHANGED2 -> "OK" +} diff --git a/compiler/testData/klibABI/nonAbstractFunctionInAbstractClassBecomesAbstract/lib2/module.info b/compiler/testData/klibABI/addEnumEntry/lib2/module.info similarity index 100% rename from compiler/testData/klibABI/nonAbstractFunctionInAbstractClassBecomesAbstract/lib2/module.info rename to compiler/testData/klibABI/addEnumEntry/lib2/module.info diff --git a/compiler/testData/klibABI/addEnumEntry/main/m.kt b/compiler/testData/klibABI/addEnumEntry/main/m.kt new file mode 100644 index 00000000000..cca9ce70310 --- /dev/null +++ b/compiler/testData/klibABI/addEnumEntry/main/m.kt @@ -0,0 +1,7 @@ +import abitestutils.abiTest + +fun box() = abiTest { + expectSuccess { compute(E.UNCHANGED2) } + expectFailure(noWhenBranch()) { compute(E.ADDED) } + expectSuccess { compute(E.UNCHANGED1) } +} diff --git a/compiler/testData/klibABI/removeProperty/main/module.info b/compiler/testData/klibABI/addEnumEntry/main/module.info similarity index 81% rename from compiler/testData/klibABI/removeProperty/main/module.info rename to compiler/testData/klibABI/addEnumEntry/main/module.info index 62f7f4fab07..de4760c9c67 100644 --- a/compiler/testData/klibABI/removeProperty/main/module.info +++ b/compiler/testData/klibABI/addEnumEntry/main/module.info @@ -1,2 +1,2 @@ -STEP 0: +STEP 1: dependencies: stdlib, lib1, lib2 \ No newline at end of file diff --git a/compiler/testData/klibABI/removeAbstractFunctionFromInterface/project.info b/compiler/testData/klibABI/addEnumEntry/project.info similarity index 56% rename from compiler/testData/klibABI/removeAbstractFunctionFromInterface/project.info rename to compiler/testData/klibABI/addEnumEntry/project.info index 01ef0b966c5..f006dfc6fe8 100644 --- a/compiler/testData/klibABI/removeAbstractFunctionFromInterface/project.info +++ b/compiler/testData/klibABI/addEnumEntry/project.info @@ -1,10 +1,7 @@ MODULES: lib1, lib2, main STEP 0: - libs: lib1, lib2, main - -STEP 1: libs: lib1, lib2 -STEP 2: - libs: lib1 +STEP 1: + libs: lib1, main \ No newline at end of file diff --git a/compiler/testData/klibABI/addSealedSubclass/lib1/l1.kt b/compiler/testData/klibABI/addSealedSubclass/lib1/l1.kt new file mode 100644 index 00000000000..7ac676794b1 --- /dev/null +++ b/compiler/testData/klibABI/addSealedSubclass/lib1/l1.kt @@ -0,0 +1,45 @@ +sealed class SC1 { + class C1 : SC1() + object O1 : SC1() +// class Added : SC1() + class C2 : SC1() + object O2 : SC1() +} + +sealed class SC2 { + class C1 : SC2() + object O1 : SC2() +// object Added : SC2() + class C2 : SC2() + object O2 : SC2() +} + +sealed interface SI1 { + class C1 : SI1 + object O1 : SI1 + interface I1 : SI1 +// class Added : SI1 + class C2 : SI1 + object O2 : SI1 + interface I2 : SI1 +} + +sealed interface SI2 { + class C1 : SI2 + object O1 : SI2 + interface I1 : SI2 +// object Added : SI2 + class C2 : SI2 + object O2 : SI2 + interface I2 : SI2 +} + +sealed interface SI3 { + class C1 : SI3 + object O1 : SI3 + interface I1 : SI3 +// interface Added : SI3 + class C2 : SI3 + object O2 : SI3 + interface I2 : SI3 +} diff --git a/compiler/testData/klibABI/addSealedSubclass/lib1/l1.kt.1 b/compiler/testData/klibABI/addSealedSubclass/lib1/l1.kt.1 new file mode 100644 index 00000000000..09c13a431d0 --- /dev/null +++ b/compiler/testData/klibABI/addSealedSubclass/lib1/l1.kt.1 @@ -0,0 +1,45 @@ +sealed class SC1 { + class C1 : SC1() + object O1 : SC1() + class Added : SC1() + class C2 : SC1() + object O2 : SC1() +} + +sealed class SC2 { + class C1 : SC2() + object O1 : SC2() + object Added : SC2() + class C2 : SC2() + object O2 : SC2() +} + +sealed interface SI1 { + class C1 : SI1 + object O1 : SI1 + interface I1 : SI1 + class Added : SI1 + class C2 : SI1 + object O2 : SI1 + interface I2 : SI1 +} + +sealed interface SI2 { + class C1 : SI2 + object O1 : SI2 + interface I1 : SI2 + object Added : SI2 + class C2 : SI2 + object O2 : SI2 + interface I2 : SI2 +} + +sealed interface SI3 { + class C1 : SI3 + object O1 : SI3 + interface I1 : SI3 + interface Added : SI3 + class C2 : SI3 + object O2 : SI3 + interface I2 : SI3 +} diff --git a/compiler/testData/klibABI/removeClassAsParameterType/lib1/module.info b/compiler/testData/klibABI/addSealedSubclass/lib1/module.info similarity index 100% rename from compiler/testData/klibABI/removeClassAsParameterType/lib1/module.info rename to compiler/testData/klibABI/addSealedSubclass/lib1/module.info diff --git a/compiler/testData/klibABI/addSealedSubclass/lib2/l2.kt b/compiler/testData/klibABI/addSealedSubclass/lib2/l2.kt new file mode 100644 index 00000000000..2dfc7ab3e8f --- /dev/null +++ b/compiler/testData/klibABI/addSealedSubclass/lib2/l2.kt @@ -0,0 +1,40 @@ +fun compute(sealedClass: SC1): String = when (sealedClass) { + is SC1.C1 -> "OK" + SC1.O1 -> "OK" + is SC1.C2 -> "OK" + SC1.O2 -> "OK" +} + +fun compute(sealedClass: SC2): String = when (sealedClass) { + is SC2.C1 -> "OK" + SC2.O1 -> "OK" + is SC2.C2 -> "OK" + SC2.O2 -> "OK" +} + +fun compute(sealedInterface: SI1): String = when (sealedInterface) { + is SI1.C1 -> "OK" + SI1.O1 -> "OK" + is SI1.I1 -> "OK" + is SI1.C2 -> "OK" + SI1.O2 -> "OK" + is SI1.I2 -> "OK" +} + +fun compute(sealedInterface: SI2): String = when (sealedInterface) { + is SI2.C1 -> "OK" + SI2.O1 -> "OK" + is SI2.I1 -> "OK" + is SI2.C2 -> "OK" + SI2.O2 -> "OK" + is SI2.I2 -> "OK" +} + +fun compute(sealedInterface: SI3): String = when (sealedInterface) { + is SI3.C1 -> "OK" + SI3.O1 -> "OK" + is SI3.I1 -> "OK" + is SI3.C2 -> "OK" + SI3.O2 -> "OK" + is SI3.I2 -> "OK" +} diff --git a/compiler/testData/klibABI/nonAbstractFunctionInInterfaceBecomesAbstract/lib2/module.info b/compiler/testData/klibABI/addSealedSubclass/lib2/module.info similarity index 100% rename from compiler/testData/klibABI/nonAbstractFunctionInInterfaceBecomesAbstract/lib2/module.info rename to compiler/testData/klibABI/addSealedSubclass/lib2/module.info diff --git a/compiler/testData/klibABI/addSealedSubclass/main/m.kt b/compiler/testData/klibABI/addSealedSubclass/main/m.kt new file mode 100644 index 00000000000..ee1f5b71c78 --- /dev/null +++ b/compiler/testData/klibABI/addSealedSubclass/main/m.kt @@ -0,0 +1,39 @@ +import abitestutils.abiTest + +fun box() = abiTest { + expectSuccess { compute(SC1.C1()) } + expectSuccess { compute(SC1.O1) } + expectFailure(noWhenBranch()) { compute(SC1.Added()) } + expectSuccess { compute(SC1.C2()) } + expectSuccess { compute(SC1.O2) } + + expectSuccess { compute(SC2.C1()) } + expectSuccess { compute(SC2.O1) } + expectFailure(noWhenBranch()) { compute(SC2.Added) } + expectSuccess { compute(SC2.C2()) } + expectSuccess { compute(SC2.O2) } + + expectSuccess { compute(SI1.C1()) } + expectSuccess { compute(SI1.O1) } + expectSuccess { compute(object : SI1.I1 {}) } + expectFailure(noWhenBranch()) { compute(SI1.Added()) } + expectSuccess { compute(SI1.C2()) } + expectSuccess { compute(SI1.O2) } + expectSuccess { compute(object : SI1.I2 {}) } + + expectSuccess { compute(SI2.C1()) } + expectSuccess { compute(SI2.O1) } + expectSuccess { compute(object : SI2.I1 {}) } + expectFailure(noWhenBranch()) { compute(SI2.Added) } + expectSuccess { compute(SI2.C2()) } + expectSuccess { compute(SI2.O2) } + expectSuccess { compute(object : SI2.I2 {}) } + + expectSuccess { compute(SI3.C1()) } + expectSuccess { compute(SI3.O1) } + expectSuccess { compute(object : SI3.I1 {}) } + expectFailure(noWhenBranch()) { compute(object : SI3.Added {}) } + expectSuccess { compute(SI3.C2()) } + expectSuccess { compute(SI3.O2) } + expectSuccess { compute(object : SI3.I2 {}) } +} diff --git a/compiler/testData/klibABI/typeAliasRHSTypeChange/main/module.info b/compiler/testData/klibABI/addSealedSubclass/main/module.info similarity index 81% rename from compiler/testData/klibABI/typeAliasRHSTypeChange/main/module.info rename to compiler/testData/klibABI/addSealedSubclass/main/module.info index 62f7f4fab07..de4760c9c67 100644 --- a/compiler/testData/klibABI/typeAliasRHSTypeChange/main/module.info +++ b/compiler/testData/klibABI/addSealedSubclass/main/module.info @@ -1,2 +1,2 @@ -STEP 0: +STEP 1: dependencies: stdlib, lib1, lib2 \ No newline at end of file diff --git a/compiler/testData/klibABI/removeAbstractPropertyFromInterface/project.info b/compiler/testData/klibABI/addSealedSubclass/project.info similarity index 56% rename from compiler/testData/klibABI/removeAbstractPropertyFromInterface/project.info rename to compiler/testData/klibABI/addSealedSubclass/project.info index 01ef0b966c5..f006dfc6fe8 100644 --- a/compiler/testData/klibABI/removeAbstractPropertyFromInterface/project.info +++ b/compiler/testData/klibABI/addSealedSubclass/project.info @@ -1,10 +1,7 @@ MODULES: lib1, lib2, main STEP 0: - libs: lib1, lib2, main - -STEP 1: libs: lib1, lib2 -STEP 2: - libs: lib1 +STEP 1: + libs: lib1, main \ No newline at end of file diff --git a/compiler/testData/klibABI/changeClassVisibility/lib1/l1.kt b/compiler/testData/klibABI/changeClassVisibility/lib1/l1.kt new file mode 100644 index 00000000000..78b48b5a83b --- /dev/null +++ b/compiler/testData/klibABI/changeClassVisibility/lib1/l1.kt @@ -0,0 +1,26 @@ +public open class PublicTopLevelClass { + public class PublicToInternalNestedClass + public class PublicToProtectedNestedClass + public class PublicToPrivateNestedClass + public inner class PublicToInternalInnerClass + public inner class PublicToProtectedInnerClass + public inner class PublicToPrivateInnerClass +} + +public open class PublicToInternalTopLevelClass { + public class PublicToInternalNestedClass + public class PublicToProtectedNestedClass + public class PublicToPrivateNestedClass + public inner class PublicToInternalInnerClass + public inner class PublicToProtectedInnerClass + public inner class PublicToPrivateInnerClass +} + +public open class PublicToPrivateTopLevelClass { + public class PublicToInternalNestedClass + public class PublicToProtectedNestedClass + public class PublicToPrivateNestedClass + public inner class PublicToInternalInnerClass + public inner class PublicToProtectedInnerClass + public inner class PublicToPrivateInnerClass +} diff --git a/compiler/testData/klibABI/changeClassVisibility/lib1/l1.kt.1 b/compiler/testData/klibABI/changeClassVisibility/lib1/l1.kt.1 new file mode 100644 index 00000000000..6d7a61737c4 --- /dev/null +++ b/compiler/testData/klibABI/changeClassVisibility/lib1/l1.kt.1 @@ -0,0 +1,32 @@ +public open class PublicTopLevelClass { + override fun toString() = "PublicTopLevelClass" + + internal class PublicToInternalNestedClass { override fun toString() = "PublicTopLevelClass.PublicToInternalNestedClass" } + protected class PublicToProtectedNestedClass { override fun toString() = "PublicTopLevelClass.PublicToProtectedNestedClass" } + private class PublicToPrivateNestedClass { override fun toString() = "PublicTopLevelClass.PublicToPrivateNestedClass" } + internal inner class PublicToInternalInnerClass { override fun toString() = "PublicTopLevelClass.PublicToInternalInnerClass" } + protected inner class PublicToProtectedInnerClass { override fun toString() = "PublicTopLevelClass.PublicToProtectedInnerClass" } + private inner class PublicToPrivateInnerClass { override fun toString() = "PublicTopLevelClass.PublicToPrivateInnerClass" } +} + +internal open class PublicToInternalTopLevelClass { + override fun toString() = "PublicToInternalTopLevelClass" + + internal class PublicToInternalNestedClass { override fun toString() = "PublicToInternalTopLevelClass.PublicToInternalNestedClass" } + protected class PublicToProtectedNestedClass { override fun toString() = "PublicToInternalTopLevelClass.PublicToProtectedNestedClass" } + private class PublicToPrivateNestedClass { override fun toString() = "PublicToInternalTopLevelClass.PublicToPrivateNestedClass" } + internal inner class PublicToInternalInnerClass { override fun toString() = "PublicToInternalTopLevelClass.PublicToInternalInnerClass" } + protected inner class PublicToProtectedInnerClass { override fun toString() = "PublicToInternalTopLevelClass.PublicToProtectedInnerClass" } + private inner class PublicToPrivateInnerClass { override fun toString() = "PublicToInternalTopLevelClass.PublicToPrivateInnerClass" } +} + +private open class PublicToPrivateTopLevelClass { + override fun toString() = "PublicToPrivateTopLevelClass" + + internal class PublicToInternalNestedClass { override fun toString() = "PublicToPrivateTopLevelClass.PublicToInternalNestedClass" } + protected class PublicToProtectedNestedClass { override fun toString() = "PublicToPrivateTopLevelClass.PublicToProtectedNestedClass" } + private class PublicToPrivateNestedClass { override fun toString() = "PublicToPrivateTopLevelClass.PublicToPrivateNestedClass" } + internal inner class PublicToInternalInnerClass { override fun toString() = "PublicToPrivateTopLevelClass.PublicToInternalInnerClass" } + protected inner class PublicToProtectedInnerClass { override fun toString() = "PublicToPrivateTopLevelClass.PublicToProtectedInnerClass" } + private inner class PublicToPrivateInnerClass { override fun toString() = "PublicToPrivateTopLevelClass.PublicToPrivateInnerClass" } +} diff --git a/compiler/testData/klibABI/removeClassAsReturnType/lib1/module.info b/compiler/testData/klibABI/changeClassVisibility/lib1/module.info similarity index 100% rename from compiler/testData/klibABI/removeClassAsReturnType/lib1/module.info rename to compiler/testData/klibABI/changeClassVisibility/lib1/module.info diff --git a/compiler/testData/klibABI/changeClassVisibility/lib2/l2.kt b/compiler/testData/klibABI/changeClassVisibility/lib2/l2.kt new file mode 100644 index 00000000000..de0f4873ae8 --- /dev/null +++ b/compiler/testData/klibABI/changeClassVisibility/lib2/l2.kt @@ -0,0 +1,85 @@ +@file:Suppress("FunctionName", "UNUSED_PARAMETER") + +/** + * Note: + * + * `fun *_valueParameter()` accepts nullable type and always returns a string. + * + * `fun *_returnType()` has non-nullable return type but in fact always throws an instrance of [TestException]. This is to avoid induced + * errors caused by instantition of the returned declaration itself. + * + * `fun *_anyReturnType` has [kotlin.Any] return type and always returns just created instance of the declaration. + */ + +data class TestException(val id: String) : Exception() +private fun fail(id: String): Nothing = throw TestException(id) + +fun PublicTopLevelClass_valueParameter(value: PublicTopLevelClass?): String = "PublicTopLevelClass" +fun PublicTopLevelClass_returnType(): PublicTopLevelClass = fail("PublicTopLevelClass") +fun PublicTopLevelClass_anyReturnType(): Any = PublicTopLevelClass() +fun PublicTopLevelClass_PublicToInternalNestedClass_valueParameter(value: PublicTopLevelClass.PublicToInternalNestedClass?): String = "PublicTopLevelClass.PublicToInternalNestedClass" +fun PublicTopLevelClass_PublicToInternalNestedClass_returnType(): PublicTopLevelClass.PublicToInternalNestedClass = fail("PublicTopLevelClass.PublicToInternalNestedClass") +fun PublicTopLevelClass_PublicToInternalNestedClass_anyReturnType(): Any = PublicTopLevelClass.PublicToInternalNestedClass() +fun PublicTopLevelClass_PublicToProtectedNestedClass_valueParameter(value: PublicTopLevelClass.PublicToProtectedNestedClass?): String = "PublicTopLevelClass.PublicToProtectedNestedClass" +fun PublicTopLevelClass_PublicToProtectedNestedClass_returnType(): PublicTopLevelClass.PublicToProtectedNestedClass = fail("PublicTopLevelClass.PublicToProtectedNestedClass") +fun PublicTopLevelClass_PublicToProtectedNestedClass_anyReturnType(): Any = PublicTopLevelClass.PublicToProtectedNestedClass() +fun PublicTopLevelClass_PublicToPrivateNestedClass_valueParameter(value: PublicTopLevelClass.PublicToPrivateNestedClass?): String = "PublicTopLevelClass.PublicToPrivateNestedClass" +fun PublicTopLevelClass_PublicToPrivateNestedClass_returnType(): PublicTopLevelClass.PublicToPrivateNestedClass = fail("PublicTopLevelClass.PublicToPrivateNestedClass") +fun PublicTopLevelClass_PublicToPrivateNestedClass_anyReturnType(): Any = PublicTopLevelClass.PublicToPrivateNestedClass() +fun PublicTopLevelClass_PublicToInternalInnerClass_valueParameter(value: PublicTopLevelClass.PublicToInternalInnerClass?): String = "PublicTopLevelClass.PublicToInternalInnerClass" +fun PublicTopLevelClass_PublicToInternalInnerClass_returnType(): PublicTopLevelClass.PublicToInternalInnerClass = fail("PublicTopLevelClass.PublicToInternalInnerClass") +fun PublicTopLevelClass_PublicToInternalInnerClass_anyReturnType(): Any = PublicTopLevelClass().PublicToInternalInnerClass() +fun PublicTopLevelClass_PublicToProtectedInnerClass_valueParameter(value: PublicTopLevelClass.PublicToProtectedInnerClass?): String = "PublicTopLevelClass.PublicToProtectedInnerClass" +fun PublicTopLevelClass_PublicToProtectedInnerClass_returnType(): PublicTopLevelClass.PublicToProtectedInnerClass = fail("PublicTopLevelClass.PublicToProtectedInnerClass") +fun PublicTopLevelClass_PublicToProtectedInnerClass_anyReturnType(): Any = PublicTopLevelClass().PublicToProtectedInnerClass() +fun PublicTopLevelClass_PublicToPrivateInnerClass_valueParameter(value: PublicTopLevelClass.PublicToPrivateInnerClass?): String = "PublicTopLevelClass.PublicToPrivateInnerClass" +fun PublicTopLevelClass_PublicToPrivateInnerClass_returnType(): PublicTopLevelClass.PublicToPrivateInnerClass = fail("PublicTopLevelClass.PublicToPrivateInnerClass") +fun PublicTopLevelClass_PublicToPrivateInnerClass_anyReturnType(): Any = PublicTopLevelClass().PublicToPrivateInnerClass() + +fun PublicToInternalTopLevelClass_valueParameter(value: PublicToInternalTopLevelClass?): String = "PublicToInternalTopLevelClass" +fun PublicToInternalTopLevelClass_returnType(): PublicToInternalTopLevelClass = fail("PublicToInternalTopLevelClass") +fun PublicToInternalTopLevelClass_anyReturnType(): Any = PublicToInternalTopLevelClass() +fun PublicToInternalTopLevelClass_PublicToInternalNestedClass_valueParameter(value: PublicToInternalTopLevelClass.PublicToInternalNestedClass?): String = "PublicToInternalTopLevelClass.PublicToInternalNestedClass" +fun PublicToInternalTopLevelClass_PublicToInternalNestedClass_returnType(): PublicToInternalTopLevelClass.PublicToInternalNestedClass = fail("PublicToInternalTopLevelClass.PublicToInternalNestedClass") +fun PublicToInternalTopLevelClass_PublicToInternalNestedClass_anyReturnType(): Any = PublicToInternalTopLevelClass.PublicToInternalNestedClass() +fun PublicToInternalTopLevelClass_PublicToProtectedNestedClass_valueParameter(value: PublicToInternalTopLevelClass.PublicToProtectedNestedClass?): String = "PublicToInternalTopLevelClass.PublicToProtectedNestedClass" +fun PublicToInternalTopLevelClass_PublicToProtectedNestedClass_returnType(): PublicToInternalTopLevelClass.PublicToProtectedNestedClass = fail("PublicToInternalTopLevelClass.PublicToProtectedNestedClass") +fun PublicToInternalTopLevelClass_PublicToProtectedNestedClass_anyReturnType(): Any = PublicToInternalTopLevelClass.PublicToProtectedNestedClass() +fun PublicToInternalTopLevelClass_PublicToPrivateNestedClass_valueParameter(value: PublicToInternalTopLevelClass.PublicToPrivateNestedClass?): String = "PublicToInternalTopLevelClass.PublicToPrivateNestedClass" +fun PublicToInternalTopLevelClass_PublicToPrivateNestedClass_returnType(): PublicToInternalTopLevelClass.PublicToPrivateNestedClass = fail("PublicToInternalTopLevelClass.PublicToPrivateNestedClass") +fun PublicToInternalTopLevelClass_PublicToPrivateNestedClass_anyReturnType(): Any = PublicToInternalTopLevelClass.PublicToPrivateNestedClass() +fun PublicToInternalTopLevelClass_PublicToInternalInnerClass_valueParameter(value: PublicToInternalTopLevelClass.PublicToInternalInnerClass?): String = "PublicToInternalTopLevelClass.PublicToInternalInnerClass" +fun PublicToInternalTopLevelClass_PublicToInternalInnerClass_returnType(): PublicToInternalTopLevelClass.PublicToInternalInnerClass = fail("PublicToInternalTopLevelClass.PublicToInternalInnerClass") +fun PublicToInternalTopLevelClass_PublicToInternalInnerClass_anyReturnType(): Any = PublicToInternalTopLevelClass().PublicToInternalInnerClass() +fun PublicToInternalTopLevelClass_PublicToProtectedInnerClass_valueParameter(value: PublicToInternalTopLevelClass.PublicToProtectedInnerClass?): String = "PublicToInternalTopLevelClass.PublicToProtectedInnerClass" +fun PublicToInternalTopLevelClass_PublicToProtectedInnerClass_returnType(): PublicToInternalTopLevelClass.PublicToProtectedInnerClass = fail("PublicToInternalTopLevelClass.PublicToProtectedInnerClass") +fun PublicToInternalTopLevelClass_PublicToProtectedInnerClass_anyReturnType(): Any = PublicToInternalTopLevelClass().PublicToProtectedInnerClass() +fun PublicToInternalTopLevelClass_PublicToPrivateInnerClass_valueParameter(value: PublicToInternalTopLevelClass.PublicToPrivateInnerClass?): String = "PublicToInternalTopLevelClass.PublicToPrivateInnerClass" +fun PublicToInternalTopLevelClass_PublicToPrivateInnerClass_returnType(): PublicToInternalTopLevelClass.PublicToPrivateInnerClass = fail("PublicToInternalTopLevelClass.PublicToPrivateInnerClass") +fun PublicToInternalTopLevelClass_PublicToPrivateInnerClass_anyReturnType(): Any = PublicToInternalTopLevelClass().PublicToPrivateInnerClass() + +fun PublicToPrivateTopLevelClass_valueParameter(value: PublicToPrivateTopLevelClass?): String = "PublicToPrivateTopLevelClass" +fun PublicToPrivateTopLevelClass_returnType(): PublicToPrivateTopLevelClass = fail("PublicToPrivateTopLevelClass") +fun PublicToPrivateTopLevelClass_anyReturnType(): Any = PublicToPrivateTopLevelClass() +fun PublicToPrivateTopLevelClass_PublicToInternalNestedClass_valueParameter(value: PublicToPrivateTopLevelClass.PublicToInternalNestedClass?): String = "PublicToPrivateTopLevelClass.PublicToInternalNestedClass" +fun PublicToPrivateTopLevelClass_PublicToInternalNestedClass_returnType(): PublicToPrivateTopLevelClass.PublicToInternalNestedClass = fail("PublicToPrivateTopLevelClass.PublicToInternalNestedClass") +fun PublicToPrivateTopLevelClass_PublicToInternalNestedClass_anyReturnType(): Any = PublicToPrivateTopLevelClass.PublicToInternalNestedClass() +fun PublicToPrivateTopLevelClass_PublicToProtectedNestedClass_valueParameter(value: PublicToPrivateTopLevelClass.PublicToProtectedNestedClass?): String = "PublicToPrivateTopLevelClass.PublicToProtectedNestedClass" +fun PublicToPrivateTopLevelClass_PublicToProtectedNestedClass_returnType(): PublicToPrivateTopLevelClass.PublicToProtectedNestedClass = fail("PublicToPrivateTopLevelClass.PublicToProtectedNestedClass") +fun PublicToPrivateTopLevelClass_PublicToProtectedNestedClass_anyReturnType(): Any = PublicToPrivateTopLevelClass.PublicToProtectedNestedClass() +fun PublicToPrivateTopLevelClass_PublicToPrivateNestedClass_valueParameter(value: PublicToPrivateTopLevelClass.PublicToPrivateNestedClass?): String = "PublicToPrivateTopLevelClass.PublicToPrivateNestedClass" +fun PublicToPrivateTopLevelClass_PublicToPrivateNestedClass_returnType(): PublicToPrivateTopLevelClass.PublicToPrivateNestedClass = fail("PublicToPrivateTopLevelClass.PublicToPrivateNestedClass") +fun PublicToPrivateTopLevelClass_PublicToPrivateNestedClass_anyReturnType(): Any = PublicToPrivateTopLevelClass.PublicToPrivateNestedClass() +fun PublicToPrivateTopLevelClass_PublicToInternalInnerClass_valueParameter(value: PublicToPrivateTopLevelClass.PublicToInternalInnerClass?): String = "PublicToPrivateTopLevelClass.PublicToInternalInnerClass" +fun PublicToPrivateTopLevelClass_PublicToInternalInnerClass_returnType(): PublicToPrivateTopLevelClass.PublicToInternalInnerClass = fail("PublicToPrivateTopLevelClass.PublicToInternalInnerClass") +fun PublicToPrivateTopLevelClass_PublicToInternalInnerClass_anyReturnType(): Any = PublicToPrivateTopLevelClass().PublicToInternalInnerClass() +fun PublicToPrivateTopLevelClass_PublicToProtectedInnerClass_valueParameter(value: PublicToPrivateTopLevelClass.PublicToProtectedInnerClass?): String = "PublicToPrivateTopLevelClass.PublicToProtectedInnerClass" +fun PublicToPrivateTopLevelClass_PublicToProtectedInnerClass_returnType(): PublicToPrivateTopLevelClass.PublicToProtectedInnerClass = fail("PublicToPrivateTopLevelClass.PublicToProtectedInnerClass") +fun PublicToPrivateTopLevelClass_PublicToProtectedInnerClass_anyReturnType(): Any = PublicToPrivateTopLevelClass().PublicToProtectedInnerClass() +fun PublicToPrivateTopLevelClass_PublicToPrivateInnerClass_valueParameter(value: PublicToPrivateTopLevelClass.PublicToPrivateInnerClass?): String = "PublicToPrivateTopLevelClass.PublicToPrivateInnerClass" +fun PublicToPrivateTopLevelClass_PublicToPrivateInnerClass_returnType(): PublicToPrivateTopLevelClass.PublicToPrivateInnerClass = fail("PublicToPrivateTopLevelClass.PublicToPrivateInnerClass") +fun PublicToPrivateTopLevelClass_PublicToPrivateInnerClass_anyReturnType(): Any = PublicToPrivateTopLevelClass().PublicToPrivateInnerClass() + +class PublicTopLevelClassInheritor : PublicTopLevelClass() { override fun toString() = "PublicTopLevelClassInheritor" } +class PublicToInternalTopLevelClassInheritor : PublicToInternalTopLevelClass() { override fun toString() = "PublicToInternalTopLevelClassInheritor" } +class PublicToPrivateTopLevelClassInheritor : PublicToPrivateTopLevelClass() { override fun toString() = "PublicToPrivateTopLevelClassInheritor" } diff --git a/compiler/testData/klibABI/nonAbstractPropertyInAbstractClassBecomesAbstract/lib2/module.info b/compiler/testData/klibABI/changeClassVisibility/lib2/module.info similarity index 100% rename from compiler/testData/klibABI/nonAbstractPropertyInAbstractClassBecomesAbstract/lib2/module.info rename to compiler/testData/klibABI/changeClassVisibility/lib2/module.info diff --git a/compiler/testData/klibABI/changeClassVisibility/main/m.kt b/compiler/testData/klibABI/changeClassVisibility/main/m.kt new file mode 100644 index 00000000000..5631947ec00 --- /dev/null +++ b/compiler/testData/klibABI/changeClassVisibility/main/m.kt @@ -0,0 +1,117 @@ +import abitestutils.abiTest +import abitestutils.TestBuilder +import abitestutils.TestMode.NATIVE_CACHE_STATIC_EVERYWHERE + +fun box() = abiTest { + success("PublicTopLevelClass") { PublicTopLevelClass_valueParameter(null) } + successViaException("PublicTopLevelClass") { PublicTopLevelClass_returnType() } + success("PublicTopLevelClass") { PublicTopLevelClass_anyReturnType() } + success("PublicTopLevelClass.PublicToInternalNestedClass") { PublicTopLevelClass_PublicToInternalNestedClass_valueParameter(null) } + successViaException("PublicTopLevelClass.PublicToInternalNestedClass") { PublicTopLevelClass_PublicToInternalNestedClass_returnType() } + // TODO: KT-54469, creating instance of PublicTopLevelClass.PublicToInternalNestedClass in another module should fail. + success("PublicTopLevelClass.PublicToInternalNestedClass") { PublicTopLevelClass_PublicToInternalNestedClass_anyReturnType() } + success("PublicTopLevelClass.PublicToProtectedNestedClass") { PublicTopLevelClass_PublicToProtectedNestedClass_valueParameter(null) } + successViaException("PublicTopLevelClass.PublicToProtectedNestedClass") { PublicTopLevelClass_PublicToProtectedNestedClass_returnType() } + success("PublicTopLevelClass.PublicToProtectedNestedClass") { PublicTopLevelClass_PublicToProtectedNestedClass_anyReturnType() } + success("PublicTopLevelClass.PublicToPrivateNestedClass") { PublicTopLevelClass_PublicToPrivateNestedClass_valueParameter(null) } + successViaException("PublicTopLevelClass.PublicToPrivateNestedClass") { PublicTopLevelClass_PublicToPrivateNestedClass_returnType() } + inaccessible("PublicToPrivateNestedClass") { PublicTopLevelClass_PublicToPrivateNestedClass_anyReturnType() } + success("PublicTopLevelClass.PublicToInternalInnerClass") { PublicTopLevelClass_PublicToInternalInnerClass_valueParameter(null) } + successViaException("PublicTopLevelClass.PublicToInternalInnerClass") { PublicTopLevelClass_PublicToInternalInnerClass_returnType() } + // TODO: KT-54469, creating instance of PublicTopLevelClass.PublicToInternalInnerClass in another module should fail. + success("PublicTopLevelClass.PublicToInternalInnerClass") { PublicTopLevelClass_PublicToInternalInnerClass_anyReturnType() } + success("PublicTopLevelClass.PublicToProtectedInnerClass") { PublicTopLevelClass_PublicToProtectedInnerClass_valueParameter(null) } + successViaException("PublicTopLevelClass.PublicToProtectedInnerClass") { PublicTopLevelClass_PublicToProtectedInnerClass_returnType() } + success("PublicTopLevelClass.PublicToProtectedInnerClass") { PublicTopLevelClass_PublicToProtectedInnerClass_anyReturnType() } + success("PublicTopLevelClass.PublicToPrivateInnerClass") { PublicTopLevelClass_PublicToPrivateInnerClass_valueParameter(null) } + successViaException("PublicTopLevelClass.PublicToPrivateInnerClass") { PublicTopLevelClass_PublicToPrivateInnerClass_returnType() } + inaccessible("PublicToPrivateInnerClass") { PublicTopLevelClass_PublicToPrivateInnerClass_anyReturnType() } + + // TODO: KT-54469, accessing PublicToInternalTopLevelClass and all nested classes should fail. + success("PublicToInternalTopLevelClass") { PublicToInternalTopLevelClass_valueParameter(null) } + successViaException("PublicToInternalTopLevelClass") { PublicToInternalTopLevelClass_returnType() } + success("PublicToInternalTopLevelClass") { PublicToInternalTopLevelClass_anyReturnType() } + success("PublicToInternalTopLevelClass.PublicToInternalNestedClass") { PublicToInternalTopLevelClass_PublicToInternalNestedClass_valueParameter(null) } + successViaException("PublicToInternalTopLevelClass.PublicToInternalNestedClass") { PublicToInternalTopLevelClass_PublicToInternalNestedClass_returnType() } + success("PublicToInternalTopLevelClass.PublicToInternalNestedClass") { PublicToInternalTopLevelClass_PublicToInternalNestedClass_anyReturnType() } + success("PublicToInternalTopLevelClass.PublicToProtectedNestedClass") { PublicToInternalTopLevelClass_PublicToProtectedNestedClass_valueParameter(null) } + successViaException("PublicToInternalTopLevelClass.PublicToProtectedNestedClass") { PublicToInternalTopLevelClass_PublicToProtectedNestedClass_returnType() } + success("PublicToInternalTopLevelClass.PublicToProtectedNestedClass") { PublicToInternalTopLevelClass_PublicToProtectedNestedClass_anyReturnType() } + success("PublicToInternalTopLevelClass.PublicToPrivateNestedClass") { PublicToInternalTopLevelClass_PublicToPrivateNestedClass_valueParameter(null) } + successViaException("PublicToInternalTopLevelClass.PublicToPrivateNestedClass") { PublicToInternalTopLevelClass_PublicToPrivateNestedClass_returnType() } + inaccessible("PublicToPrivateNestedClass") { PublicToInternalTopLevelClass_PublicToPrivateNestedClass_anyReturnType() } + success("PublicToInternalTopLevelClass.PublicToInternalInnerClass") { PublicToInternalTopLevelClass_PublicToInternalInnerClass_valueParameter(null) } + successViaException("PublicToInternalTopLevelClass.PublicToInternalInnerClass") { PublicToInternalTopLevelClass_PublicToInternalInnerClass_returnType() } + success("PublicToInternalTopLevelClass.PublicToInternalInnerClass") { PublicToInternalTopLevelClass_PublicToInternalInnerClass_anyReturnType() } + success("PublicToInternalTopLevelClass.PublicToProtectedInnerClass") { PublicToInternalTopLevelClass_PublicToProtectedInnerClass_valueParameter(null) } + successViaException("PublicToInternalTopLevelClass.PublicToProtectedInnerClass") { PublicToInternalTopLevelClass_PublicToProtectedInnerClass_returnType() } + success("PublicToInternalTopLevelClass.PublicToProtectedInnerClass") { PublicToInternalTopLevelClass_PublicToProtectedInnerClass_anyReturnType() } + success("PublicToInternalTopLevelClass.PublicToPrivateInnerClass") { PublicToInternalTopLevelClass_PublicToPrivateInnerClass_valueParameter(null) } + successViaException("PublicToInternalTopLevelClass.PublicToPrivateInnerClass") { PublicToInternalTopLevelClass_PublicToPrivateInnerClass_returnType() } + inaccessible("PublicToPrivateInnerClass") { PublicToInternalTopLevelClass_PublicToPrivateInnerClass_anyReturnType() } + + unlinkedSymbolInValueParameter("/PublicToPrivateTopLevelClass") { PublicToPrivateTopLevelClass_valueParameter(null) } + unlinkedSymbolInReturnType("/PublicToPrivateTopLevelClass") { PublicToPrivateTopLevelClass_returnType() } + unlinkedConstructorSymbol("/PublicToPrivateTopLevelClass.") { PublicToPrivateTopLevelClass_anyReturnType() } + unlinkedSymbolInValueParameter("/PublicToPrivateTopLevelClass.PublicToInternalNestedClass") { PublicToPrivateTopLevelClass_PublicToInternalNestedClass_valueParameter(null) } + unlinkedSymbolInReturnType("/PublicToPrivateTopLevelClass.PublicToInternalNestedClass") { PublicToPrivateTopLevelClass_PublicToInternalNestedClass_returnType() } + unlinkedConstructorSymbol("/PublicToPrivateTopLevelClass.PublicToInternalNestedClass.") { PublicToPrivateTopLevelClass_PublicToInternalNestedClass_anyReturnType() } + unlinkedSymbolInValueParameter("/PublicToPrivateTopLevelClass.PublicToProtectedNestedClass") { PublicToPrivateTopLevelClass_PublicToProtectedNestedClass_valueParameter(null) } + unlinkedSymbolInReturnType("/PublicToPrivateTopLevelClass.PublicToProtectedNestedClass") { PublicToPrivateTopLevelClass_PublicToProtectedNestedClass_returnType() } + unlinkedConstructorSymbol("/PublicToPrivateTopLevelClass.PublicToProtectedNestedClass.") { PublicToPrivateTopLevelClass_PublicToProtectedNestedClass_anyReturnType() } + unlinkedSymbolInValueParameter("/PublicToPrivateTopLevelClass.PublicToPrivateNestedClass") { PublicToPrivateTopLevelClass_PublicToPrivateNestedClass_valueParameter(null) } + unlinkedSymbolInReturnType("/PublicToPrivateTopLevelClass.PublicToPrivateNestedClass") { PublicToPrivateTopLevelClass_PublicToPrivateNestedClass_returnType() } + unlinkedConstructorSymbol("/PublicToPrivateTopLevelClass.PublicToPrivateNestedClass.") { PublicToPrivateTopLevelClass_PublicToPrivateNestedClass_anyReturnType() } + unlinkedSymbolInValueParameter("/PublicToPrivateTopLevelClass.PublicToInternalInnerClass") { PublicToPrivateTopLevelClass_PublicToInternalInnerClass_valueParameter(null) } + unlinkedSymbolInReturnType("/PublicToPrivateTopLevelClass.PublicToInternalInnerClass") { PublicToPrivateTopLevelClass_PublicToInternalInnerClass_returnType() } + unlinkedConstructorSymbol("/PublicToPrivateTopLevelClass.") { PublicToPrivateTopLevelClass_PublicToInternalInnerClass_anyReturnType() } + unlinkedSymbolInValueParameter("/PublicToPrivateTopLevelClass.PublicToProtectedInnerClass") { PublicToPrivateTopLevelClass_PublicToProtectedInnerClass_valueParameter(null) } + unlinkedSymbolInReturnType("/PublicToPrivateTopLevelClass.PublicToProtectedInnerClass") { PublicToPrivateTopLevelClass_PublicToProtectedInnerClass_returnType() } + unlinkedConstructorSymbol("/PublicToPrivateTopLevelClass.") { PublicToPrivateTopLevelClass_PublicToProtectedInnerClass_anyReturnType() } + unlinkedSymbolInValueParameter("/PublicToPrivateTopLevelClass.PublicToPrivateInnerClass") { PublicToPrivateTopLevelClass_PublicToPrivateInnerClass_valueParameter(null) } + unlinkedSymbolInReturnType("/PublicToPrivateTopLevelClass.PublicToPrivateInnerClass") { PublicToPrivateTopLevelClass_PublicToPrivateInnerClass_returnType() } + unlinkedConstructorSymbol("/PublicToPrivateTopLevelClass.") { PublicToPrivateTopLevelClass_PublicToPrivateInnerClass_anyReturnType() } + + success("PublicTopLevelClassInheritor") { PublicTopLevelClassInheritor() } + // TODO: KT-54469, creating instance of PublicToInternalTopLevelClassInheritor should fail. + success("PublicToInternalTopLevelClassInheritor") { PublicToInternalTopLevelClassInheritor() } + expectFailure(linkage("Constructor 'PublicToPrivateTopLevelClassInheritor.' can not be called: Class 'PublicToPrivateTopLevelClassInheritor' uses unlinked class symbol '/PublicToPrivateTopLevelClass'")) { PublicToPrivateTopLevelClassInheritor() } +} + +// Shortcuts: +private inline fun TestBuilder.success(expectedOutcome: String, noinline block: () -> Any) = + expectSuccess(expectedOutcome) { block().toString() } + +private inline fun TestBuilder.successViaException(testExceptionId: String, noinline block: () -> Unit) = + expectFailure(custom { (it as? TestException)?.id == testExceptionId }, block) + +private inline fun TestBuilder.inaccessible(className: String, noinline block: () -> Unit) = expectFailure( + linkage("Constructor '$className.' can not be called: Private constructor declared in module can not be accessed in module "), + block +) + +private inline fun TestBuilder.unlinkedSymbolInValueParameter(signature: String, noinline block: () -> Unit) { + val functionName = signature.removePrefix("/").replace('.', '_') + "_valueParameter" + unlinkedSymbol(signature, functionName, block) +} + +private inline fun TestBuilder.unlinkedSymbolInReturnType(signature: String, noinline block: () -> Unit) { + val functionName = signature.removePrefix("/").replace('.', '_') + "_returnType" + unlinkedSymbol(signature, functionName, block) +} + +private inline fun TestBuilder.unlinkedConstructorSymbol(signature: String, noinline block: () -> Unit) { + val constructorName = signature.removePrefix("/").split('.').takeLast(2).joinToString(".") + expectFailure(linkage("Constructor '$constructorName' can not be called: No constructor found for symbol '$signature'"), block) +} + +private inline fun TestBuilder.unlinkedSymbol(signature: String, functionName: String, noinline block: () -> Unit) { + // Need to slightly adjust the expected IR linkage error message. Reason: When Lazy IR is used the type of the + // symbol is determined more accurately. + val symbolKind = if ("InnerClass" in functionName && testMode == NATIVE_CACHE_STATIC_EVERYWHERE) + "inner class" + else + "class" + + expectFailure(linkage("Function '$functionName' can not be called: Function uses unlinked $symbolKind symbol '$signature'"), block) +} diff --git a/compiler/testData/klibABI/removeClassAsConstructorCall/main/module.info b/compiler/testData/klibABI/changeClassVisibility/main/module.info similarity index 100% rename from compiler/testData/klibABI/removeClassAsConstructorCall/main/module.info rename to compiler/testData/klibABI/changeClassVisibility/main/module.info diff --git a/compiler/testData/klibABI/nonAbstractFunctionInAbstractClassBecomesAbstract/project.info b/compiler/testData/klibABI/changeClassVisibility/project.info similarity index 100% rename from compiler/testData/klibABI/nonAbstractFunctionInAbstractClassBecomesAbstract/project.info rename to compiler/testData/klibABI/changeClassVisibility/project.info diff --git a/compiler/testData/klibABI/changeFunctionVisibility/lib1/l1.kt b/compiler/testData/klibABI/changeFunctionVisibility/lib1/l1.kt index b0d40d0b7ff..146703ae43b 100644 --- a/compiler/testData/klibABI/changeFunctionVisibility/lib1/l1.kt +++ b/compiler/testData/klibABI/changeFunctionVisibility/lib1/l1.kt @@ -1,21 +1,26 @@ public fun publicToInternalTopLevelFunction() = "publicToInternalTopLevelFunction.v1" +public fun publicToInternalPATopLevelFunction() = "publicToInternalPATopLevelFunction.v1" public fun publicToPrivateTopLevelFunction() = "publicToPrivateTopLevelFunction.v1" open class Container { public fun publicToProtectedFunction() = "Container.publicToProtectedFunction.v1" public fun publicToInternalFunction() = "Container.publicToInternalFunction.v1" + public fun publicToInternalPAFunction() = "Container.publicToInternalPAFunction.v1" public fun publicToPrivateFunction() = "Container.publicToPrivateFunction.v1" protected fun protectedToPublicFunction() = "Container.protectedToPublicFunction.v1" protected fun protectedToInternalFunction() = "Container.protectedToInternalFunction.v1" + protected fun protectedToInternalPAFunction() = "Container.protectedToInternalPAFunction.v1" protected fun protectedToPrivateFunction() = "Container.protectedToPrivateFunction.v1" public open fun publicToProtectedOverriddenFunction() = "Container.publicToProtectedOverriddenFunction.v1" public open fun publicToInternalOverriddenFunction() = "Container.publicToInternalOverriddenFunction.v1" + public open fun publicToInternalPAOverriddenFunction() = "Container.publicToInternalPAOverriddenFunction.v1" public open fun publicToPrivateOverriddenFunction() = "Container.publicToPrivateOverriddenFunction.v1" protected open fun protectedToPublicOverriddenFunction() = "Container.protectedToPublicOverriddenFunction.v1" protected open fun protectedToInternalOverriddenFunction() = "Container.protectedToInternalOverriddenFunction.v1" + protected open fun protectedToInternalPAOverriddenFunction() = "Container.protectedToInternalPAOverriddenFunction.v1" protected open fun protectedToPrivateOverriddenFunction() = "Container.protectedToPrivateOverriddenFunction.v1" // public fun newPublicFunction() = "Container.newPublicFunction.v1" @@ -24,5 +29,7 @@ open class Container { // protected open fun newOpenProtectedFunction() = "Container.newOpenProtectedFunction.v1" // internal fun newInternalFunction() = "Container.newInternalFunction.v1" // internal open fun newOpenInternalFunction() = "Container.newOpenInternalFunction.v1" +// @PublishedApi internal fun newInternalPAFunction() = "Container.newInternalPAFunction.v1" +// @PublishedApi internal open fun newOpenInternalPAFunction() = "Container.newOpenInternalPAFunction.v1" // private fun newPrivateFunction() = "Container.newPrivateFunction.v1" } diff --git a/compiler/testData/klibABI/changeFunctionVisibility/lib1/l1.kt.1 b/compiler/testData/klibABI/changeFunctionVisibility/lib1/l1.kt.1 index bab9666ccf1..fb4a2ea76eb 100644 --- a/compiler/testData/klibABI/changeFunctionVisibility/lib1/l1.kt.1 +++ b/compiler/testData/klibABI/changeFunctionVisibility/lib1/l1.kt.1 @@ -1,21 +1,26 @@ internal fun publicToInternalTopLevelFunction() = "publicToInternalTopLevelFunction.v2" +@PublishedApi internal fun publicToInternalPATopLevelFunction() = "publicToInternalPATopLevelFunction.v2" private fun publicToPrivateTopLevelFunction() = "publicToPrivateTopLevelFunction.v2" open class Container { protected fun publicToProtectedFunction() = "Container.publicToProtectedFunction.v2" internal fun publicToInternalFunction() = "Container.publicToInternalFunction.v2" + @PublishedApi internal fun publicToInternalPAFunction() = "Container.publicToInternalPAFunction.v2" private fun publicToPrivateFunction() = "Container.publicToPrivateFunction.v2" public fun protectedToPublicFunction() = "Container.protectedToPublicFunction.v2" internal fun protectedToInternalFunction() = "Container.protectedToInternalFunction.v2" + @PublishedApi internal fun protectedToInternalPAFunction() = "Container.protectedToInternalPAFunction.v2" private fun protectedToPrivateFunction() = "Container.protectedToPrivateFunction.v2" protected open fun publicToProtectedOverriddenFunction() = "Container.publicToProtectedOverriddenFunction.v2" internal open fun publicToInternalOverriddenFunction() = "Container.publicToInternalOverriddenFunction.v2" + @PublishedApi internal open fun publicToInternalPAOverriddenFunction() = "Container.publicToInternalPAOverriddenFunction.v2" private /*open*/ fun publicToPrivateOverriddenFunction() = "Container.publicToPrivateOverriddenFunction.v2" public open fun protectedToPublicOverriddenFunction() = "Container.protectedToPublicOverriddenFunction.v2" internal open fun protectedToInternalOverriddenFunction() = "Container.protectedToInternalOverriddenFunction.v2" + @PublishedApi internal open fun protectedToInternalPAOverriddenFunction() = "Container.protectedToInternalPAOverriddenFunction.v2" private /*open*/ fun protectedToPrivateOverriddenFunction() = "Container.protectedToPrivateOverriddenFunction.v2" public fun newPublicFunction() = "Container.newPublicFunction.v2" @@ -24,5 +29,7 @@ open class Container { protected open fun newOpenProtectedFunction() = "Container.newOpenProtectedFunction.v2" internal fun newInternalFunction() = "Container.newInternalFunction.v2" internal open fun newOpenInternalFunction() = "Container.newOpenInternalFunction.v2" + @PublishedApi internal fun newInternalPAFunction() = "Container.newInternalPAFunction.v2" + @PublishedApi internal open fun newOpenInternalPAFunction() = "Container.newOpenInternalPAFunction.v2" private fun newPrivateFunction() = "Container.newPrivateFunction.v2" } diff --git a/compiler/testData/klibABI/changeFunctionVisibility/lib2/l2.kt b/compiler/testData/klibABI/changeFunctionVisibility/lib2/l2.kt index 326c77ee5a6..ee15ff23478 100644 --- a/compiler/testData/klibABI/changeFunctionVisibility/lib2/l2.kt +++ b/compiler/testData/klibABI/changeFunctionVisibility/lib2/l2.kt @@ -2,25 +2,30 @@ class ContainerImpl : Container() { // Just to check that accessing from within the class hierarchy has the same effect as accessing from the outside: fun publicToProtectedFunctionAccess() = publicToProtectedFunction() fun publicToInternalFunctionAccess() = publicToInternalFunction() + fun publicToInternalPAFunctionAccess() = publicToInternalPAFunction() fun publicToPrivateFunctionAccess() = publicToPrivateFunction() // As far as protected members can't be accessed outside of the class hierarchy, we need special accessors. fun protectedToPublicFunctionAccess() = protectedToPublicFunction() fun protectedToInternalFunctionAccess() = protectedToInternalFunction() + fun protectedToInternalPAFunctionAccess() = protectedToInternalPAFunction() fun protectedToPrivateFunctionAccess() = protectedToPrivateFunction() // Overridden functions with changed visibility: override fun publicToProtectedOverriddenFunction() = "ContainerImpl.publicToProtectedOverriddenFunction" override fun publicToInternalOverriddenFunction() = "ContainerImpl.publicToInternalOverriddenFunction" + override fun publicToInternalPAOverriddenFunction() = "ContainerImpl.publicToInternalPAOverriddenFunction" override fun publicToPrivateOverriddenFunction() = "ContainerImpl.publicToPrivateOverriddenFunction" override fun protectedToPublicOverriddenFunction() = "ContainerImpl.protectedToPublicOverriddenFunction" override fun protectedToInternalOverriddenFunction() = "ContainerImpl.protectedToInternalOverriddenFunction" + override fun protectedToInternalPAOverriddenFunction() = "ContainerImpl.protectedToInternalPAOverriddenFunction" override fun protectedToPrivateOverriddenFunction() = "ContainerImpl.protectedToPrivateOverriddenFunction" // As far as protected members can't be accessed outside of the class hierarchy, we need special accessors. fun protectedToPublicOverriddenFunctionAccess() = protectedToPublicOverriddenFunction() fun protectedToInternalOverriddenFunctionAccess() = protectedToInternalOverriddenFunction() + fun protectedToInternalPAOverriddenFunctionAccess() = protectedToInternalPAOverriddenFunction() fun protectedToPrivateOverriddenFunctionAccess() = protectedToPrivateOverriddenFunction() // Functions that accedentally start to override/conflict with functions added to Container since version v2: @@ -30,6 +35,8 @@ class ContainerImpl : Container() { protected fun newOpenProtectedFunction() = "ContainerImpl.newOpenProtectedFunction" internal fun newInternalFunction() = "ContainerImpl.newInternalFunction" internal fun newOpenInternalFunction() = "ContainerImpl.newOpenInternalFunction" + @PublishedApi internal fun newInternalPAFunction() = "ContainerImpl.newInternalPAFunction" + @PublishedApi internal fun newOpenInternalPAFunction() = "ContainerImpl.newOpenInternalPAFunction" private fun newPrivateFunction() = "ContainerImpl.newPrivateFunction" // As far as protected/private members can't be accessed outside of the class hierarchy, and internal can't be accessed @@ -38,5 +45,7 @@ class ContainerImpl : Container() { fun newOpenProtectedFunctionAccess() = newOpenProtectedFunction() fun newInternalFunctionAccess() = newInternalFunction() fun newOpenInternalFunctionAccess() = newOpenInternalFunction() + fun newInternalPAFunctionAccess() = newInternalPAFunction() + fun newOpenInternalPAFunctionAccess() = newOpenInternalPAFunction() fun newPrivateFunctionAccess() = newPrivateFunction() } diff --git a/compiler/testData/klibABI/changeFunctionVisibility/main/m.kt b/compiler/testData/klibABI/changeFunctionVisibility/main/m.kt index ba2b082fba5..10067340fa8 100644 --- a/compiler/testData/klibABI/changeFunctionVisibility/main/m.kt +++ b/compiler/testData/klibABI/changeFunctionVisibility/main/m.kt @@ -1,33 +1,65 @@ import abitestutils.abiTest +import abitestutils.TestBuilder +import abitestutils.TestMode.NATIVE_CACHE_STATIC_EVERYWHERE fun box() = abiTest { val c = Container() val ci = ContainerImpl() - expectSuccess("publicToInternalTopLevelFunction.v2") { publicToInternalTopLevelFunction() } - expectFailure(prefixed("function publicToPrivateTopLevelFunction can not be called")) { publicToPrivateTopLevelFunction() } - expectSuccess("Container.publicToProtectedFunction.v2") { c.publicToProtectedFunction() } - expectSuccess("Container.publicToProtectedFunction.v2") { ci.publicToProtectedFunction() } - expectFailure(prefixed("function publicToInternalFunction can not be called")) { c.publicToInternalFunction() } - expectFailure(prefixed("function publicToInternalFunction can not be called")) { ci.publicToInternalFunction() } - expectFailure(prefixed("function publicToPrivateFunction can not be called")) { c.publicToPrivateFunction() } - expectFailure(prefixed("function publicToPrivateFunction can not be called")) { ci.publicToPrivateFunction() } - expectSuccess("Container.publicToProtectedFunction.v2") { ci.publicToProtectedFunctionAccess() } - expectFailure(prefixed("function publicToInternalFunction can not be called")) { ci.publicToInternalFunctionAccess() } - expectFailure(prefixed("function publicToPrivateFunction can not be called")) { ci.publicToPrivateFunctionAccess() } - expectSuccess("Container.protectedToPublicFunction.v2") { ci.protectedToPublicFunctionAccess() } - expectFailure(prefixed("function protectedToInternalFunction can not be called")) { ci.protectedToInternalFunctionAccess() } - expectFailure(prefixed("function protectedToPrivateFunction can not be called")) { ci.protectedToPrivateFunctionAccess() } - expectSuccess("ContainerImpl.publicToProtectedOverriddenFunction") { ci.publicToProtectedOverriddenFunction() } - expectSuccess("ContainerImpl.publicToInternalOverriddenFunction") { ci.publicToInternalOverriddenFunction() } - expectSuccess("ContainerImpl.publicToPrivateOverriddenFunction") { ci.publicToPrivateOverriddenFunction() } - expectSuccess("ContainerImpl.protectedToPublicOverriddenFunction") { ci.protectedToPublicOverriddenFunctionAccess() } - expectSuccess("ContainerImpl.protectedToInternalOverriddenFunction") { ci.protectedToInternalOverriddenFunctionAccess() } - expectSuccess("ContainerImpl.protectedToPrivateOverriddenFunction") { ci.protectedToPrivateOverriddenFunctionAccess() } - expectSuccess("ContainerImpl.newPublicFunction") { ci.newPublicFunction() } - expectSuccess("ContainerImpl.newOpenPublicFunction") { ci.newOpenPublicFunction() } - expectSuccess("ContainerImpl.newProtectedFunction") { ci.newProtectedFunctionAccess() } - expectSuccess("ContainerImpl.newOpenProtectedFunction") { ci.newOpenProtectedFunctionAccess() } - expectSuccess("ContainerImpl.newInternalFunction") { ci.newInternalFunctionAccess() } - expectSuccess("ContainerImpl.newOpenInternalFunction") { ci.newOpenInternalFunctionAccess() } - expectSuccess("ContainerImpl.newPrivateFunction") { ci.newPrivateFunctionAccess() } + + success("publicToInternalTopLevelFunction.v2") { publicToInternalTopLevelFunction() } // Signature remains the same. + success("publicToInternalPATopLevelFunction.v2") { publicToInternalPATopLevelFunction() } // Signature remains the same. + unlinkedSymbol("/publicToPrivateTopLevelFunction") { publicToPrivateTopLevelFunction() } // Signature changed. + + success("Container.publicToProtectedFunction.v2") { c.publicToProtectedFunction() } // Signature remains the same. + success("Container.publicToProtectedFunction.v2") { ci.publicToProtectedFunction() } // Signature remains the same. + // TODO: KT-54469, Container.publicToInternalFunction() should fail because it is accessed from another module. + success("Container.publicToInternalFunction.v2") { c.publicToInternalFunction() } // Signature remains the same. + unlinkedSymbol("/ContainerImpl.publicToInternalFunction") { ci.publicToInternalFunction() } // FOs are not generated for internal members from other module. + // TODO: KT-54469, Container.publicToInternalPAFunction() should fail because it is accessed from another module. + success("Container.publicToInternalPAFunction.v2") { c.publicToInternalPAFunction() } // Signature remains the same. + unlinkedSymbol("/ContainerImpl.publicToInternalPAFunction") { ci.publicToInternalPAFunction() } // FOs are not generated for internal members from other module. + inaccessible("publicToPrivateFunction") { c.publicToPrivateFunction() } // Inaccessible from other module though signature remains the same. + unlinkedSymbol("/ContainerImpl.publicToPrivateFunction") { ci.publicToPrivateFunction() } // FOs are not generated for private members. + + success("Container.publicToProtectedFunction.v2") { ci.publicToProtectedFunctionAccess() } // Signature remains the same. + unlinkedSymbol("/ContainerImpl.publicToInternalFunction") { ci.publicToInternalFunctionAccess() } // FOs are not generated for internal members from other module. + unlinkedSymbol("/ContainerImpl.publicToInternalPAFunction") { ci.publicToInternalPAFunctionAccess() } // FOs are not generated for internal members from other module. + unlinkedSymbol("/ContainerImpl.publicToPrivateFunction") { ci.publicToPrivateFunctionAccess() } // FOs are not generated for private members. + success("Container.protectedToPublicFunction.v2") { ci.protectedToPublicFunctionAccess() } // Signature remains the same. + unlinkedSymbol("/ContainerImpl.protectedToInternalFunction") { ci.protectedToInternalFunctionAccess() } // FOs are not generated for internal members from other module. + unlinkedSymbol("/ContainerImpl.protectedToInternalPAFunction") { ci.protectedToInternalPAFunctionAccess() } // FOs are not generated for internal members from other module. + unlinkedSymbol("/ContainerImpl.protectedToPrivateFunction") { ci.protectedToPrivateFunctionAccess() } // FOs are not generated for private members. + + success("ContainerImpl.publicToProtectedOverriddenFunction") { ci.publicToProtectedOverriddenFunction() } + success("ContainerImpl.publicToInternalOverriddenFunction") { ci.publicToInternalOverriddenFunction() } + success("ContainerImpl.publicToInternalPAOverriddenFunction") { ci.publicToInternalPAOverriddenFunction() } + success("ContainerImpl.publicToPrivateOverriddenFunction") { ci.publicToPrivateOverriddenFunction() } + success("ContainerImpl.protectedToPublicOverriddenFunction") { ci.protectedToPublicOverriddenFunctionAccess() } + success("ContainerImpl.protectedToInternalOverriddenFunction") { ci.protectedToInternalOverriddenFunctionAccess() } + success("ContainerImpl.protectedToInternalPAOverriddenFunction") { ci.protectedToInternalPAOverriddenFunctionAccess() } + success("ContainerImpl.protectedToPrivateOverriddenFunction") { ci.protectedToPrivateOverriddenFunctionAccess() } + + success("ContainerImpl.newPublicFunction") { ci.newPublicFunction() } + success("ContainerImpl.newOpenPublicFunction") { ci.newOpenPublicFunction() } + success("ContainerImpl.newProtectedFunction") { ci.newProtectedFunctionAccess() } + success("ContainerImpl.newOpenProtectedFunction") { ci.newOpenProtectedFunctionAccess() } + success("ContainerImpl.newInternalFunction") { ci.newInternalFunctionAccess() } + success("ContainerImpl.newOpenInternalFunction") { ci.newOpenInternalFunctionAccess() } + success("ContainerImpl.newInternalPAFunction") { ci.newInternalPAFunctionAccess() } + success("ContainerImpl.newOpenInternalPAFunction") { ci.newOpenInternalPAFunctionAccess() } + success("ContainerImpl.newPrivateFunction") { ci.newPrivateFunctionAccess() } } + +// Shortcuts: +private inline fun TestBuilder.success(expectedOutcome: String, noinline block: () -> String) = + expectSuccess(expectedOutcome, block) + +private inline fun TestBuilder.unlinkedSymbol(signature: String, noinline block: () -> Unit) { + val functionName = signature.removePrefix("/").substringAfterLast(".") + expectFailure(linkage("Function '$functionName' can not be called: No function found for symbol '$signature'"), block) +} + +private inline fun TestBuilder.inaccessible(functionName: String, noinline block: () -> Unit) = expectFailure( + linkage("Function '$functionName' can not be called: Private function declared in module can not be accessed in module
"), + block +) diff --git a/compiler/testData/klibABI/changeFunctionVisibility/project.info b/compiler/testData/klibABI/changeFunctionVisibility/project.info index 7174f018f58..2147306d715 100644 --- a/compiler/testData/klibABI/changeFunctionVisibility/project.info +++ b/compiler/testData/klibABI/changeFunctionVisibility/project.info @@ -1,4 +1,3 @@ -MUTED MODULES: lib1, lib2, main STEP 0: diff --git a/compiler/testData/klibABI/changePropertyVisibility/lib1/l1.kt b/compiler/testData/klibABI/changePropertyVisibility/lib1/l1.kt index d28af0feccb..04aea95de5e 100644 --- a/compiler/testData/klibABI/changePropertyVisibility/lib1/l1.kt +++ b/compiler/testData/klibABI/changePropertyVisibility/lib1/l1.kt @@ -1,5 +1,7 @@ public val publicToInternalTopLevelProperty1 = "publicToInternalTopLevelProperty1.v1" public val publicToInternalTopLevelProperty2 get() = "publicToInternalTopLevelProperty2.v1" +public val publicToInternalPATopLevelProperty1 = "publicToInternalPATopLevelProperty1.v1" +public val publicToInternalPATopLevelProperty2 get() = "publicToInternalPATopLevelProperty2.v1" public val publicToPrivateTopLevelProperty1 = "publicToPrivateTopLevelProperty1.v1" public val publicToPrivateTopLevelProperty2 get() = "publicToPrivateTopLevelProperty2.v1" @@ -8,6 +10,8 @@ open class Container { public val publicToProtectedProperty2 get() = "Container.publicToProtectedProperty2.v1" public val publicToInternalProperty1 = "Container.publicToInternalProperty1.v1" public val publicToInternalProperty2 get() = "Container.publicToInternalProperty2.v1" + public val publicToInternalPAProperty1 = "Container.publicToInternalPAProperty1.v1" + public val publicToInternalPAProperty2 get() = "Container.publicToInternalPAProperty2.v1" public val publicToPrivateProperty1 = "Container.publicToPrivateProperty1.v1" public val publicToPrivateProperty2 get() = "Container.publicToPrivateProperty2.v1" @@ -15,6 +19,8 @@ open class Container { protected val protectedToPublicProperty2 get() = "Container.protectedToPublicProperty2.v1" protected val protectedToInternalProperty1 = "Container.protectedToInternalProperty1.v1" protected val protectedToInternalProperty2 get() = "Container.protectedToInternalProperty2.v1" + protected val protectedToInternalPAProperty1 = "Container.protectedToInternalPAProperty1.v1" + protected val protectedToInternalPAProperty2 get() = "Container.protectedToInternalPAProperty2.v1" protected val protectedToPrivateProperty1 = "Container.protectedToPrivateProperty1.v1" protected val protectedToPrivateProperty2 get() = "Container.protectedToPrivateProperty2.v1" @@ -26,6 +32,10 @@ open class Container { public open val publicToInternalOverriddenProperty2 get() = "Container.publicToInternalOverriddenProperty2.v1" public open val publicToInternalOverriddenProperty3 = "Container.publicToInternalOverriddenProperty3.v1" public open val publicToInternalOverriddenProperty4 get() = "Container.publicToInternalOverriddenProperty4.v1" + public open val publicToInternalPAOverriddenProperty1 = "Container.publicToInternalPAOverriddenProperty1.v1" + public open val publicToInternalPAOverriddenProperty2 get() = "Container.publicToInternalPAOverriddenProperty2.v1" + public open val publicToInternalPAOverriddenProperty3 = "Container.publicToInternalPAOverriddenProperty3.v1" + public open val publicToInternalPAOverriddenProperty4 get() = "Container.publicToInternalPAOverriddenProperty4.v1" public open val publicToPrivateOverriddenProperty1 = "Container.publicToPrivateOverriddenProperty1.v1" public open val publicToPrivateOverriddenProperty2 get() = "Container.publicToPrivateOverriddenProperty2.v1" public open val publicToPrivateOverriddenProperty3 = "Container.publicToPrivateOverriddenProperty3.v1" @@ -39,6 +49,10 @@ open class Container { protected open val protectedToInternalOverriddenProperty2 get() = "Container.protectedToInternalOverriddenProperty2.v1" protected open val protectedToInternalOverriddenProperty3 = "Container.protectedToInternalOverriddenProperty3.v1" protected open val protectedToInternalOverriddenProperty4 get() = "Container.protectedToInternalOverriddenProperty4.v1" + protected open val protectedToInternalPAOverriddenProperty1 = "Container.protectedToInternalPAOverriddenProperty1.v1" + protected open val protectedToInternalPAOverriddenProperty2 get() = "Container.protectedToInternalPAOverriddenProperty2.v1" + protected open val protectedToInternalPAOverriddenProperty3 = "Container.protectedToInternalPAOverriddenProperty3.v1" + protected open val protectedToInternalPAOverriddenProperty4 get() = "Container.protectedToInternalPAOverriddenProperty4.v1" protected open val protectedToPrivateOverriddenProperty1 = "Container.protectedToPrivateOverriddenProperty1.v1" protected open val protectedToPrivateOverriddenProperty2 get() = "Container.protectedToPrivateOverriddenProperty2.v1" protected open val protectedToPrivateOverriddenProperty3 = "Container.protectedToPrivateOverriddenProperty3.v1" @@ -68,6 +82,14 @@ open class Container { // internal open val newOpenInternalProperty2 get() = "Container.newOpenInternalProperty2.v1" // internal open val newOpenInternalProperty3 = "Container.newOpenInternalProperty3.v1" // internal open val newOpenInternalProperty4 get() = "Container.newOpenInternalProperty4.v1" +// internal val newInternalPAProperty1 = "Container.newInternalPAProperty1.v1" +// internal val newInternalPAProperty2 get() = "Container.newInternalPAProperty2.v1" +// internal val newInternalPAProperty3 = "Container.newInternalPAProperty3.v1" +// internal val newInternalPAProperty4 get() = "Container.newInternalPAProperty4.v1" +// internal open val newOpenInternalPAProperty1 = "Container.newOpenInternalPAProperty1.v1" +// internal open val newOpenInternalPAProperty2 get() = "Container.newOpenInternalPAProperty2.v1" +// internal open val newOpenInternalPAProperty3 = "Container.newOpenInternalPAProperty3.v1" +// internal open val newOpenInternalPAProperty4 get() = "Container.newOpenInternalPAProperty4.v1" // private val newPrivateProperty1 = "Container.newPrivateProperty1.v1" // private val newPrivateProperty2 get() = "Container.newPrivateProperty2.v1" // private val newPrivateProperty3 = "Container.newPrivateProperty3.v1" diff --git a/compiler/testData/klibABI/changePropertyVisibility/lib1/l1.kt.1 b/compiler/testData/klibABI/changePropertyVisibility/lib1/l1.kt.1 index c2d5fea7d23..d8c451f2ea1 100644 --- a/compiler/testData/klibABI/changePropertyVisibility/lib1/l1.kt.1 +++ b/compiler/testData/klibABI/changePropertyVisibility/lib1/l1.kt.1 @@ -1,5 +1,7 @@ internal val publicToInternalTopLevelProperty1 = "publicToInternalTopLevelProperty1.v2" internal val publicToInternalTopLevelProperty2 get() = "publicToInternalTopLevelProperty2.v2" +@PublishedApi internal val publicToInternalPATopLevelProperty1 = "publicToInternalPATopLevelProperty1.v2" +@PublishedApi internal val publicToInternalPATopLevelProperty2 get() = "publicToInternalPATopLevelProperty2.v2" private val publicToPrivateTopLevelProperty1 = "publicToPrivateTopLevelProperty1.v2" private val publicToPrivateTopLevelProperty2 get() = "publicToPrivateTopLevelProperty2.v2" @@ -8,6 +10,8 @@ open class Container { protected val publicToProtectedProperty2 get() = "Container.publicToProtectedProperty2.v2" internal val publicToInternalProperty1 = "Container.publicToInternalProperty1.v2" internal val publicToInternalProperty2 get() = "Container.publicToInternalProperty2.v2" + @PublishedApi internal val publicToInternalPAProperty1 = "Container.publicToInternalPAProperty1.v2" + @PublishedApi internal val publicToInternalPAProperty2 get() = "Container.publicToInternalPAProperty2.v2" private val publicToPrivateProperty1 = "Container.publicToPrivateProperty1.v2" private val publicToPrivateProperty2 get() = "Container.publicToPrivateProperty2.v2" @@ -15,6 +19,8 @@ open class Container { public val protectedToPublicProperty2 get() = "Container.protectedToPublicProperty2.v2" internal val protectedToInternalProperty1 = "Container.protectedToInternalProperty1.v2" internal val protectedToInternalProperty2 get() = "Container.protectedToInternalProperty2.v2" + @PublishedApi internal val protectedToInternalPAProperty1 = "Container.protectedToInternalPAProperty1.v2" + @PublishedApi internal val protectedToInternalPAProperty2 get() = "Container.protectedToInternalPAProperty2.v2" private val protectedToPrivateProperty1 = "Container.protectedToPrivateProperty1.v2" private val protectedToPrivateProperty2 get() = "Container.protectedToPrivateProperty2.v2" @@ -26,6 +32,10 @@ open class Container { internal open val publicToInternalOverriddenProperty2 get() = "Container.publicToInternalOverriddenProperty2.v2" internal open val publicToInternalOverriddenProperty3 get() = "Container.publicToInternalOverriddenProperty3.v2" internal open val publicToInternalOverriddenProperty4 = "Container.publicToInternalOverriddenProperty4.v2" + @PublishedApi internal open val publicToInternalPAOverriddenProperty1 = "Container.publicToInternalPAOverriddenProperty1.v2" + @PublishedApi internal open val publicToInternalPAOverriddenProperty2 get() = "Container.publicToInternalPAOverriddenProperty2.v2" + @PublishedApi internal open val publicToInternalPAOverriddenProperty3 = "Container.publicToInternalPAOverriddenProperty3.v2" + @PublishedApi internal open val publicToInternalPAOverriddenProperty4 get() = "Container.publicToInternalPAOverriddenProperty4.v2" private /*open*/ val publicToPrivateOverriddenProperty1 = "Container.publicToPrivateOverriddenProperty1.v2" private /*open*/ val publicToPrivateOverriddenProperty2 get() = "Container.publicToPrivateOverriddenProperty2.v2" private /*open*/ val publicToPrivateOverriddenProperty3 get() = "Container.publicToPrivateOverriddenProperty3.v2" @@ -39,6 +49,10 @@ open class Container { internal open val protectedToInternalOverriddenProperty2 get() = "Container.protectedToInternalOverriddenProperty2.v2" internal open val protectedToInternalOverriddenProperty3 get() = "Container.protectedToInternalOverriddenProperty3.v2" internal open val protectedToInternalOverriddenProperty4 = "Container.protectedToInternalOverriddenProperty4.v2" + @PublishedApi internal open val protectedToInternalPAOverriddenProperty1 = "Container.protectedToInternalPAOverriddenProperty1.v2" + @PublishedApi internal open val protectedToInternalPAOverriddenProperty2 get() = "Container.protectedToInternalPAOverriddenProperty2.v2" + @PublishedApi internal open val protectedToInternalPAOverriddenProperty3 = "Container.protectedToInternalPAOverriddenProperty3.v2" + @PublishedApi internal open val protectedToInternalPAOverriddenProperty4 get() = "Container.protectedToInternalPAOverriddenProperty4.v2" private /*open*/ val protectedToPrivateOverriddenProperty1 = "Container.protectedToPrivateOverriddenProperty1.v2" private /*open*/ val protectedToPrivateOverriddenProperty2 get() = "Container.protectedToPrivateOverriddenProperty2.v2" private /*open*/ val protectedToPrivateOverriddenProperty3 get() = "Container.protectedToPrivateOverriddenProperty3.v2" @@ -68,6 +82,14 @@ open class Container { internal open val newOpenInternalProperty2 get() = "Container.newOpenInternalProperty2.v2" internal open val newOpenInternalProperty3 = "Container.newOpenInternalProperty3.v2" internal open val newOpenInternalProperty4 get() = "Container.newOpenInternalProperty4.v2" + @PublishedApi internal val newInternalPAProperty1 = "Container.newInternalPAProperty1.v2" + @PublishedApi internal val newInternalPAProperty2 get() = "Container.newInternalPAProperty2.v2" + @PublishedApi internal val newInternalPAProperty3 = "Container.newInternalPAProperty3.v2" + @PublishedApi internal val newInternalPAProperty4 get() = "Container.newInternalPAProperty4.v2" + @PublishedApi internal open val newOpenInternalPAProperty1 = "Container.newOpenInternalPAProperty1.v2" + @PublishedApi internal open val newOpenInternalPAProperty2 get() = "Container.newOpenInternalPAProperty2.v2" + @PublishedApi internal open val newOpenInternalPAProperty3 = "Container.newOpenInternalPAProperty3.v2" + @PublishedApi internal open val newOpenInternalPAProperty4 get() = "Container.newOpenInternalPAProperty4.v2" private val newPrivateProperty1 = "Container.newPrivateProperty1.v2" private val newPrivateProperty2 get() = "Container.newPrivateProperty2.v2" private val newPrivateProperty3 = "Container.newPrivateProperty3.v2" diff --git a/compiler/testData/klibABI/changePropertyVisibility/lib2/l2.kt b/compiler/testData/klibABI/changePropertyVisibility/lib2/l2.kt index 7819377ab0c..8f760ea3405 100644 --- a/compiler/testData/klibABI/changePropertyVisibility/lib2/l2.kt +++ b/compiler/testData/klibABI/changePropertyVisibility/lib2/l2.kt @@ -4,6 +4,8 @@ class ContainerImpl : Container() { fun publicToProtectedProperty2Access() = publicToProtectedProperty2 fun publicToInternalProperty1Access() = publicToInternalProperty1 fun publicToInternalProperty2Access() = publicToInternalProperty2 + fun publicToInternalPAProperty1Access() = publicToInternalPAProperty1 + fun publicToInternalPAProperty2Access() = publicToInternalPAProperty2 fun publicToPrivateProperty1Access() = publicToPrivateProperty1 fun publicToPrivateProperty2Access() = publicToPrivateProperty2 @@ -12,6 +14,8 @@ class ContainerImpl : Container() { fun protectedToPublicProperty2Access() = protectedToPublicProperty2 fun protectedToInternalProperty1Access() = protectedToInternalProperty1 fun protectedToInternalProperty2Access() = protectedToInternalProperty2 + fun protectedToInternalPAProperty1Access() = protectedToInternalPAProperty1 + fun protectedToInternalPAProperty2Access() = protectedToInternalPAProperty2 fun protectedToPrivateProperty1Access() = protectedToPrivateProperty1 fun protectedToPrivateProperty2Access() = protectedToPrivateProperty2 @@ -24,6 +28,10 @@ class ContainerImpl : Container() { override val publicToInternalOverriddenProperty2 get() = "ContainerImpl.publicToInternalOverriddenProperty2" override val publicToInternalOverriddenProperty3 get() = "ContainerImpl.publicToInternalOverriddenProperty3" override val publicToInternalOverriddenProperty4 = "ContainerImpl.publicToInternalOverriddenProperty4" + override val publicToInternalPAOverriddenProperty1 = "ContainerImpl.publicToInternalPAOverriddenProperty1" + override val publicToInternalPAOverriddenProperty2 get() = "ContainerImpl.publicToInternalPAOverriddenProperty2" + override val publicToInternalPAOverriddenProperty3 get() = "ContainerImpl.publicToInternalPAOverriddenProperty3" + override val publicToInternalPAOverriddenProperty4 = "ContainerImpl.publicToInternalPAOverriddenProperty4" override val publicToPrivateOverriddenProperty1 = "ContainerImpl.publicToPrivateOverriddenProperty1" override val publicToPrivateOverriddenProperty2 get() = "ContainerImpl.publicToPrivateOverriddenProperty2" override val publicToPrivateOverriddenProperty3 get() = "ContainerImpl.publicToPrivateOverriddenProperty3" @@ -37,6 +45,10 @@ class ContainerImpl : Container() { override val protectedToInternalOverriddenProperty2 get() = "ContainerImpl.protectedToInternalOverriddenProperty2" override val protectedToInternalOverriddenProperty3 get() = "ContainerImpl.protectedToInternalOverriddenProperty3" override val protectedToInternalOverriddenProperty4 = "ContainerImpl.protectedToInternalOverriddenProperty4" + override val protectedToInternalPAOverriddenProperty1 = "ContainerImpl.protectedToInternalPAOverriddenProperty1" + override val protectedToInternalPAOverriddenProperty2 get() = "ContainerImpl.protectedToInternalPAOverriddenProperty2" + override val protectedToInternalPAOverriddenProperty3 get() = "ContainerImpl.protectedToInternalPAOverriddenProperty3" + override val protectedToInternalPAOverriddenProperty4 = "ContainerImpl.protectedToInternalPAOverriddenProperty4" override val protectedToPrivateOverriddenProperty1 = "ContainerImpl.protectedToPrivateOverriddenProperty1" override val protectedToPrivateOverriddenProperty2 get() = "ContainerImpl.protectedToPrivateOverriddenProperty2" override val protectedToPrivateOverriddenProperty3 get() = "ContainerImpl.protectedToPrivateOverriddenProperty3" @@ -51,6 +63,10 @@ class ContainerImpl : Container() { fun protectedToInternalOverriddenProperty2Access() = protectedToInternalOverriddenProperty2 fun protectedToInternalOverriddenProperty3Access() = protectedToInternalOverriddenProperty3 fun protectedToInternalOverriddenProperty4Access() = protectedToInternalOverriddenProperty4 + fun protectedToInternalPAOverriddenProperty1Access() = protectedToInternalPAOverriddenProperty1 + fun protectedToInternalPAOverriddenProperty2Access() = protectedToInternalPAOverriddenProperty2 + fun protectedToInternalPAOverriddenProperty3Access() = protectedToInternalPAOverriddenProperty3 + fun protectedToInternalPAOverriddenProperty4Access() = protectedToInternalPAOverriddenProperty4 fun protectedToPrivateOverriddenProperty1Access() = protectedToPrivateOverriddenProperty1 fun protectedToPrivateOverriddenProperty2Access() = protectedToPrivateOverriddenProperty2 fun protectedToPrivateOverriddenProperty3Access() = protectedToPrivateOverriddenProperty3 @@ -81,6 +97,14 @@ class ContainerImpl : Container() { internal open val newOpenInternalProperty2 get() = "ContainerImpl.newOpenInternalProperty2" internal open val newOpenInternalProperty3 get() = "ContainerImpl.newOpenInternalProperty3" internal open val newOpenInternalProperty4 = "ContainerImpl.newOpenInternalProperty4" + internal val newInternalPAProperty1 = "ContainerImpl.newInternalPAProperty1" + internal val newInternalPAProperty2 get() = "ContainerImpl.newInternalPAProperty2" + internal val newInternalPAProperty3 get() = "ContainerImpl.newInternalPAProperty3" + internal val newInternalPAProperty4 = "ContainerImpl.newInternalPAProperty4" + internal open val newOpenInternalPAProperty1 = "ContainerImpl.newOpenInternalPAProperty1" + internal open val newOpenInternalPAProperty2 get() = "ContainerImpl.newOpenInternalPAProperty2" + internal open val newOpenInternalPAProperty3 get() = "ContainerImpl.newOpenInternalPAProperty3" + internal open val newOpenInternalPAProperty4 = "ContainerImpl.newOpenInternalPAProperty4" private val newPrivateProperty1 = "ContainerImpl.newPrivateProperty1" private val newPrivateProperty2 get() = "ContainerImpl.newPrivateProperty2" private val newPrivateProperty3 get() = "ContainerImpl.newPrivateProperty3" @@ -104,6 +128,14 @@ class ContainerImpl : Container() { fun newOpenInternalProperty2Access() = newOpenInternalProperty2 fun newOpenInternalProperty3Access() = newOpenInternalProperty3 fun newOpenInternalProperty4Access() = newOpenInternalProperty4 + fun newInternalPAProperty1Access() = newInternalPAProperty1 + fun newInternalPAProperty2Access() = newInternalPAProperty2 + fun newInternalPAProperty3Access() = newInternalPAProperty3 + fun newInternalPAProperty4Access() = newInternalPAProperty4 + fun newOpenInternalPAProperty1Access() = newOpenInternalPAProperty1 + fun newOpenInternalPAProperty2Access() = newOpenInternalPAProperty2 + fun newOpenInternalPAProperty3Access() = newOpenInternalPAProperty3 + fun newOpenInternalPAProperty4Access() = newOpenInternalPAProperty4 fun newPrivateProperty1Access() = newPrivateProperty1 fun newPrivateProperty2Access() = newPrivateProperty2 fun newPrivateProperty3Access() = newPrivateProperty3 diff --git a/compiler/testData/klibABI/changePropertyVisibility/main/m.kt b/compiler/testData/klibABI/changePropertyVisibility/main/m.kt index 0c548071e87..5162ed953c7 100644 --- a/compiler/testData/klibABI/changePropertyVisibility/main/m.kt +++ b/compiler/testData/klibABI/changePropertyVisibility/main/m.kt @@ -1,82 +1,133 @@ import abitestutils.abiTest +import abitestutils.TestBuilder +import abitestutils.TestMode.NATIVE_CACHE_STATIC_EVERYWHERE fun box() = abiTest { val c = Container() val ci = ContainerImpl() - expectSuccess("publicToInternalTopLevelProperty1.v2") { publicToInternalTopLevelProperty1 } - expectSuccess("publicToInternalTopLevelProperty2.v2") { publicToInternalTopLevelProperty2 } - expectFailure(prefixed("property accessor publicToPrivateTopLevelProperty1. can not be called")) { publicToPrivateTopLevelProperty1 } - expectFailure(prefixed("property accessor publicToPrivateTopLevelProperty2. can not be called")) { publicToPrivateTopLevelProperty2 } - expectSuccess("Container.publicToProtectedProperty1.v2") { c.publicToProtectedProperty1 } - expectSuccess("Container.publicToProtectedProperty1.v2") { ci.publicToProtectedProperty1 } - expectSuccess("Container.publicToProtectedProperty2.v2") { c.publicToProtectedProperty2 } - expectSuccess("Container.publicToProtectedProperty2.v2") { ci.publicToProtectedProperty2 } - expectFailure(prefixed("property accessor publicToInternalProperty1. can not be called")) { c.publicToInternalProperty1 } - expectFailure(prefixed("property accessor publicToInternalProperty1. can not be called")) { ci.publicToInternalProperty1 } - expectFailure(prefixed("property accessor publicToInternalProperty2. can not be called")) { c.publicToInternalProperty2 } - expectFailure(prefixed("property accessor publicToInternalProperty2. can not be called")) { ci.publicToInternalProperty2 } - expectFailure(prefixed("property accessor publicToPrivateProperty1. can not be called")) { c.publicToPrivateProperty1 } - expectFailure(prefixed("property accessor publicToPrivateProperty1. can not be called")) { ci.publicToPrivateProperty1 } - expectFailure(prefixed("property accessor publicToPrivateProperty2. can not be called")) { c.publicToPrivateProperty2 } - expectFailure(prefixed("property accessor publicToPrivateProperty2. can not be called")) { ci.publicToPrivateProperty2 } - expectSuccess("Container.publicToProtectedProperty1.v2") { ci.publicToProtectedProperty1Access() } - expectSuccess("Container.publicToProtectedProperty2.v2") { ci.publicToProtectedProperty2Access() } - expectFailure(prefixed("property accessor publicToInternalProperty1. can not be called")) { ci.publicToInternalProperty1Access() } - expectFailure(prefixed("property accessor publicToInternalProperty2. can not be called")) { ci.publicToInternalProperty2Access() } - expectFailure(prefixed("property accessor publicToPrivateProperty1. can not be called")) { ci.publicToPrivateProperty1Access() } - expectFailure(prefixed("property accessor publicToPrivateProperty2. can not be called")) { ci.publicToPrivateProperty2Access() } - expectSuccess("Container.protectedToPublicProperty1.v2") { ci.protectedToPublicProperty1Access() } - expectSuccess("Container.protectedToPublicProperty2.v2") { ci.protectedToPublicProperty2Access() } - expectFailure(prefixed("property accessor protectedToInternalProperty1. can not be called")) { ci.protectedToInternalProperty1Access() } - expectFailure(prefixed("property accessor protectedToInternalProperty2. can not be called")) { ci.protectedToInternalProperty2Access() } - expectFailure(prefixed("property accessor protectedToPrivateProperty1. can not be called")) { ci.protectedToPrivateProperty1Access() } - expectFailure(prefixed("property accessor protectedToPrivateProperty2. can not be called")) { ci.protectedToPrivateProperty2Access() } - expectSuccess("ContainerImpl.publicToProtectedOverriddenProperty1") { ci.publicToProtectedOverriddenProperty1 } - expectSuccess("ContainerImpl.publicToProtectedOverriddenProperty2") { ci.publicToProtectedOverriddenProperty2 } - expectSuccess("ContainerImpl.publicToProtectedOverriddenProperty3") { ci.publicToProtectedOverriddenProperty3 } - expectSuccess("ContainerImpl.publicToProtectedOverriddenProperty4") { ci.publicToProtectedOverriddenProperty4 } - expectSuccess("ContainerImpl.publicToInternalOverriddenProperty1") { ci.publicToInternalOverriddenProperty1 } - expectSuccess("ContainerImpl.publicToInternalOverriddenProperty2") { ci.publicToInternalOverriddenProperty2 } - expectSuccess("ContainerImpl.publicToInternalOverriddenProperty3") { ci.publicToInternalOverriddenProperty3 } - expectSuccess("ContainerImpl.publicToInternalOverriddenProperty4") { ci.publicToInternalOverriddenProperty4 } - expectSuccess("ContainerImpl.publicToPrivateOverriddenProperty1") { ci.publicToPrivateOverriddenProperty1 } - expectSuccess("ContainerImpl.publicToPrivateOverriddenProperty2") { ci.publicToPrivateOverriddenProperty2 } - expectSuccess("ContainerImpl.publicToPrivateOverriddenProperty3") { ci.publicToPrivateOverriddenProperty3 } - expectSuccess("ContainerImpl.publicToPrivateOverriddenProperty4") { ci.publicToPrivateOverriddenProperty4 } - expectSuccess("ContainerImpl.protectedToPublicOverriddenProperty1") { ci.protectedToPublicOverriddenProperty1Access() } - expectSuccess("ContainerImpl.protectedToPublicOverriddenProperty2") { ci.protectedToPublicOverriddenProperty2Access() } - expectSuccess("ContainerImpl.protectedToPublicOverriddenProperty3") { ci.protectedToPublicOverriddenProperty3Access() } - expectSuccess("ContainerImpl.protectedToPublicOverriddenProperty4") { ci.protectedToPublicOverriddenProperty4Access() } - expectSuccess("ContainerImpl.protectedToInternalOverriddenProperty1") { ci.protectedToInternalOverriddenProperty1Access() } - expectSuccess("ContainerImpl.protectedToInternalOverriddenProperty2") { ci.protectedToInternalOverriddenProperty2Access() } - expectSuccess("ContainerImpl.protectedToInternalOverriddenProperty3") { ci.protectedToInternalOverriddenProperty3Access() } - expectSuccess("ContainerImpl.protectedToInternalOverriddenProperty4") { ci.protectedToInternalOverriddenProperty4Access() } - expectSuccess("ContainerImpl.protectedToPrivateOverriddenProperty1") { ci.protectedToPrivateOverriddenProperty1Access() } - expectSuccess("ContainerImpl.protectedToPrivateOverriddenProperty2") { ci.protectedToPrivateOverriddenProperty2Access() } - expectSuccess("ContainerImpl.protectedToPrivateOverriddenProperty3") { ci.protectedToPrivateOverriddenProperty3Access() } - expectSuccess("ContainerImpl.protectedToPrivateOverriddenProperty4") { ci.protectedToPrivateOverriddenProperty4Access() } - expectSuccess("ContainerImpl.newPublicProperty1") { ci.newPublicProperty1 } - expectSuccess("ContainerImpl.newPublicProperty2") { ci.newPublicProperty2 } - expectSuccess("ContainerImpl.newPublicProperty3") { ci.newPublicProperty3 } - expectSuccess("ContainerImpl.newPublicProperty4") { ci.newPublicProperty4 } - expectSuccess("ContainerImpl.newProtectedProperty1") { ci.newProtectedProperty1Access() } - expectSuccess("ContainerImpl.newProtectedProperty2") { ci.newProtectedProperty2Access() } - expectSuccess("ContainerImpl.newProtectedProperty3") { ci.newProtectedProperty3Access() } - expectSuccess("ContainerImpl.newProtectedProperty4") { ci.newProtectedProperty4Access() } - expectSuccess("ContainerImpl.newOpenProtectedProperty1") { ci.newOpenProtectedProperty1Access() } - expectSuccess("ContainerImpl.newOpenProtectedProperty2") { ci.newOpenProtectedProperty2Access() } - expectSuccess("ContainerImpl.newOpenProtectedProperty3") { ci.newOpenProtectedProperty3Access() } - expectSuccess("ContainerImpl.newOpenProtectedProperty4") { ci.newOpenProtectedProperty4Access() } - expectSuccess("ContainerImpl.newInternalProperty1") { ci.newInternalProperty1Access() } - expectSuccess("ContainerImpl.newInternalProperty2") { ci.newInternalProperty2Access() } - expectSuccess("ContainerImpl.newInternalProperty3") { ci.newInternalProperty3Access() } - expectSuccess("ContainerImpl.newInternalProperty4") { ci.newInternalProperty4Access() } - expectSuccess("ContainerImpl.newOpenInternalProperty1") { ci.newOpenInternalProperty1Access() } - expectSuccess("ContainerImpl.newOpenInternalProperty2") { ci.newOpenInternalProperty2Access() } - expectSuccess("ContainerImpl.newOpenInternalProperty3") { ci.newOpenInternalProperty3Access() } - expectSuccess("ContainerImpl.newOpenInternalProperty4") { ci.newOpenInternalProperty4Access() } - expectSuccess("ContainerImpl.newPrivateProperty1") { ci.newPrivateProperty1Access() } - expectSuccess("ContainerImpl.newPrivateProperty2") { ci.newPrivateProperty2Access() } - expectSuccess("ContainerImpl.newPrivateProperty3") { ci.newPrivateProperty3Access() } - expectSuccess("ContainerImpl.newPrivateProperty4") { ci.newPrivateProperty4Access() } + + success("publicToInternalTopLevelProperty1.v2") { publicToInternalTopLevelProperty1 } // Signature remains the same. + success("publicToInternalTopLevelProperty2.v2") { publicToInternalTopLevelProperty2 } // Signature remains the same. + success("publicToInternalPATopLevelProperty1.v2") { publicToInternalPATopLevelProperty1 } // Signature remains the same. + success("publicToInternalPATopLevelProperty2.v2") { publicToInternalPATopLevelProperty2 } // Signature remains the same. + unlinkedSymbol("/publicToPrivateTopLevelProperty1.") { publicToPrivateTopLevelProperty1 } // Signature changed. + unlinkedSymbol("/publicToPrivateTopLevelProperty2.") { publicToPrivateTopLevelProperty2 } // Signature changed. + + success("Container.publicToProtectedProperty1.v2") { c.publicToProtectedProperty1 } // Signature remains the same. + success("Container.publicToProtectedProperty1.v2") { ci.publicToProtectedProperty1 } // Signature remains the same. + success("Container.publicToProtectedProperty2.v2") { c.publicToProtectedProperty2 } // Signature remains the same. + success("Container.publicToProtectedProperty2.v2") { ci.publicToProtectedProperty2 } // Signature remains the same. + // TODO: KT-54469, Container.publicToInternalProperty1 should fail because it is accessed from another module. + success("Container.publicToInternalProperty1.v2") { c.publicToInternalProperty1 } // Signature remains the same. + unlinkedSymbol("/ContainerImpl.publicToInternalProperty1.") { ci.publicToInternalProperty1 } // FOs are not generated for internal members from other module. + // TODO: KT-54469, Container.publicToInternalProperty2 should fail because it is accessed from another module. + success("Container.publicToInternalProperty2.v2") { c.publicToInternalProperty2 } // Signature remains the same. + unlinkedSymbol("/ContainerImpl.publicToInternalProperty2.") { ci.publicToInternalProperty2 } // FOs are not generated for internal members from other module. + // TODO: KT-54469, Container.publicToInternalPAProperty1 should fail because it is accessed from another module. + success("Container.publicToInternalPAProperty1.v2") { c.publicToInternalPAProperty1 } // Signature remains the same. + unlinkedSymbol("/ContainerImpl.publicToInternalPAProperty1.") { ci.publicToInternalPAProperty1 } // FOs are not generated for internal members from other module. + // TODO: KT-54469, Container.publicToInternalPAProperty2 should fail because it is accessed from another module. + success("Container.publicToInternalPAProperty2.v2") { c.publicToInternalPAProperty2 } // Signature remains the same. + unlinkedSymbol("/ContainerImpl.publicToInternalPAProperty2.") { ci.publicToInternalPAProperty2 } // FOs are not generated for internal members from other module. + inaccessible("publicToPrivateProperty1.") { c.publicToPrivateProperty1 } // Inaccessible from other module though signature remains the same. + unlinkedSymbol("/ContainerImpl.publicToPrivateProperty1.") { ci.publicToPrivateProperty1 } // FOs are not generated for private members. + inaccessible("publicToPrivateProperty2.") { c.publicToPrivateProperty2 } // Inaccessible from other module though signature remains the same. + unlinkedSymbol("/ContainerImpl.publicToPrivateProperty2.") { ci.publicToPrivateProperty2 } // FOs are not generated for private members. + + success("Container.publicToProtectedProperty1.v2") { ci.publicToProtectedProperty1Access() } // Signature remains the same. + success("Container.publicToProtectedProperty2.v2") { ci.publicToProtectedProperty2Access() } // Signature remains the same. + unlinkedSymbol("/ContainerImpl.publicToInternalProperty1.") { ci.publicToInternalProperty1Access() } // FOs are not generated for internal members from other module. + unlinkedSymbol("/ContainerImpl.publicToInternalProperty2.") { ci.publicToInternalProperty2Access() } // FOs are not generated for internal members from other module. + unlinkedSymbol("/ContainerImpl.publicToInternalPAProperty1.") { ci.publicToInternalPAProperty1Access() } // FOs are not generated for internal members from other module. + unlinkedSymbol("/ContainerImpl.publicToInternalPAProperty2.") { ci.publicToInternalPAProperty2Access() } // FOs are not generated for internal members from other module. + unlinkedSymbol("/ContainerImpl.publicToPrivateProperty1.") { ci.publicToPrivateProperty1Access() } // FOs are not generated for private members. + unlinkedSymbol("/ContainerImpl.publicToPrivateProperty2.") { ci.publicToPrivateProperty2Access() } // FOs are not generated for private members. + success("Container.protectedToPublicProperty1.v2") { ci.protectedToPublicProperty1Access() } // Signature remains the same. + success("Container.protectedToPublicProperty2.v2") { ci.protectedToPublicProperty2Access() } // Signature remains the same. + unlinkedSymbol("/ContainerImpl.protectedToInternalProperty1.") { ci.protectedToInternalProperty1Access() } // FOs are not generated for internal members from other module. + unlinkedSymbol("/ContainerImpl.protectedToInternalProperty2.") { ci.protectedToInternalProperty2Access() } // FOs are not generated for internal members from other module. + unlinkedSymbol("/ContainerImpl.protectedToInternalPAProperty1.") { ci.protectedToInternalPAProperty1Access() } // FOs are not generated for internal members from other module. + unlinkedSymbol("/ContainerImpl.protectedToInternalPAProperty2.") { ci.protectedToInternalPAProperty2Access() } // FOs are not generated for internal members from other module. + unlinkedSymbol("/ContainerImpl.protectedToPrivateProperty1.") { ci.protectedToPrivateProperty1Access() } // FOs are not generated for private members. + unlinkedSymbol("/ContainerImpl.protectedToPrivateProperty2.") { ci.protectedToPrivateProperty2Access() } // FOs are not generated for private members. + + success("ContainerImpl.publicToProtectedOverriddenProperty1") { ci.publicToProtectedOverriddenProperty1 } + success("ContainerImpl.publicToProtectedOverriddenProperty2") { ci.publicToProtectedOverriddenProperty2 } + success("ContainerImpl.publicToProtectedOverriddenProperty3") { ci.publicToProtectedOverriddenProperty3 } + success("ContainerImpl.publicToProtectedOverriddenProperty4") { ci.publicToProtectedOverriddenProperty4 } + success("ContainerImpl.publicToInternalOverriddenProperty1") { ci.publicToInternalOverriddenProperty1 } + success("ContainerImpl.publicToInternalOverriddenProperty2") { ci.publicToInternalOverriddenProperty2 } + success("ContainerImpl.publicToInternalOverriddenProperty3") { ci.publicToInternalOverriddenProperty3 } + success("ContainerImpl.publicToInternalOverriddenProperty4") { ci.publicToInternalOverriddenProperty4 } + success("ContainerImpl.publicToInternalPAOverriddenProperty1") { ci.publicToInternalPAOverriddenProperty1 } + success("ContainerImpl.publicToInternalPAOverriddenProperty2") { ci.publicToInternalPAOverriddenProperty2 } + success("ContainerImpl.publicToInternalPAOverriddenProperty3") { ci.publicToInternalPAOverriddenProperty3 } + success("ContainerImpl.publicToInternalPAOverriddenProperty4") { ci.publicToInternalPAOverriddenProperty4 } + success("ContainerImpl.publicToPrivateOverriddenProperty1") { ci.publicToPrivateOverriddenProperty1 } + success("ContainerImpl.publicToPrivateOverriddenProperty2") { ci.publicToPrivateOverriddenProperty2 } + success("ContainerImpl.publicToPrivateOverriddenProperty3") { ci.publicToPrivateOverriddenProperty3 } + success("ContainerImpl.publicToPrivateOverriddenProperty4") { ci.publicToPrivateOverriddenProperty4 } + success("ContainerImpl.protectedToPublicOverriddenProperty1") { ci.protectedToPublicOverriddenProperty1Access() } + success("ContainerImpl.protectedToPublicOverriddenProperty2") { ci.protectedToPublicOverriddenProperty2Access() } + success("ContainerImpl.protectedToPublicOverriddenProperty3") { ci.protectedToPublicOverriddenProperty3Access() } + success("ContainerImpl.protectedToPublicOverriddenProperty4") { ci.protectedToPublicOverriddenProperty4Access() } + success("ContainerImpl.protectedToInternalOverriddenProperty1") { ci.protectedToInternalOverriddenProperty1Access() } + success("ContainerImpl.protectedToInternalOverriddenProperty2") { ci.protectedToInternalOverriddenProperty2Access() } + success("ContainerImpl.protectedToInternalOverriddenProperty3") { ci.protectedToInternalOverriddenProperty3Access() } + success("ContainerImpl.protectedToInternalOverriddenProperty4") { ci.protectedToInternalOverriddenProperty4Access() } + success("ContainerImpl.protectedToInternalPAOverriddenProperty1") { ci.protectedToInternalPAOverriddenProperty1Access() } + success("ContainerImpl.protectedToInternalPAOverriddenProperty2") { ci.protectedToInternalPAOverriddenProperty2Access() } + success("ContainerImpl.protectedToInternalPAOverriddenProperty3") { ci.protectedToInternalPAOverriddenProperty3Access() } + success("ContainerImpl.protectedToInternalPAOverriddenProperty4") { ci.protectedToInternalPAOverriddenProperty4Access() } + success("ContainerImpl.protectedToPrivateOverriddenProperty1") { ci.protectedToPrivateOverriddenProperty1Access() } + success("ContainerImpl.protectedToPrivateOverriddenProperty2") { ci.protectedToPrivateOverriddenProperty2Access() } + success("ContainerImpl.protectedToPrivateOverriddenProperty3") { ci.protectedToPrivateOverriddenProperty3Access() } + success("ContainerImpl.protectedToPrivateOverriddenProperty4") { ci.protectedToPrivateOverriddenProperty4Access() } + + success("ContainerImpl.newPublicProperty1") { ci.newPublicProperty1 } + success("ContainerImpl.newPublicProperty2") { ci.newPublicProperty2 } + success("ContainerImpl.newPublicProperty3") { ci.newPublicProperty3 } + success("ContainerImpl.newPublicProperty4") { ci.newPublicProperty4 } + success("ContainerImpl.newProtectedProperty1") { ci.newProtectedProperty1Access() } + success("ContainerImpl.newProtectedProperty2") { ci.newProtectedProperty2Access() } + success("ContainerImpl.newProtectedProperty3") { ci.newProtectedProperty3Access() } + success("ContainerImpl.newProtectedProperty4") { ci.newProtectedProperty4Access() } + success("ContainerImpl.newOpenProtectedProperty1") { ci.newOpenProtectedProperty1Access() } + success("ContainerImpl.newOpenProtectedProperty2") { ci.newOpenProtectedProperty2Access() } + success("ContainerImpl.newOpenProtectedProperty3") { ci.newOpenProtectedProperty3Access() } + success("ContainerImpl.newOpenProtectedProperty4") { ci.newOpenProtectedProperty4Access() } + success("ContainerImpl.newInternalProperty1") { ci.newInternalProperty1Access() } + success("ContainerImpl.newInternalProperty2") { ci.newInternalProperty2Access() } + success("ContainerImpl.newInternalProperty3") { ci.newInternalProperty3Access() } + success("ContainerImpl.newInternalProperty4") { ci.newInternalProperty4Access() } + success("ContainerImpl.newOpenInternalProperty1") { ci.newOpenInternalProperty1Access() } + success("ContainerImpl.newOpenInternalProperty2") { ci.newOpenInternalProperty2Access() } + success("ContainerImpl.newOpenInternalProperty3") { ci.newOpenInternalProperty3Access() } + success("ContainerImpl.newOpenInternalProperty4") { ci.newOpenInternalProperty4Access() } + success("ContainerImpl.newInternalPAProperty1") { ci.newInternalPAProperty1Access() } + success("ContainerImpl.newInternalPAProperty2") { ci.newInternalPAProperty2Access() } + success("ContainerImpl.newInternalPAProperty3") { ci.newInternalPAProperty3Access() } + success("ContainerImpl.newInternalPAProperty4") { ci.newInternalPAProperty4Access() } + success("ContainerImpl.newOpenInternalPAProperty1") { ci.newOpenInternalPAProperty1Access() } + success("ContainerImpl.newOpenInternalPAProperty2") { ci.newOpenInternalPAProperty2Access() } + success("ContainerImpl.newOpenInternalPAProperty3") { ci.newOpenInternalPAProperty3Access() } + success("ContainerImpl.newOpenInternalPAProperty4") { ci.newOpenInternalPAProperty4Access() } + success("ContainerImpl.newPrivateProperty1") { ci.newPrivateProperty1Access() } + success("ContainerImpl.newPrivateProperty2") { ci.newPrivateProperty2Access() } + success("ContainerImpl.newPrivateProperty3") { ci.newPrivateProperty3Access() } + success("ContainerImpl.newPrivateProperty4") { ci.newPrivateProperty4Access() } } + +// Shortcuts: +private inline fun TestBuilder.success(expectedOutcome: String, noinline block: () -> String) = + expectSuccess(expectedOutcome, block) + +private inline fun TestBuilder.unlinkedSymbol(signature: String, noinline block: () -> Unit) { + val accessorName = signature.removePrefix("/").split('.').takeLast(2).joinToString(".") + expectFailure(linkage("Property accessor '$accessorName' can not be called: No property accessor found for symbol '$signature'"), block) +} + +private inline fun TestBuilder.inaccessible(accessorName: String, noinline block: () -> Unit) = expectFailure( + linkage("Property accessor '$accessorName' can not be called: Private property accessor declared in module can not be accessed in module
"), + block +) diff --git a/compiler/testData/klibABI/changePropertyVisibility/project.info b/compiler/testData/klibABI/changePropertyVisibility/project.info index 7174f018f58..2147306d715 100644 --- a/compiler/testData/klibABI/changePropertyVisibility/project.info +++ b/compiler/testData/klibABI/changePropertyVisibility/project.info @@ -1,4 +1,3 @@ -MUTED MODULES: lib1, lib2, main STEP 0: diff --git a/compiler/testData/klibABI/classTransformations/lib1/l1.kt b/compiler/testData/klibABI/classTransformations/lib1/l1.kt new file mode 100644 index 00000000000..08dc484467f --- /dev/null +++ b/compiler/testData/klibABI/classTransformations/lib1/l1.kt @@ -0,0 +1,143 @@ +class ClassToEnum { + class Foo + object Bar + inner class Baz +} + +object ObjectToEnum { + class Foo + object Bar +} + +enum class EnumToClass { + Foo, + Bar, + Baz +} + +enum class EnumToObject { + Foo, + Bar +} + +class ClassToObject +object ObjectToClass + +class ClassToInterface + +class NestedObjectToCompanion1 { + object Companion { + fun name() = "NestedObjectToCompanion1.Companion" + override fun toString() = name() + } +} + +class NestedObjectToCompanion2 { + object Foo { + fun name() = "NestedObjectToCompanion2.Foo" + override fun toString() = name() + } +} + +class CompanionToNestedObject1 { + companion object { + fun name() = "CompanionToNestedObject1.Companion" + override fun toString() = name() + } +} + +class CompanionToNestedObject2 { + companion object Foo { + fun name() = "CompanionToNestedObject2.Foo" + override fun toString() = name() + } +} + +class CompanionAndNestedObjectsSwap { + companion object Foo { + fun name() = "Foo" + } + + object Bar { + fun name() = "Bar" + } +} + +class NestedClassContainer { + fun name() = "NestedClassContainer" + + class NestedToInner { + fun name() = "NestedClassContainer.NestedToInner" + override fun toString() = name() + + object Object { + fun name() = "NestedClassContainer.NestedToInner.Object" + override fun toString() = name() + } + + companion object Companion { + fun name() = "NestedClassContainer.NestedToInner.Companion" + override fun toString() = name() + } + + class Nested { + fun name() = "NestedClassContainer.NestedToInner.Nested" + override fun toString() = name() + } + + inner class Inner { + fun name() = this@NestedToInner.name() + ".Inner" + override fun toString() = name() + } + } +} + +class InnerClassContainer { + fun name() = "InnerClassContainer" + + inner class InnerToNested { + fun name() = this@InnerClassContainer.name() + ".InnerToNested" + override fun toString() = name() + + inner class /*object*/ Object { + fun name() = this@InnerToNested.name() + ".Object" + override fun toString() = name() + } + + inner class /*companion object*/ Companion { + fun name() = this@InnerToNested.name() + ".Companion" + override fun toString() = name() + } + + inner class /*class*/ Nested { + fun name() = this@InnerToNested.name() + ".Nested" + override fun toString() = name() + } + + inner class Inner { + fun name() = this@InnerToNested.name() + ".Inner" + override fun toString() = name() + } + } +} + +annotation class AnnotationClassWithChangedParameterType(val x: Int) +annotation class AnnotationClassThatBecomesRegularClass(val x: Int) +annotation class AnnotationClassThatDisappears(val x: Int) +annotation class AnnotationClassWithRenamedParameters(val i: Int, val s: String) +annotation class AnnotationClassWithReorderedParameters(val i: Int, val s: String) +annotation class AnnotationClassWithNewParameter(val i: Int) + +value class ValueToClass(val x: Int) +class ClassToValue(val x: Int) + +data class DataToClass(val x: Int, val y: Int) + +fun interface FunctionalInterfaceToInterface { + fun work() +} + +class ClassToAbstractClass { + var name: String = "Alice" + fun getGreeting() = "Hello, $name!" +} diff --git a/compiler/testData/klibABI/classTransformations/lib1/l1.kt.1 b/compiler/testData/klibABI/classTransformations/lib1/l1.kt.1 new file mode 100644 index 00000000000..16693bfd338 --- /dev/null +++ b/compiler/testData/klibABI/classTransformations/lib1/l1.kt.1 @@ -0,0 +1,143 @@ +enum class ClassToEnum { + Foo, + Bar, + Baz +} + +enum class ObjectToEnum { + Foo, + Bar +} + +class EnumToClass { + class Foo + object Bar + inner class Baz +} + +object EnumToObject { + class Foo + object Bar +} + +object ClassToObject +class ObjectToClass + +interface ClassToInterface + +class NestedObjectToCompanion1 { + companion object { + fun name() = "NestedObjectToCompanion1.Companion" + override fun toString() = name() + } +} + +class NestedObjectToCompanion2 { + companion object Foo { + fun name() = "NestedObjectToCompanion2.Foo" + override fun toString() = name() + } +} + +class CompanionToNestedObject1 { + object Companion { + fun name() = "CompanionToNestedObject1.Companion" + override fun toString() = name() + } +} + +class CompanionToNestedObject2 { + object Foo { + fun name() = "CompanionToNestedObject2.Foo" + override fun toString() = name() + } +} + +class CompanionAndNestedObjectsSwap { + object Foo { + fun name() = "Foo" + } + + companion object Bar { + fun name() = "Bar" + } +} + +class NestedClassContainer { + fun name() = "NestedClassContainer" + + inner class NestedToInner { + fun name() = this@NestedClassContainer.name() + ".NestedToInner" + override fun toString() = name() + + inner class /*object*/ Object { + fun name() = this@NestedToInner.name() + ".Object" + override fun toString() = name() + } + + inner class /*companion object*/ Companion { + fun name() = this@NestedToInner.name() + ".Companion" + override fun toString() = name() + } + + inner class /*class*/ Nested { + fun name() = this@NestedToInner.name() + ".Nested" + override fun toString() = name() + } + + inner class Inner { + fun name() = this@NestedToInner.name() + ".Inner" + override fun toString() = name() + } + } +} + +class InnerClassContainer { + fun name() = "InnerClassContainer" + + class InnerToNested { + fun name() = "InnerClassContainer.InnerToNested" + override fun toString() = name() + + object Object { + fun name() = "InnerClassContainer.InnerToNested.Companion" + override fun toString() = name() + } + + companion object Companion { + fun name() = "InnerClassContainer.InnerToNested.Companion" + override fun toString() = name() + } + + class Nested { + fun name() = "InnerClassContainer.InnerToNested.Nested" + override fun toString() = name() + } + + inner class Inner { + fun name() = this@InnerToNested.name() + ".Inner" + override fun toString() = name() + } + } +} + +annotation class AnnotationClassWithChangedParameterType(val x: /*Int*/ String) +/*annotation*/ class AnnotationClassThatBecomesRegularClass(val x: Int) { override fun toString() = "AnnotationClassThatBecomesRegularClass[x=$x]" } +//annotation class AnnotationClassThatDisappears(val x: Int) +annotation class AnnotationClassWithRenamedParameters(val xi: Int, val xs: String) +annotation class AnnotationClassWithReorderedParameters(val s: String, val i: Int) +annotation class AnnotationClassWithNewParameter(val i: Int, val s: String = "Apple") + +class ValueToClass(val x: Int) +value class ClassToValue(val x: Int) + +/*data*/ class DataToClass(val x: Int, val y: Int) + +/*fun*/ interface FunctionalInterfaceToInterface { + fun work() +} + +abstract class ClassToAbstractClass { + abstract var name: String + fun getGreeting() = "Hello, $name!" +} diff --git a/compiler/testData/klibABI/removeClassAsSuperTypeArgument/lib1/module.info b/compiler/testData/klibABI/classTransformations/lib1/module.info similarity index 100% rename from compiler/testData/klibABI/removeClassAsSuperTypeArgument/lib1/module.info rename to compiler/testData/klibABI/classTransformations/lib1/module.info diff --git a/compiler/testData/klibABI/classTransformations/lib2/l2.kt b/compiler/testData/klibABI/classTransformations/lib2/l2.kt new file mode 100644 index 00000000000..3f678f017ad --- /dev/null +++ b/compiler/testData/klibABI/classTransformations/lib2/l2.kt @@ -0,0 +1,222 @@ +fun getClassToEnumFoo(): ClassToEnum.Foo = ClassToEnum.Foo() +inline fun getClassToEnumFooInline(): ClassToEnum.Foo = ClassToEnum.Foo() +fun getClassToEnumFooAsAny(): Any = ClassToEnum.Foo() +inline fun getClassToEnumFooAsAnyInline(): Any = ClassToEnum.Foo() + +fun getClassToEnumBar(): ClassToEnum.Bar = ClassToEnum.Bar +inline fun getClassToEnumBarInline(): ClassToEnum.Bar = ClassToEnum.Bar +fun getClassToEnumBarAsAny(): Any = ClassToEnum.Bar +inline fun getClassToEnumBarAsAnyInline(): Any = ClassToEnum.Bar + +fun getClassToEnumBaz(): ClassToEnum.Baz = ClassToEnum().Baz() +inline fun getClassToEnumBazInline(): ClassToEnum.Baz = ClassToEnum().Baz() +fun getClassToEnumBazAsAny(): Any = ClassToEnum().Baz() +inline fun getClassToEnumBazAsAnyInline(): Any = ClassToEnum().Baz() + +fun getObjectToEnumFoo(): ObjectToEnum.Foo = ObjectToEnum.Foo() +inline fun getObjectToEnumFooInline(): ObjectToEnum.Foo = ObjectToEnum.Foo() +fun getObjectToEnumFooAsAny(): Any = ObjectToEnum.Foo() +inline fun getObjectToEnumFooAsAnyInline(): Any = ObjectToEnum.Foo() + +fun getObjectToEnumBar(): ObjectToEnum.Bar = ObjectToEnum.Bar +inline fun getObjectToEnumBarInline(): ObjectToEnum.Bar = ObjectToEnum.Bar +fun getObjectToEnumBarAsAny(): Any = ObjectToEnum.Bar +inline fun getObjectToEnumBarAsAnyInline(): Any = ObjectToEnum.Bar + +fun getEnumToClassFoo(): EnumToClass = EnumToClass.Foo +inline fun getEnumToClassFooInline(): EnumToClass = EnumToClass.Foo +fun getEnumToClassFooAsAny(): Any = EnumToClass.Foo +inline fun getEnumToClassFooAsAnyInline(): Any = EnumToClass.Foo + +fun getEnumToClassBar(): EnumToClass = EnumToClass.Bar +inline fun getEnumToClassBarInline(): EnumToClass = EnumToClass.Bar +fun getEnumToClassBarAsAny(): Any = EnumToClass.Bar +inline fun getEnumToClassBarAsAnyInline(): Any = EnumToClass.Bar + +fun getEnumToClassBaz(): EnumToClass = EnumToClass.Baz +inline fun getEnumToClassBazInline(): EnumToClass = EnumToClass.Baz +fun getEnumToClassBazAsAny(): Any = EnumToClass.Baz +inline fun getEnumToClassBazAsAnyInline(): Any = EnumToClass.Baz + +fun getEnumToObjectFoo(): EnumToObject = EnumToObject.Foo +inline fun getEnumToObjectFooInline(): EnumToObject = EnumToObject.Foo +fun getEnumToObjectFooAsAny(): Any = EnumToObject.Foo +inline fun getEnumToObjectFooAsAnyInline(): Any = EnumToObject.Foo + +fun getEnumToObjectBar(): EnumToObject = EnumToObject.Bar +inline fun getEnumToObjectBarInline(): EnumToObject = EnumToObject.Bar +fun getEnumToObjectBarAsAny(): Any = EnumToObject.Bar +inline fun getEnumToObjectBarAsAnyInline(): Any = EnumToObject.Bar + +fun getClassToObject(): ClassToObject = ClassToObject() +inline fun getClassToObjectInline(): ClassToObject = ClassToObject() +fun getClassToObjectAsAny(): Any = ClassToObject() +inline fun getClassToObjectAsAnyInline(): Any = ClassToObject() + +fun getObjectToClass(): ObjectToClass = ObjectToClass +inline fun getObjectToClassInline(): ObjectToClass = ObjectToClass +fun getObjectToClassAsAny(): Any = ObjectToClass +inline fun getObjectToClassAsAnyInline(): Any = ObjectToClass + +fun getClassToInterface(): ClassToInterface = ClassToInterface() +inline fun getClassToInterfaceInline(): ClassToInterface = ClassToInterface() +fun getClassToInterfaceAsAny(): Any = ClassToInterface() +inline fun getClassToInterfaceAsAnyInline(): Any = ClassToInterface() + +fun getNestedObjectToCompanion1(): NestedObjectToCompanion1.Companion = NestedObjectToCompanion1.Companion +inline fun getNestedObjectToCompanion1Inline(): NestedObjectToCompanion1.Companion = NestedObjectToCompanion1.Companion +fun getNestedObjectToCompanion1AsAny(): Any = NestedObjectToCompanion1.Companion +inline fun getNestedObjectToCompanion1AsAnyInline(): Any = NestedObjectToCompanion1.Companion + +fun getNestedObjectToCompanion2(): NestedObjectToCompanion2.Foo = NestedObjectToCompanion2.Foo +inline fun getNestedObjectToCompanion2Inline(): NestedObjectToCompanion2.Foo = NestedObjectToCompanion2.Foo +fun getNestedObjectToCompanion2AsAny(): Any = NestedObjectToCompanion2.Foo +inline fun getNestedObjectToCompanion2AsAnyInline(): Any = NestedObjectToCompanion2.Foo + +fun getCompanionToNestedObject1(): CompanionToNestedObject1.Companion = CompanionToNestedObject1.Companion +inline fun getCompanionToNestedObject1Inline(): CompanionToNestedObject1.Companion = CompanionToNestedObject1.Companion +fun getCompanionToNestedObject1AsAny(): Any = CompanionToNestedObject1.Companion +inline fun getCompanionToNestedObject1AsAnyInline(): Any = CompanionToNestedObject1.Companion +fun getCompanionToNestedObject1Name(): String = CompanionToNestedObject1.Companion.name() +inline fun getCompanionToNestedObject1NameInline(): String = CompanionToNestedObject1.Companion.name() +fun getCompanionToNestedObject1NameShort(): String = CompanionToNestedObject1.name() // "Companion" is omit +inline fun getCompanionToNestedObject1NameShortInline(): String = CompanionToNestedObject1.name() // "Companion" is omit + +fun getCompanionToNestedObject2(): CompanionToNestedObject2.Foo = CompanionToNestedObject2.Foo +inline fun getCompanionToNestedObject2Inline(): CompanionToNestedObject2.Foo = CompanionToNestedObject2.Foo +fun getCompanionToNestedObject2AsAny(): Any = CompanionToNestedObject2.Foo +inline fun getCompanionToNestedObject2AsAnyInline(): Any = CompanionToNestedObject2.Foo +fun getCompanionToNestedObject2Name(): String = CompanionToNestedObject2.Foo.name() +inline fun getCompanionToNestedObject2NameInline(): String = CompanionToNestedObject2.Foo.name() +fun getCompanionToNestedObject2NameShort(): String = CompanionToNestedObject2.name() // "Foo" is omit +inline fun getCompanionToNestedObject2NameShortInline(): String = CompanionToNestedObject2.name() // "Foo" is omit + +fun getCompanionAndNestedObjectsSwap(): String = CompanionAndNestedObjectsSwap.name() // companion object name is omit +inline fun getCompanionAndNestedObjectsSwapInline(): String = CompanionAndNestedObjectsSwap.name() // companion object name is omit + +fun getNestedToInnerName() = NestedClassContainer.NestedToInner().name() +inline fun getNestedToInnerNameInline() = NestedClassContainer.NestedToInner().name() +fun getNestedToInnerObjectName() = NestedClassContainer.NestedToInner.Object.name() +inline fun getNestedToInnerObjectNameInline() = NestedClassContainer.NestedToInner.Object.name() +fun getNestedToInnerCompanionName() = NestedClassContainer.NestedToInner.name() +inline fun getNestedToInnerCompanionNameInline() = NestedClassContainer.NestedToInner.name() +fun getNestedToInnerNestedName() = NestedClassContainer.NestedToInner.Nested().name() +inline fun getNestedToInnerNestedNameInline() = NestedClassContainer.NestedToInner.Nested().name() +fun getNestedToInnerInnerName() = NestedClassContainer.NestedToInner().Inner().name() +inline fun getNestedToInnerInnerNameInline() = NestedClassContainer.NestedToInner().Inner().name() + +fun getInnerToNestedName() = InnerClassContainer().InnerToNested().name() +inline fun getInnerToNestedNameInline() = InnerClassContainer().InnerToNested().name() +fun getInnerToNestedObjectName() = InnerClassContainer().InnerToNested().Object().name() +inline fun getInnerToNestedObjectNameInline() = InnerClassContainer().InnerToNested().Object().name() +fun getInnerToNestedCompanionName() = InnerClassContainer().InnerToNested().Companion().name() +inline fun getInnerToNestedCompanionNameInline() = InnerClassContainer().InnerToNested().Companion().name() +fun getInnerToNestedNestedName() = InnerClassContainer().InnerToNested().Nested().name() +inline fun getInnerToNestedNestedNameInline() = InnerClassContainer().InnerToNested().Nested().name() +fun getInnerToNestedInnerName() = InnerClassContainer().InnerToNested().Inner().name() +inline fun getInnerToNestedInnerNameInline() = InnerClassContainer().InnerToNested().Inner().name() + +annotation class AnnotationClassWithParameterThatBecomesRegularClass(val x: AnnotationClassThatBecomesRegularClass) +annotation class AnnotationClassWithParameterOfParameterThatBecomesRegularClass(val x: AnnotationClassWithParameterThatBecomesRegularClass) +annotation class AnnotationClassWithParameterThatDisappears(val x: AnnotationClassThatDisappears) +annotation class AnnotationClassWithParameterOfParameterThatDisappears(val x: AnnotationClassWithParameterThatDisappears) + +fun getAnnotationClassWithChangedParameterType(): AnnotationClassWithChangedParameterType = AnnotationClassWithChangedParameterType(101) +inline fun getAnnotationClassWithChangedParameterTypeInline(): AnnotationClassWithChangedParameterType = AnnotationClassWithChangedParameterType(102) +fun getAnnotationClassWithChangedParameterTypeAsAny(): Any = AnnotationClassWithChangedParameterType(103) +inline fun getAnnotationClassWithChangedParameterTypeAsAnyInline(): Any = AnnotationClassWithChangedParameterType(104) +fun getAnnotationClassThatBecomesRegularClass(): AnnotationClassThatBecomesRegularClass = AnnotationClassThatBecomesRegularClass(105) +inline fun getAnnotationClassThatBecomesRegularClassInline(): AnnotationClassThatBecomesRegularClass = AnnotationClassThatBecomesRegularClass(106) +fun getAnnotationClassThatBecomesRegularClassAsAny(): Any = AnnotationClassThatBecomesRegularClass(107) +inline fun getAnnotationClassThatBecomesRegularClassAsAnyInline(): Any = AnnotationClassThatBecomesRegularClass(108) +fun getAnnotationClassWithParameterThatBecomesRegularClass(): AnnotationClassWithParameterThatBecomesRegularClass = AnnotationClassWithParameterThatBecomesRegularClass(AnnotationClassThatBecomesRegularClass(109)) +inline fun getAnnotationClassWithParameterThatBecomesRegularClassInline(): AnnotationClassWithParameterThatBecomesRegularClass = AnnotationClassWithParameterThatBecomesRegularClass(AnnotationClassThatBecomesRegularClass(110)) +fun getAnnotationClassWithParameterThatBecomesRegularClassAsAny(): Any = AnnotationClassWithParameterThatBecomesRegularClass(AnnotationClassThatBecomesRegularClass(111)) +inline fun getAnnotationClassWithParameterThatBecomesRegularClassAsAnyInline(): Any = AnnotationClassWithParameterThatBecomesRegularClass(AnnotationClassThatBecomesRegularClass(112)) +fun getAnnotationClassWithParameterOfParameterThatBecomesRegularClass(): AnnotationClassWithParameterOfParameterThatBecomesRegularClass = AnnotationClassWithParameterOfParameterThatBecomesRegularClass(AnnotationClassWithParameterThatBecomesRegularClass(AnnotationClassThatBecomesRegularClass(113))) +inline fun getAnnotationClassWithParameterOfParameterThatBecomesRegularClassInline(): AnnotationClassWithParameterOfParameterThatBecomesRegularClass = AnnotationClassWithParameterOfParameterThatBecomesRegularClass(AnnotationClassWithParameterThatBecomesRegularClass(AnnotationClassThatBecomesRegularClass(114))) +fun getAnnotationClassWithParameterOfParameterThatBecomesRegularClassAsAny(): Any = AnnotationClassWithParameterOfParameterThatBecomesRegularClass(AnnotationClassWithParameterThatBecomesRegularClass(AnnotationClassThatBecomesRegularClass(115))) +inline fun getAnnotationClassWithParameterOfParameterThatBecomesRegularClassAsAnyInline(): Any = AnnotationClassWithParameterOfParameterThatBecomesRegularClass(AnnotationClassWithParameterThatBecomesRegularClass(AnnotationClassThatBecomesRegularClass(116))) +fun getAnnotationClassThatDisappears(): AnnotationClassThatDisappears = AnnotationClassThatDisappears(117) +inline fun getAnnotationClassThatDisappearsInline(): AnnotationClassThatDisappears = AnnotationClassThatDisappears(118) +fun getAnnotationClassThatDisappearsAsAny(): Any = AnnotationClassThatDisappears(119) +inline fun getAnnotationClassThatDisappearsAsAnyInline(): Any = AnnotationClassThatDisappears(120) +fun getAnnotationClassWithParameterThatDisappears(): AnnotationClassWithParameterThatDisappears = AnnotationClassWithParameterThatDisappears(AnnotationClassThatDisappears(121)) +inline fun getAnnotationClassWithParameterThatDisappearsInline(): AnnotationClassWithParameterThatDisappears = AnnotationClassWithParameterThatDisappears(AnnotationClassThatDisappears(122)) +fun getAnnotationClassWithParameterThatDisappearsAsAny(): Any = AnnotationClassWithParameterThatDisappears(AnnotationClassThatDisappears(123)) +inline fun getAnnotationClassWithParameterThatDisappearsAsAnyInline(): Any = AnnotationClassWithParameterThatDisappears(AnnotationClassThatDisappears(124)) +fun getAnnotationClassWithParameterOfParameterThatDisappears(): AnnotationClassWithParameterOfParameterThatDisappears = AnnotationClassWithParameterOfParameterThatDisappears(AnnotationClassWithParameterThatDisappears(AnnotationClassThatDisappears(125))) +inline fun getAnnotationClassWithParameterOfParameterThatDisappearsInline(): AnnotationClassWithParameterOfParameterThatDisappears = AnnotationClassWithParameterOfParameterThatDisappears(AnnotationClassWithParameterThatDisappears(AnnotationClassThatDisappears(126))) +fun getAnnotationClassWithParameterOfParameterThatDisappearsAsAny(): Any = AnnotationClassWithParameterOfParameterThatDisappears(AnnotationClassWithParameterThatDisappears(AnnotationClassThatDisappears(127))) +inline fun getAnnotationClassWithParameterOfParameterThatDisappearsAsAnyInline(): Any = AnnotationClassWithParameterOfParameterThatDisappears(AnnotationClassWithParameterThatDisappears(AnnotationClassThatDisappears(128))) +fun getAnnotationClassWithRenamedParameters(): AnnotationClassWithRenamedParameters = AnnotationClassWithRenamedParameters(129, "Banana") +inline fun getAnnotationClassWithRenamedParametersInline(): AnnotationClassWithRenamedParameters = AnnotationClassWithRenamedParameters(130, "Pear") +fun getAnnotationClassWithRenamedParametersAsAny(): Any = AnnotationClassWithRenamedParameters(131, "Orange") +inline fun getAnnotationClassWithRenamedParametersAsAnyInline(): Any = AnnotationClassWithRenamedParameters(132, "Peach") +fun getAnnotationClassWithReorderedParameters(): AnnotationClassWithReorderedParameters = AnnotationClassWithReorderedParameters(133, "Kiwi") +inline fun getAnnotationClassWithReorderedParametersInline(): AnnotationClassWithReorderedParameters = AnnotationClassWithReorderedParameters(134, "Watermelon") +fun getAnnotationClassWithReorderedParametersAsAny(): Any = AnnotationClassWithReorderedParameters(135, "Grapefruit") +inline fun getAnnotationClassWithReorderedParametersAsAnyInline(): Any = AnnotationClassWithReorderedParameters(136, "Melon") +fun getAnnotationClassWithNewParameter(): AnnotationClassWithNewParameter = AnnotationClassWithNewParameter(137) +inline fun getAnnotationClassWithNewParameterInline(): AnnotationClassWithNewParameter = AnnotationClassWithNewParameter(138) +fun getAnnotationClassWithNewParameterAsAny(): Any = AnnotationClassWithNewParameter(139) +inline fun getAnnotationClassWithNewParameterAsAnyInline(): Any = AnnotationClassWithNewParameter(140) + +@AnnotationClassWithChangedParameterType(1) class HolderOfAnnotationClassWithChangedParameterType { override fun toString() = "HolderOfAnnotationClassWithChangedParameterType" } +@AnnotationClassThatBecomesRegularClass(2) class HolderOfAnnotationClassThatBecomesRegularClass { override fun toString() = "HolderOfAnnotationClassThatBecomesRegularClass" } +@AnnotationClassWithParameterThatBecomesRegularClass(AnnotationClassThatBecomesRegularClass(3)) class HolderOfAnnotationClassWithParameterThatBecomesRegularClass { override fun toString() = "HolderOfAnnotationClassWithParameterThatBecomesRegularClass" } +@AnnotationClassWithParameterOfParameterThatBecomesRegularClass(AnnotationClassWithParameterThatBecomesRegularClass(AnnotationClassThatBecomesRegularClass(4))) class HolderOfAnnotationClassWithParameterOfParameterThatBecomesRegularClass { override fun toString() = "HolderOfAnnotationClassWithParameterOfParameterThatBecomesRegularClass" } +@AnnotationClassThatDisappears(5) class HolderOfAnnotationClassThatDisappears { override fun toString() = "HolderOfAnnotationClassThatDisappears" } +@AnnotationClassWithParameterThatDisappears(AnnotationClassThatDisappears(6)) class HolderOfAnnotationClassWithParameterThatDisappears { override fun toString() = "HolderOfAnnotationClassWithParameterThatDisappears" } +@AnnotationClassWithParameterOfParameterThatDisappears(AnnotationClassWithParameterThatDisappears(AnnotationClassThatDisappears(7))) class HolderOfAnnotationClassWithParameterOfParameterThatDisappears { override fun toString() = "HolderOfAnnotationClassWithParameterOfParameterThatDisappears" } +@AnnotationClassWithRenamedParameters(8, "Grape") class HolderOfAnnotationClassWithRenamedParameters { override fun toString() = "HolderOfAnnotationClassWithRenamedParameters" } +@AnnotationClassWithReorderedParameters(9, "Figs") class HolderOfAnnotationClassWithReorderedParameters { override fun toString() = "HolderOfAnnotationClassWithReorderedParameters" } +@AnnotationClassWithNewParameter(10) class HolderOfAnnotationClassWithNewParameter { override fun toString() = "HolderOfAnnotationClassWithNewParameter" } + +fun getHolderOfAnnotationClassWithChangedParameterType() = HolderOfAnnotationClassWithChangedParameterType() +inline fun getHolderOfAnnotationClassWithChangedParameterTypeInline() = HolderOfAnnotationClassWithChangedParameterType() +fun getHolderOfAnnotationClassThatBecomesRegularClass() = HolderOfAnnotationClassThatBecomesRegularClass() +inline fun getHolderOfAnnotationClassThatBecomesRegularClassInline() = HolderOfAnnotationClassThatBecomesRegularClass() +fun getHolderOfAnnotationClassWithParameterThatBecomesRegularClass() = HolderOfAnnotationClassWithParameterThatBecomesRegularClass() +inline fun getHolderOfAnnotationClassWithParameterThatBecomesRegularClassInline() = HolderOfAnnotationClassWithParameterThatBecomesRegularClass() +fun getHolderOfAnnotationClassWithParameterOfParameterThatBecomesRegularClass() = HolderOfAnnotationClassWithParameterOfParameterThatBecomesRegularClass() +inline fun getHolderOfAnnotationClassWithParameterOfParameterThatBecomesRegularClassInline() = HolderOfAnnotationClassWithParameterOfParameterThatBecomesRegularClass() +fun getHolderOfAnnotationClassThatDisappears() = HolderOfAnnotationClassThatDisappears() +inline fun getHolderOfAnnotationClassThatDisappearsInline() = HolderOfAnnotationClassThatDisappears() +fun getHolderOfAnnotationClassWithParameterThatDisappears() = HolderOfAnnotationClassWithParameterThatDisappears() +inline fun getHolderOfAnnotationClassWithParameterThatDisappearsInline() = HolderOfAnnotationClassWithParameterThatDisappears() +fun getHolderOfAnnotationClassWithParameterOfParameterThatDisappears() = HolderOfAnnotationClassWithParameterOfParameterThatDisappears() +inline fun getHolderOfAnnotationClassWithParameterOfParameterThatDisappearsInline() = HolderOfAnnotationClassWithParameterOfParameterThatDisappears() +fun getHolderOfAnnotationClassWithRenamedParameters() = HolderOfAnnotationClassWithRenamedParameters() +inline fun getHolderOfAnnotationClassWithRenamedParametersInline() = HolderOfAnnotationClassWithRenamedParameters() +fun getHolderOfAnnotationClassWithReorderedParameters() = HolderOfAnnotationClassWithReorderedParameters() +inline fun getHolderOfAnnotationClassWithReorderedParametersInline() = HolderOfAnnotationClassWithReorderedParameters() +fun getHolderOfAnnotationClassWithNewParameter() = HolderOfAnnotationClassWithNewParameter() +inline fun getHolderOfAnnotationClassWithNewParameterInline() = HolderOfAnnotationClassWithNewParameter() + +fun getValueToClass(): ValueToClass = ValueToClass(1) +inline fun getValueToClassInline(): ValueToClass = ValueToClass(2) +fun getValueToClassAsAny(): Any = ValueToClass(3) +inline fun getValueToClassAsAnyInline(): Any = ValueToClass(4) + +fun getClassToValue(): ClassToValue = ClassToValue(1) +inline fun getClassToValueInline(): ClassToValue = ClassToValue(2) +fun getClassToValueAsAny(): Any = ClassToValue(3) +inline fun getClassToValueAsAnyInline(): Any = ClassToValue(4) + +fun getSumFromDataClass(): Int { + val (x, y) = DataToClass(1, 2) + return x + y +} + +fun getFunctionalInterfaceToInterface(): FunctionalInterfaceToInterface { + val worker = FunctionalInterfaceToInterface { /* do some work */ } + worker.work() + return worker +} + +fun instantiationOfAbstractClass() { + // Accessing uninitialized members of abstract class is an UB. We shall not allow instantiating + // abstract classes except for from their direct inheritors. + ClassToAbstractClass().getGreeting() +} diff --git a/compiler/testData/klibABI/nonAbstractPropertyInInterfaceBecomesAbstract/lib2/module.info b/compiler/testData/klibABI/classTransformations/lib2/module.info similarity index 100% rename from compiler/testData/klibABI/nonAbstractPropertyInInterfaceBecomesAbstract/lib2/module.info rename to compiler/testData/klibABI/classTransformations/lib2/module.info diff --git a/compiler/testData/klibABI/classTransformations/main/m.kt b/compiler/testData/klibABI/classTransformations/main/m.kt new file mode 100644 index 00000000000..7e039d023a5 --- /dev/null +++ b/compiler/testData/klibABI/classTransformations/main/m.kt @@ -0,0 +1,210 @@ +import abitestutils.abiTest +import abitestutils.TestMode.NATIVE_CACHE_STATIC_EVERYWHERE + +fun box() = abiTest { + /** + * `fun foo(): A.B`: In older version of the library `A` and `B` were classes. In newer version `B` is an entry of enum `A`. + * + * When no lazy IR is used, [IrCall.symbol.owner] is a function (most likely [IrFunctionImpl]) which has the stub [IrClass] (the one + * generated by [MissingDeclarationStubGenerator]) with "/A.B|null[0]" signature in the return type. So the function is formally + * detected as "referecing an unbound CLASS symbol" and the appropriate error message is constructed. + * + * When lazy IR is used, [IrCall.symbol.owner] is a lazy-IR function with the return type holding the lazy-IR class + * generated from [EnumEntrySyntheticClassDescriptor] for the enum entry and having a different signature: "/A.B.|null[0]". + * This class is not detected as unbound, and the whole function is not considered as partially linked. But the [IrCall] + * still has its own expression type recorded that is deserialized without lazy-IR-distortion, so the [IrCall] expression + * is detected as "using an unbound CLASS symbol" with "/A.B|null[0]" signature. + * + * The [adjustForLazyIr] function is used to adjust tested error messages depending on whether lazy IR is used or not. + */ + fun adjustForLazyIr(declaration: String) = if (testMode == NATIVE_CACHE_STATIC_EVERYWHERE) "Expression" else declaration + + expectFailure(linkage("Function 'getClassToEnumFoo' can not be called: ${adjustForLazyIr("Function")} uses unlinked class symbol '/ClassToEnum.Foo'")) { getClassToEnumFoo() } + expectFailure(linkage("Function 'getClassToEnumFooInline' can not be called: ${adjustForLazyIr("Function")} uses unlinked class symbol '/ClassToEnum.Foo'")) { getClassToEnumFooInline() } + expectFailure(linkage("Constructor 'Foo.' can not be called: No constructor found for symbol '/ClassToEnum.Foo.'")) { getClassToEnumFooAsAny() } + expectFailure(linkage("Constructor 'Foo.' can not be called: No constructor found for symbol '/ClassToEnum.Foo.'")) { getClassToEnumFooAsAnyInline() } + expectFailure(linkage("Function 'getClassToEnumBar' can not be called: ${adjustForLazyIr("Function")} uses unlinked class symbol '/ClassToEnum.Bar'")) { getClassToEnumBar() } + expectFailure(linkage("Function 'getClassToEnumBarInline' can not be called: ${adjustForLazyIr("Function")} uses unlinked class symbol '/ClassToEnum.Bar'")) { getClassToEnumBarInline() } + expectFailure(linkage("Can not get instance of singleton 'Bar': No class found for symbol '/ClassToEnum.Bar'")) { getClassToEnumBarAsAny() } + expectFailure(linkage("Can not get instance of singleton 'Bar': No class found for symbol '/ClassToEnum.Bar'")) { getClassToEnumBarAsAnyInline() } + expectFailure(linkage("Function 'getClassToEnumBaz' can not be called: ${adjustForLazyIr("Function")} uses unlinked class symbol '/ClassToEnum.Baz'")) { getClassToEnumBaz() } + expectFailure(linkage("Function 'getClassToEnumBazInline' can not be called: ${adjustForLazyIr("Function")} uses unlinked class symbol '/ClassToEnum.Baz'")) { getClassToEnumBazInline() } + expectFailure(linkage("Constructor 'ClassToEnum.' can not be called: Private constructor declared in module can not be accessed in module ")) { getClassToEnumBazAsAny() } + expectFailure(linkage("Constructor 'ClassToEnum.' can not be called: Private constructor declared in module can not be accessed in module ")) { getClassToEnumBazAsAnyInline() } + + expectFailure(linkage("Function 'getObjectToEnumFoo' can not be called: ${adjustForLazyIr("Function")} uses unlinked class symbol '/ObjectToEnum.Foo'")) { getObjectToEnumFoo() } + expectFailure(linkage("Function 'getObjectToEnumFooInline' can not be called: ${adjustForLazyIr("Function")} uses unlinked class symbol '/ObjectToEnum.Foo'")) { getObjectToEnumFooInline() } + expectFailure(linkage("Constructor 'Foo.' can not be called: No constructor found for symbol '/ObjectToEnum.Foo.'")) { getObjectToEnumFooAsAny() } + expectFailure(linkage("Constructor 'Foo.' can not be called: No constructor found for symbol '/ObjectToEnum.Foo.'")) { getObjectToEnumFooAsAnyInline() } + expectFailure(linkage("Function 'getObjectToEnumBar' can not be called: ${adjustForLazyIr("Function")} uses unlinked class symbol '/ObjectToEnum.Bar'")) { getObjectToEnumBar() } + expectFailure(linkage("Function 'getObjectToEnumBarInline' can not be called: ${adjustForLazyIr("Function")} uses unlinked class symbol '/ObjectToEnum.Bar'")) { getObjectToEnumBarInline() } + expectFailure(linkage("Can not get instance of singleton 'Bar': No class found for symbol '/ObjectToEnum.Bar'")) { getObjectToEnumBarAsAny() } + expectFailure(linkage("Can not get instance of singleton 'Bar': No class found for symbol '/ObjectToEnum.Bar'")) { getObjectToEnumBarAsAnyInline() } + + expectFailure(linkage("Can not get instance of singleton 'EnumToClass.Foo': No enum entry found for symbol '/EnumToClass.Foo'")) { getEnumToClassFoo() } + expectFailure(linkage("Can not get instance of singleton 'EnumToClass.Foo': No enum entry found for symbol '/EnumToClass.Foo'")) { getEnumToClassFooInline() } + expectFailure(linkage("Can not get instance of singleton 'EnumToClass.Foo': No enum entry found for symbol '/EnumToClass.Foo'")) { getEnumToClassFooAsAny() } + expectFailure(linkage("Can not get instance of singleton 'EnumToClass.Foo': No enum entry found for symbol '/EnumToClass.Foo'")) { getEnumToClassFooAsAnyInline() } + expectFailure(linkage("Can not get instance of singleton 'EnumToClass.Bar': No enum entry found for symbol '/EnumToClass.Bar'")) { getEnumToClassBar() } + expectFailure(linkage("Can not get instance of singleton 'EnumToClass.Bar': No enum entry found for symbol '/EnumToClass.Bar'")) { getEnumToClassBarInline() } + expectFailure(linkage("Can not get instance of singleton 'EnumToClass.Bar': No enum entry found for symbol '/EnumToClass.Bar'")) { getEnumToClassBarAsAny() } + expectFailure(linkage("Can not get instance of singleton 'EnumToClass.Bar': No enum entry found for symbol '/EnumToClass.Bar'")) { getEnumToClassBarAsAnyInline() } + expectFailure(linkage("Can not get instance of singleton 'EnumToClass.Baz': No enum entry found for symbol '/EnumToClass.Baz'")) { getEnumToClassBaz() } + expectFailure(linkage("Can not get instance of singleton 'EnumToClass.Baz': No enum entry found for symbol '/EnumToClass.Baz'")) { getEnumToClassBazInline() } + expectFailure(linkage("Can not get instance of singleton 'EnumToClass.Baz': No enum entry found for symbol '/EnumToClass.Baz'")) { getEnumToClassBazAsAny() } + expectFailure(linkage("Can not get instance of singleton 'EnumToClass.Baz': No enum entry found for symbol '/EnumToClass.Baz'")) { getEnumToClassBazAsAnyInline() } + + expectFailure(linkage("Can not get instance of singleton 'EnumToObject.Foo': No enum entry found for symbol '/EnumToObject.Foo'")) { getEnumToObjectFoo() } + expectFailure(linkage("Can not get instance of singleton 'EnumToObject.Foo': No enum entry found for symbol '/EnumToObject.Foo'")) { getEnumToObjectFooInline() } + expectFailure(linkage("Can not get instance of singleton 'EnumToObject.Foo': No enum entry found for symbol '/EnumToObject.Foo'")) { getEnumToObjectFooAsAny() } + expectFailure(linkage("Can not get instance of singleton 'EnumToObject.Foo': No enum entry found for symbol '/EnumToObject.Foo'")) { getEnumToObjectFooAsAnyInline() } + expectFailure(linkage("Can not get instance of singleton 'EnumToObject.Bar': No enum entry found for symbol '/EnumToObject.Bar'")) { getEnumToObjectBar() } + expectFailure(linkage("Can not get instance of singleton 'EnumToObject.Bar': No enum entry found for symbol '/EnumToObject.Bar'")) { getEnumToObjectBarInline() } + expectFailure(linkage("Can not get instance of singleton 'EnumToObject.Bar': No enum entry found for symbol '/EnumToObject.Bar'")) { getEnumToObjectBarAsAny() } + expectFailure(linkage("Can not get instance of singleton 'EnumToObject.Bar': No enum entry found for symbol '/EnumToObject.Bar'")) { getEnumToObjectBarAsAnyInline() } + + expectFailure(linkage("Constructor 'ClassToObject.' can not be called: Private constructor declared in module can not be accessed in module ")) { getClassToObject() } + expectFailure(linkage("Constructor 'ClassToObject.' can not be called: Private constructor declared in module can not be accessed in module ")) { getClassToObjectInline() } + expectFailure(linkage("Constructor 'ClassToObject.' can not be called: Private constructor declared in module can not be accessed in module ")) { getClassToObjectAsAny() } + expectFailure(linkage("Constructor 'ClassToObject.' can not be called: Private constructor declared in module can not be accessed in module ")) { getClassToObjectAsAnyInline() } + + expectFailure(linkage("Can not get instance of singleton 'ObjectToClass': 'ObjectToClass' is class while object is expected")) { getObjectToClass() } + expectFailure(linkage("Can not get instance of singleton 'ObjectToClass': 'ObjectToClass' is class while object is expected")) { getObjectToClassInline() } + expectFailure(linkage("Can not get instance of singleton 'ObjectToClass': 'ObjectToClass' is class while object is expected")) { getObjectToClassAsAny() } + expectFailure(linkage("Can not get instance of singleton 'ObjectToClass': 'ObjectToClass' is class while object is expected")) { getObjectToClassAsAnyInline() } + + expectFailure(linkage("Constructor 'ClassToInterface.' can not be called: No constructor found for symbol '/ClassToInterface.'")) { getClassToInterface() } + expectFailure(linkage("Constructor 'ClassToInterface.' can not be called: No constructor found for symbol '/ClassToInterface.'")) { getClassToInterfaceInline() } + expectFailure(linkage("Constructor 'ClassToInterface.' can not be called: No constructor found for symbol '/ClassToInterface.'")) { getClassToInterfaceAsAny() } + expectFailure(linkage("Constructor 'ClassToInterface.' can not be called: No constructor found for symbol '/ClassToInterface.'")) { getClassToInterfaceAsAnyInline() } + + expectSuccess("NestedObjectToCompanion1.Companion") { getNestedObjectToCompanion1().toString() } + expectSuccess("NestedObjectToCompanion1.Companion") { getNestedObjectToCompanion1Inline().toString() } + expectSuccess("NestedObjectToCompanion1.Companion") { getNestedObjectToCompanion1AsAny().toString() } + expectSuccess("NestedObjectToCompanion1.Companion") { getNestedObjectToCompanion1AsAnyInline().toString() } + + expectSuccess("NestedObjectToCompanion2.Foo") { getNestedObjectToCompanion2().toString() } + expectSuccess("NestedObjectToCompanion2.Foo") { getNestedObjectToCompanion2Inline().toString() } + expectSuccess("NestedObjectToCompanion2.Foo") { getNestedObjectToCompanion2AsAny().toString() } + expectSuccess("NestedObjectToCompanion2.Foo") { getNestedObjectToCompanion2AsAnyInline().toString() } + + expectSuccess("CompanionToNestedObject1.Companion") { getCompanionToNestedObject1().toString() } + expectSuccess("CompanionToNestedObject1.Companion") { getCompanionToNestedObject1Inline().toString() } + expectSuccess("CompanionToNestedObject1.Companion") { getCompanionToNestedObject1AsAny().toString() } + expectSuccess("CompanionToNestedObject1.Companion") { getCompanionToNestedObject1AsAnyInline().toString() } + expectSuccess("CompanionToNestedObject1.Companion") { getCompanionToNestedObject1Name() } + expectSuccess("CompanionToNestedObject1.Companion") { getCompanionToNestedObject1NameShort() } + expectSuccess("CompanionToNestedObject1.Companion") { getCompanionToNestedObject1NameInline() } + expectSuccess("CompanionToNestedObject1.Companion") { getCompanionToNestedObject1NameShortInline() } + + expectSuccess("CompanionToNestedObject2.Foo") { getCompanionToNestedObject2().toString() } + expectSuccess("CompanionToNestedObject2.Foo") { getCompanionToNestedObject2Inline().toString() } + expectSuccess("CompanionToNestedObject2.Foo") { getCompanionToNestedObject2AsAny().toString() } + expectSuccess("CompanionToNestedObject2.Foo") { getCompanionToNestedObject2AsAnyInline().toString() } + expectSuccess("CompanionToNestedObject2.Foo") { getCompanionToNestedObject2Name() } + expectSuccess("CompanionToNestedObject2.Foo") { getCompanionToNestedObject2NameShort() } + expectSuccess("CompanionToNestedObject2.Foo") { getCompanionToNestedObject2NameInline() } + expectSuccess("CompanionToNestedObject2.Foo") { getCompanionToNestedObject2NameShortInline() } + + expectSuccess("Foo") { getCompanionAndNestedObjectsSwap() } + expectSuccess("Foo") { getCompanionAndNestedObjectsSwapInline() } + + expectFailure(linkage("Constructor 'NestedToInner.' can not be called: The call site does not provide a dispatch receiver parameter 'this' that the constructor requires")) { getNestedToInnerName() } + expectFailure(linkage("Constructor 'NestedToInner.' can not be called: The call site does not provide a dispatch receiver parameter 'this' that the constructor requires")) { getNestedToInnerNameInline() } + expectFailure(linkage("Can not get instance of singleton 'Object': 'Object' is inner class while object is expected")) { getNestedToInnerObjectName() } + expectFailure(linkage("Can not get instance of singleton 'Object': 'Object' is inner class while object is expected")) { getNestedToInnerObjectNameInline() } + expectFailure(linkage("Can not get instance of singleton 'Companion': 'Companion' is inner class while object is expected")) { getNestedToInnerCompanionName() } + expectFailure(linkage("Can not get instance of singleton 'Companion': 'Companion' is inner class while object is expected")) { getNestedToInnerCompanionNameInline() } + expectFailure(linkage("Constructor 'Nested.' can not be called: The call site does not provide a dispatch receiver parameter 'this' that the constructor requires")) { getNestedToInnerNestedName() } + expectFailure(linkage("Constructor 'Nested.' can not be called: The call site does not provide a dispatch receiver parameter 'this' that the constructor requires")) { getNestedToInnerNestedNameInline() } + expectFailure(linkage("Constructor 'NestedToInner.' can not be called: The call site does not provide a dispatch receiver parameter 'this' that the constructor requires")) { getNestedToInnerInnerName() } + expectFailure(linkage("Constructor 'NestedToInner.' can not be called: The call site does not provide a dispatch receiver parameter 'this' that the constructor requires")) { getNestedToInnerInnerNameInline() } + + expectFailure(linkage("Constructor 'InnerToNested.' can not be called: The call site provides excessive dispatch receiver parameter 'this' that is not needed for the constructor")) { getInnerToNestedName() } + expectFailure(linkage("Constructor 'InnerToNested.' can not be called: The call site provides excessive dispatch receiver parameter 'this' that is not needed for the constructor")) { getInnerToNestedNameInline() } + expectFailure(linkage("Constructor 'InnerToNested.' can not be called: The call site provides excessive dispatch receiver parameter 'this' that is not needed for the constructor")) { getInnerToNestedObjectName() } + expectFailure(linkage("Constructor 'InnerToNested.' can not be called: The call site provides excessive dispatch receiver parameter 'this' that is not needed for the constructor")) { getInnerToNestedObjectNameInline() } + expectFailure(linkage("Constructor 'InnerToNested.' can not be called: The call site provides excessive dispatch receiver parameter 'this' that is not needed for the constructor")) { getInnerToNestedCompanionName() } + expectFailure(linkage("Constructor 'InnerToNested.' can not be called: The call site provides excessive dispatch receiver parameter 'this' that is not needed for the constructor")) { getInnerToNestedCompanionNameInline() } + expectFailure(linkage("Constructor 'InnerToNested.' can not be called: The call site provides excessive dispatch receiver parameter 'this' that is not needed for the constructor")) { getInnerToNestedNestedName() } + expectFailure(linkage("Constructor 'InnerToNested.' can not be called: The call site provides excessive dispatch receiver parameter 'this' that is not needed for the constructor")) { getInnerToNestedNestedNameInline() } + expectFailure(linkage("Constructor 'InnerToNested.' can not be called: The call site provides excessive dispatch receiver parameter 'this' that is not needed for the constructor")) { getInnerToNestedInnerName() } + expectFailure(linkage("Constructor 'InnerToNested.' can not be called: The call site provides excessive dispatch receiver parameter 'this' that is not needed for the constructor")) { getInnerToNestedInnerNameInline() } + + expectFailure(linkage("Constructor 'AnnotationClassWithChangedParameterType.' can not be called: No constructor found for symbol '/AnnotationClassWithChangedParameterType.'")) { getAnnotationClassWithChangedParameterType() } + expectFailure(linkage("Constructor 'AnnotationClassWithChangedParameterType.' can not be called: No constructor found for symbol '/AnnotationClassWithChangedParameterType.'")) { getAnnotationClassWithChangedParameterTypeInline() } + expectFailure(linkage("Constructor 'AnnotationClassWithChangedParameterType.' can not be called: No constructor found for symbol '/AnnotationClassWithChangedParameterType.'")) { getAnnotationClassWithChangedParameterTypeAsAny() } + expectFailure(linkage("Constructor 'AnnotationClassWithChangedParameterType.' can not be called: No constructor found for symbol '/AnnotationClassWithChangedParameterType.'")) { getAnnotationClassWithChangedParameterTypeAsAnyInline() } + expectSuccess(105) { getAnnotationClassThatBecomesRegularClass().x } + expectSuccess(106) { getAnnotationClassThatBecomesRegularClassInline().x } + expectSuccess("AnnotationClassThatBecomesRegularClass[x=107]") { getAnnotationClassThatBecomesRegularClassAsAny().toString() } + expectSuccess("AnnotationClassThatBecomesRegularClass[x=108]") { getAnnotationClassThatBecomesRegularClassAsAnyInline().toString() } + expectFailure(linkage("Function 'getAnnotationClassWithParameterThatBecomesRegularClass' can not be called: Function uses annotation class 'AnnotationClassWithParameterThatBecomesRegularClass' that has non-annotation class 'AnnotationClassThatBecomesRegularClass' as a parameter")) { getAnnotationClassWithParameterThatBecomesRegularClass().x.x } + expectFailure(linkage("Function 'getAnnotationClassWithParameterThatBecomesRegularClassInline' can not be called: Function uses annotation class 'AnnotationClassWithParameterThatBecomesRegularClass' that has non-annotation class 'AnnotationClassThatBecomesRegularClass' as a parameter")) { getAnnotationClassWithParameterThatBecomesRegularClassInline().x.x } + expectFailure(linkage("Constructor 'AnnotationClassWithParameterThatBecomesRegularClass.' can not be called: Annotation class 'AnnotationClassWithParameterThatBecomesRegularClass' uses non-annotation class 'AnnotationClassThatBecomesRegularClass' as a parameter")) { getAnnotationClassWithParameterThatBecomesRegularClassAsAny().toString() } + expectFailure(linkage("Constructor 'AnnotationClassWithParameterThatBecomesRegularClass.' can not be called: Annotation class 'AnnotationClassWithParameterThatBecomesRegularClass' uses non-annotation class 'AnnotationClassThatBecomesRegularClass' as a parameter")) { getAnnotationClassWithParameterThatBecomesRegularClassAsAnyInline().toString() } + expectFailure(linkage("Function 'getAnnotationClassWithParameterOfParameterThatBecomesRegularClass' can not be called: Function uses annotation class 'AnnotationClassWithParameterThatBecomesRegularClass' (via annotation class 'AnnotationClassWithParameterOfParameterThatBecomesRegularClass') that has non-annotation class 'AnnotationClassThatBecomesRegularClass' as a parameter")) { getAnnotationClassWithParameterOfParameterThatBecomesRegularClass().x.x.x } + expectFailure(linkage("Function 'getAnnotationClassWithParameterOfParameterThatBecomesRegularClassInline' can not be called: Function uses annotation class 'AnnotationClassWithParameterThatBecomesRegularClass' (via annotation class 'AnnotationClassWithParameterOfParameterThatBecomesRegularClass') that has non-annotation class 'AnnotationClassThatBecomesRegularClass' as a parameter")) { getAnnotationClassWithParameterOfParameterThatBecomesRegularClassInline().x.x.x } + expectFailure(linkage("Constructor 'AnnotationClassWithParameterThatBecomesRegularClass.' can not be called: Annotation class 'AnnotationClassWithParameterThatBecomesRegularClass' uses non-annotation class 'AnnotationClassThatBecomesRegularClass' as a parameter")) { getAnnotationClassWithParameterOfParameterThatBecomesRegularClassAsAny().toString() } + expectFailure(linkage("Constructor 'AnnotationClassWithParameterThatBecomesRegularClass.' can not be called: Annotation class 'AnnotationClassWithParameterThatBecomesRegularClass' uses non-annotation class 'AnnotationClassThatBecomesRegularClass' as a parameter")) { getAnnotationClassWithParameterOfParameterThatBecomesRegularClassAsAnyInline().toString() } + expectFailure(linkage("Function 'getAnnotationClassThatDisappears' can not be called: Function uses unlinked class symbol '/AnnotationClassThatDisappears'")) { getAnnotationClassThatDisappears() } + expectFailure(linkage("Function 'getAnnotationClassThatDisappearsInline' can not be called: Function uses unlinked class symbol '/AnnotationClassThatDisappears'")) { getAnnotationClassThatDisappearsInline() } + expectFailure(linkage("Constructor 'AnnotationClassThatDisappears.' can not be called: No constructor found for symbol '/AnnotationClassThatDisappears.'")) { getAnnotationClassThatDisappearsAsAny() } + expectFailure(linkage("Constructor 'AnnotationClassThatDisappears.' can not be called: No constructor found for symbol '/AnnotationClassThatDisappears.'")) { getAnnotationClassThatDisappearsAsAnyInline() } + expectFailure(linkage("Function 'getAnnotationClassWithParameterThatDisappears' can not be called: Function uses unlinked class symbol '/AnnotationClassThatDisappears' (via annotation class 'AnnotationClassWithParameterThatDisappears')")) { getAnnotationClassWithParameterThatDisappears() } + expectFailure(linkage("Function 'getAnnotationClassWithParameterThatDisappearsInline' can not be called: Function uses unlinked class symbol '/AnnotationClassThatDisappears' (via annotation class 'AnnotationClassWithParameterThatDisappears')")) { getAnnotationClassWithParameterThatDisappearsInline() } + expectFailure(linkage("Function 'getAnnotationClassWithParameterOfParameterThatDisappears' can not be called: Function uses unlinked class symbol '/AnnotationClassThatDisappears' (via annotation class 'AnnotationClassWithParameterOfParameterThatDisappears')")) { getAnnotationClassWithParameterOfParameterThatDisappears() } + expectFailure(linkage("Function 'getAnnotationClassWithParameterOfParameterThatDisappearsInline' can not be called: Function uses unlinked class symbol '/AnnotationClassThatDisappears' (via annotation class 'AnnotationClassWithParameterOfParameterThatDisappears')")) { getAnnotationClassWithParameterOfParameterThatDisappearsInline() } + expectFailure(linkage("Constructor 'AnnotationClassThatDisappears.' can not be called: No constructor found for symbol '/AnnotationClassThatDisappears.'")) { getAnnotationClassWithParameterThatDisappearsAsAny() } + expectFailure(linkage("Constructor 'AnnotationClassThatDisappears.' can not be called: No constructor found for symbol '/AnnotationClassThatDisappears.'")) { getAnnotationClassWithParameterThatDisappearsAsAnyInline() } + expectSuccess("@AnnotationClassWithRenamedParameters(xi=129, xs=Banana)") { getAnnotationClassWithRenamedParameters().toString() } + expectSuccess("@AnnotationClassWithRenamedParameters(xi=130, xs=Pear)") { getAnnotationClassWithRenamedParametersInline().toString() } + expectSuccess("@AnnotationClassWithRenamedParameters(xi=131, xs=Orange)") { getAnnotationClassWithRenamedParametersAsAny().toString() } + expectSuccess("@AnnotationClassWithRenamedParameters(xi=132, xs=Peach)") { getAnnotationClassWithRenamedParametersAsAnyInline().toString() } + expectFailure(linkage("Constructor 'AnnotationClassWithReorderedParameters.' can not be called: No constructor found for symbol '/AnnotationClassWithReorderedParameters.'")) { getAnnotationClassWithReorderedParameters() } + expectFailure(linkage("Constructor 'AnnotationClassWithReorderedParameters.' can not be called: No constructor found for symbol '/AnnotationClassWithReorderedParameters.'")) { getAnnotationClassWithReorderedParametersInline() } + expectFailure(linkage("Constructor 'AnnotationClassWithReorderedParameters.' can not be called: No constructor found for symbol '/AnnotationClassWithReorderedParameters.'")) { getAnnotationClassWithReorderedParametersAsAny() } + expectFailure(linkage("Constructor 'AnnotationClassWithReorderedParameters.' can not be called: No constructor found for symbol '/AnnotationClassWithReorderedParameters.'")) { getAnnotationClassWithReorderedParametersAsAnyInline() } + expectFailure(linkage("Constructor 'AnnotationClassWithNewParameter.' can not be called: No constructor found for symbol '/AnnotationClassWithNewParameter.'")) { getAnnotationClassWithNewParameter() } + expectFailure(linkage("Constructor 'AnnotationClassWithNewParameter.' can not be called: No constructor found for symbol '/AnnotationClassWithNewParameter.'")) { getAnnotationClassWithNewParameterInline() } + expectFailure(linkage("Constructor 'AnnotationClassWithNewParameter.' can not be called: No constructor found for symbol '/AnnotationClassWithNewParameter.'")) { getAnnotationClassWithNewParameterAsAny() } + expectFailure(linkage("Constructor 'AnnotationClassWithNewParameter.' can not be called: No constructor found for symbol '/AnnotationClassWithNewParameter.'")) { getAnnotationClassWithNewParameterAsAnyInline() } + + // Handle unlinked constructor call in annotation & non-annotation class appearing in annotation: + expectSuccess("HolderOfAnnotationClassWithChangedParameterType") { getHolderOfAnnotationClassWithChangedParameterType().toString() } + expectSuccess("HolderOfAnnotationClassWithChangedParameterType") { getHolderOfAnnotationClassWithChangedParameterTypeInline().toString() } + expectSuccess("HolderOfAnnotationClassThatBecomesRegularClass") { getHolderOfAnnotationClassThatBecomesRegularClass().toString() } + expectSuccess("HolderOfAnnotationClassThatBecomesRegularClass") { getHolderOfAnnotationClassThatBecomesRegularClassInline().toString() } + expectSuccess("HolderOfAnnotationClassWithParameterThatBecomesRegularClass") { getHolderOfAnnotationClassWithParameterThatBecomesRegularClass().toString() } + expectSuccess("HolderOfAnnotationClassWithParameterThatBecomesRegularClass") { getHolderOfAnnotationClassWithParameterThatBecomesRegularClassInline().toString() } + expectSuccess("HolderOfAnnotationClassWithParameterOfParameterThatBecomesRegularClass") { getHolderOfAnnotationClassWithParameterOfParameterThatBecomesRegularClass().toString() } + expectSuccess("HolderOfAnnotationClassWithParameterOfParameterThatBecomesRegularClass") { getHolderOfAnnotationClassWithParameterOfParameterThatBecomesRegularClassInline().toString() } + expectSuccess("HolderOfAnnotationClassThatDisappears") { getHolderOfAnnotationClassThatDisappears().toString() } + expectSuccess("HolderOfAnnotationClassThatDisappears") { getHolderOfAnnotationClassThatDisappearsInline().toString() } + expectSuccess("HolderOfAnnotationClassWithParameterThatDisappears") { getHolderOfAnnotationClassWithParameterThatDisappears().toString() } + expectSuccess("HolderOfAnnotationClassWithParameterThatDisappears") { getHolderOfAnnotationClassWithParameterThatDisappearsInline().toString() } + expectSuccess("HolderOfAnnotationClassWithParameterOfParameterThatDisappears") { getHolderOfAnnotationClassWithParameterOfParameterThatDisappears().toString() } + expectSuccess("HolderOfAnnotationClassWithParameterOfParameterThatDisappears") { getHolderOfAnnotationClassWithParameterOfParameterThatDisappearsInline().toString() } + expectSuccess("HolderOfAnnotationClassWithRenamedParameters") { getHolderOfAnnotationClassWithRenamedParameters().toString() } + expectSuccess("HolderOfAnnotationClassWithRenamedParameters") { getHolderOfAnnotationClassWithRenamedParametersInline().toString() } + expectSuccess("HolderOfAnnotationClassWithReorderedParameters") { getHolderOfAnnotationClassWithReorderedParameters().toString() } + expectSuccess("HolderOfAnnotationClassWithReorderedParameters") { getHolderOfAnnotationClassWithReorderedParametersInline().toString() } + expectSuccess("HolderOfAnnotationClassWithNewParameter") { getHolderOfAnnotationClassWithNewParameter().toString() } + expectSuccess("HolderOfAnnotationClassWithNewParameter") { getHolderOfAnnotationClassWithNewParameterInline().toString() } + + expectSuccess { getValueToClass(); "OK" } + expectSuccess { getValueToClassInline(); "OK" } + expectSuccess { getValueToClassAsAny(); "OK" } + expectSuccess { getValueToClassAsAnyInline(); "OK" } + + expectSuccess { getClassToValue(); "OK" } + expectSuccess { getClassToValueInline(); "OK" } + expectSuccess { getClassToValueAsAny(); "OK" } + expectSuccess { getClassToValueAsAnyInline(); "OK" } + + expectFailure(linkage("Function 'component1' can not be called: No function found for symbol '/DataToClass.component1'")) { getSumFromDataClass() } + + expectSuccess { getFunctionalInterfaceToInterface(); "OK" } + + expectFailure(linkage("Constructor 'ClassToAbstractClass.' can not be called: Can not instantiate abstract class 'ClassToAbstractClass'")) { instantiationOfAbstractClass() } +} diff --git a/compiler/testData/klibABI/removeClassAsParameterType/main/module.info b/compiler/testData/klibABI/classTransformations/main/module.info similarity index 100% rename from compiler/testData/klibABI/removeClassAsParameterType/main/module.info rename to compiler/testData/klibABI/classTransformations/main/module.info diff --git a/compiler/testData/klibABI/nonAbstractFunctionInInterfaceBecomesAbstract/project.info b/compiler/testData/klibABI/classTransformations/project.info similarity index 100% rename from compiler/testData/klibABI/nonAbstractFunctionInInterfaceBecomesAbstract/project.info rename to compiler/testData/klibABI/classTransformations/project.info diff --git a/compiler/testData/klibABI/functionTransformations/lib1/l1.kt b/compiler/testData/klibABI/functionTransformations/lib1/l1.kt new file mode 100644 index 00000000000..9970010be33 --- /dev/null +++ b/compiler/testData/klibABI/functionTransformations/lib1/l1.kt @@ -0,0 +1,99 @@ +@file:Suppress("RedundantSuspendModifier", "NOTHING_TO_INLINE") + +class Cache { + private val cache = mutableMapOf() + fun load(key: String): String? = cache[key] + fun store(key: String, value: String) { cache[key] = value } + fun dumpToString(): String = cache.entries.sortedBy { it.key }.joinToString(",") { it.key + "=" + it.value } +} + +class OperatorsToNonOperators(private val cache: Cache) { + operator fun get(key: String): String? = cache.load(key) + operator fun set(key: String, value: String) = cache.store(key, value) + operator fun invoke(): String = cache.dumpToString() + + companion object { + operator fun Cache.get(key: String): String? = load(key) + operator fun Cache.set(key: String, value: String) = store(key, value) + operator fun Cache.invoke(): String = dumpToString() + } +} + +class NonOperatorsToOperators(private val cache: Cache) { + fun get(key: String): String? = cache.load(key) + fun set(key: String, value: String) = cache.store(key, value) + fun invoke(): String = cache.dumpToString() + + companion object { + fun Cache.get(key: String): String? = load(key) + fun Cache.set(key: String, value: String) = store(key, value) + fun Cache.invoke(): String = dumpToString() + } +} + +data class Wrapper(private val value: Int) { + private operator fun plus(other: Wrapper): Wrapper = (value + other.value).wrap() + fun unwrap(): Int = value + + fun memberNonInfixToInfix(other: Wrapper): Wrapper = this + other + infix fun memberInfixToNonInfix(other: Wrapper): Wrapper = this + other + + companion object { + fun Wrapper.extensionNonInfixToInfix(other: Wrapper): Wrapper = this + other + infix fun Wrapper.extensionInfixToNonInfix(other: Wrapper): Wrapper = this + other + } +} + +fun Int.wrap(): Wrapper = Wrapper(this) + +object Functions { + fun nonTailrecToTailrec(n: Int, r: Int): Int = if (n <= 1) r else nonTailrecToTailrec(n - 1, n * r) + tailrec fun tailrecToNonTailrec(n: Int, r: Int): Int = if (n <= 1) r else tailrecToNonTailrec(n - 1, n * r) + + @Suppress("RedundantSuspendModifier") suspend fun wrapCoroutine(coroutine: suspend () -> R): R = coroutine.invoke() + suspend fun suspendToNonSuspendFunction(x: Int): Int = wrapCoroutine { -x } + fun nonSuspendToSuspendFunction(x: Int): Int = -x + + inline fun inlineLambdaToNoinlineLambda(x: Int, lambda: (Int) -> String): String = "Functions.inlineLambdaToNoinlineLambda($x) { ${lambda(x * 2)} }" + inline fun inlineLambdaToCrossinlineLambda(x: Int, lambda: (Int) -> String): String = "Functions.inlineLambdaToCrossinlineLambda($x) { ${lambda(x * 2)} }" + + fun removedFirstDefaultValue(a: Int = 42, b: Int): Int = a + b + fun removedVarargFirstDefaultValue(vararg a: Int = intArrayOf(1, 2, 3), b: Int): Int = a.sum() + b + fun removedLastDefaultValue(a: Int, b: Int = 42): Int = a + b + fun removedVarargLastDefaultValue(a: Int, vararg b: Int = intArrayOf(1, 2, 3)): Int = a + b.sum() +} + +class RemovedFirstDefaultValueInConstructor(a: Int = 42, b: Int) { + val value = a + b +} +class RemovedLastDefaultValueInConstructor(a: Int, b: Int = 42) { + val value = a + b +} + +interface Interface { + suspend fun suspendToNonSuspendFunction(x: Int): String + fun nonSuspendToSuspendFunction(x: Int): String +} + +abstract class AbstractClass { + abstract suspend fun suspendToNonSuspendFunction(x: Int): String + abstract fun nonSuspendToSuspendFunction(x: Int): String +} + +open class OpenClass { + open suspend fun suspendToNonSuspendFunction(x: Int): String = Functions.wrapCoroutine { "OpenClass.suspendToNonSuspendFunction($x)" } + open fun nonSuspendToSuspendFunction(x: Int): String = "OpenClass.nonSuspendToSuspendFunction($x)" + + open suspend fun suspendToNonSuspendFunctionWithDelegation(x: Int): String = Functions.wrapCoroutine { "OpenClass.suspendToNonSuspendFunctionWithDelegation($x)" } + open fun nonSuspendToSuspendFunctionWithDelegation(x: Int): String = "OpenClass.nonSuspendToSuspendFunctionWithDelegation($x)" + + open fun openNonInlineToInlineFunction(x: Int): String = "OpenClass.openNonInlineToInlineFunction($x)" + open fun openNonInlineToInlineFunctionWithDelegation(x: Int): String = "OpenClass.openNonInlineToInlineFunctionWithDelegation($x)" + //inline fun newInlineFunction1(x: Int): String = "OpenClass.newInlineFunction1($x)" + //inline fun newInlineFunction2(x: Int): String = "OpenClass.newInlineFunction2($x)" + //fun newNonInlineFunction(x: Int): String = "OpenClass.newNonInlineFunction($x)" + + fun newInlineFunction1Caller(x: Int): String = TODO("Not implemented: OpenClass.newInlineFunction1Caller($x)") + fun newInlineFunction2Caller(x: Int): String = TODO("Not implemented: OpenClass.newInlineFunction2Caller($x)") + fun newNonInlineFunctionCaller(x: Int): String = TODO("Not implemented: OpenClass.newNonInlineFunctionCaller($x)") +} diff --git a/compiler/testData/klibABI/functionTransformations/lib1/l1.kt.1 b/compiler/testData/klibABI/functionTransformations/lib1/l1.kt.1 new file mode 100644 index 00000000000..c4744187a30 --- /dev/null +++ b/compiler/testData/klibABI/functionTransformations/lib1/l1.kt.1 @@ -0,0 +1,99 @@ +@file:Suppress("RedundantSuspendModifier", "NOTHING_TO_INLINE") + +class Cache { + private val cache = mutableMapOf() + fun load(key: String): String? = cache[key] + fun store(key: String, value: String) { cache[key] = value } + fun dumpToString(): String = cache.entries.sortedBy { it.key }.joinToString(",") { it.key + "=" + it.value } +} + +class OperatorsToNonOperators(private val cache: Cache) { + fun get(key: String): String? = cache.load(key) + fun set(key: String, value: String) = cache.store(key, value) + fun invoke(): String = cache.dumpToString() + + companion object { + fun Cache.get(key: String): String? = load(key) + fun Cache.set(key: String, value: String) = store(key, value) + fun Cache.invoke(): String = dumpToString() + } +} + +class NonOperatorsToOperators(private val cache: Cache) { + operator fun get(key: String): String? = cache.load(key) + operator fun set(key: String, value: String) = cache.store(key, value) + operator fun invoke(): String = cache.dumpToString() + + companion object { + operator fun Cache.get(key: String): String? = load(key) + operator fun Cache.set(key: String, value: String) = store(key, value) + operator fun Cache.invoke(): String = dumpToString() + } +} + +data class Wrapper(private val value: Int) { + private operator fun plus(other: Wrapper): Wrapper = (value + other.value).wrap() + fun unwrap(): Int = value + + infix fun memberNonInfixToInfix(other: Wrapper): Wrapper = this + other + fun memberInfixToNonInfix(other: Wrapper): Wrapper = this + other + + companion object { + infix fun Wrapper.extensionNonInfixToInfix(other: Wrapper): Wrapper = this + other + fun Wrapper.extensionInfixToNonInfix(other: Wrapper): Wrapper = this + other + } +} + +fun Int.wrap(): Wrapper = Wrapper(this) + +object Functions { + tailrec fun nonTailrecToTailrec(n: Int, r: Int): Int = if (n <= 1) r else nonTailrecToTailrec(n - 1, n * r) + fun tailrecToNonTailrec(n: Int, r: Int): Int = if (n <= 1) r else tailrecToNonTailrec(n - 1, n * r) + + @Suppress("RedundantSuspendModifier") suspend fun wrapCoroutine(coroutine: suspend () -> R): R = coroutine.invoke() + fun suspendToNonSuspendFunction(x: Int): Int = -x + suspend fun nonSuspendToSuspendFunction(x: Int): Int = wrapCoroutine { -x } + + inline fun inlineLambdaToNoinlineLambda(x: Int, noinline lambda: (Int) -> String): String = "Functions.inlineLambdaToNoinlineLambda($x) { ${lambda(x * 2)} }" + inline fun inlineLambdaToCrossinlineLambda(x: Int, crossinline lambda: (Int) -> String): String = "Functions.inlineLambdaToCrossinlineLambda($x) { ${lambda(x * 2)} }" + + fun removedFirstDefaultValue(a: Int /*= 42*/, b: Int): Int = a + b + fun removedVarargFirstDefaultValue(vararg a: Int /*= intArrayOf(1, 2, 3)*/, b: Int): Int = a.sum() + b + fun removedLastDefaultValue(a: Int, b: Int /*= 42*/): Int = a + b + fun removedVarargLastDefaultValue(a: Int, vararg b: Int /*= intArrayOf(1, 2, 3)*/): Int = a + b.sum() +} + +class RemovedFirstDefaultValueInConstructor(a: Int /*= 42*/, b: Int) { + val value = a + b +} +class RemovedLastDefaultValueInConstructor(a: Int, b: Int /*= 42*/) { + val value = a + b +} + +interface Interface { + fun suspendToNonSuspendFunction(x: Int): String + suspend fun nonSuspendToSuspendFunction(x: Int): String +} + +abstract class AbstractClass { + abstract fun suspendToNonSuspendFunction(x: Int): String + abstract suspend fun nonSuspendToSuspendFunction(x: Int): String +} + +open class OpenClass { + open fun suspendToNonSuspendFunction(x: Int): String = "OpenClassV2.suspendToNonSuspendFunction($x)" + open suspend fun nonSuspendToSuspendFunction(x: Int): String = Functions.wrapCoroutine { "OpenClassV2.nonSuspendToSuspendFunction($x)" } + + open fun suspendToNonSuspendFunctionWithDelegation(x: Int): String = "OpenClassV2.suspendToNonSuspendFunctionWithDelegation($x)" + open suspend fun nonSuspendToSuspendFunctionWithDelegation(x: Int): String = Functions.wrapCoroutine { "OpenClassV2.nonSuspendToSuspendFunctionWithDelegation($x)" } + + inline fun openNonInlineToInlineFunction(x: Int): String = "OpenClassV2.openNonInlineToInlineFunction($x)" + inline fun openNonInlineToInlineFunctionWithDelegation(x: Int): String = "OpenClassV2.openNonInlineToInlineFunctionWithDelegation($x)" + inline fun newInlineFunction1(x: Int): String = "OpenClassV2.newInlineFunction1($x)" + inline fun newInlineFunction2(x: Int): String = "OpenClassV2.newInlineFunction2($x)" + fun newNonInlineFunction(x: Int): String = "OpenClassV2.newNonInlineFunction($x)" + + fun newInlineFunction1Caller(x: Int): String = newInlineFunction1(x) + fun newInlineFunction2Caller(x: Int): String = newInlineFunction2(x) + fun newNonInlineFunctionCaller(x: Int): String = newNonInlineFunction(x) +} diff --git a/compiler/testData/klibABI/removeClassAsTypeArgument/lib1/module.info b/compiler/testData/klibABI/functionTransformations/lib1/module.info similarity index 100% rename from compiler/testData/klibABI/removeClassAsTypeArgument/lib1/module.info rename to compiler/testData/klibABI/functionTransformations/lib1/module.info diff --git a/compiler/testData/klibABI/functionTransformations/lib2/l2.kt b/compiler/testData/klibABI/functionTransformations/lib2/l2.kt new file mode 100644 index 00000000000..0b7cab26da6 --- /dev/null +++ b/compiler/testData/klibABI/functionTransformations/lib2/l2.kt @@ -0,0 +1,163 @@ +import kotlin.coroutines.* + +// Auxiliary function to imitate coroutines. +private fun runCoroutine(coroutine: suspend () -> R): R { + var coroutineResult: Result? = null + + coroutine.startCoroutine(Continuation(EmptyCoroutineContext) { result -> + coroutineResult = result + }) + + return (coroutineResult ?: error("Coroutine finished without any result")).getOrThrow() +} + +private inline fun runInlined(block: () -> R): R = block() // a-la kotlin.run() but without contracts and special annotation + +fun memberOperatorsToNonOperators(vararg pairs: Pair): String { + check(pairs.isNotEmpty()) + val instance = OperatorsToNonOperators(Cache()) + pairs.forEach { (key, value) -> + instance[key] = value // set + } + pairs.forEach { (key, value) -> + check(instance[key] == value) // get + } + return "memberOperatorsToNonOperators: " + instance() // invoke +} + +fun extensionOperatorsToNonOperators(vararg pairs: Pair): String = with(OperatorsToNonOperators.Companion) { + check(pairs.isNotEmpty()) + val cache = Cache() + pairs.forEach { (key, value) -> + cache[key] = value // set + } + pairs.forEach { (key, value) -> + check(cache[key] == value) // get + } + return "extensionOperatorsToNonOperators: " + cache() // invoke +} + +fun memberNonOperatorsToOperators(vararg pairs: Pair): String { + check(pairs.isNotEmpty()) + val instance = NonOperatorsToOperators(Cache()) + pairs.forEach { (key, value) -> + instance.set(key, value) // set + } + pairs.forEach { (key, value) -> + check(instance.get(key) == value) // get + } + return "memberNonOperatorsToOperators: " + instance.invoke() // invoke +} + +fun extensionNonOperatorsToOperators(vararg pairs: Pair): String = with(NonOperatorsToOperators.Companion) { + check(pairs.isNotEmpty()) + val cache = Cache() + pairs.forEach { (key, value) -> + cache.set(key, value) // set + } + pairs.forEach { (key, value) -> + check(cache.get(key) == value) // get + } + return "extensionNonOperatorsToOperators: " + cache.invoke() // invoke +} + +fun memberNonInfixToInfix(a: Int, b: Int): Int = a.wrap().memberNonInfixToInfix(b.wrap()).unwrap() +fun extensionNonInfixToInfix(a: Int, b: Int): Int = with(Wrapper.Companion) { a.wrap().extensionNonInfixToInfix(b.wrap()).unwrap() } +fun memberInfixToNonInfix(a: Int, b: Int): Int = (a.wrap() memberInfixToNonInfix b.wrap()).unwrap() +fun extensionInfixToNonInfix(a: Int, b: Int): Int = with(Wrapper.Companion) { (a.wrap() extensionInfixToNonInfix b.wrap()).unwrap() } + +fun nonTailrecToTailrec(n: Int): Int = Functions.nonTailrecToTailrec(n, 1) +tailrec fun tailrecToNonTailrec(n: Int): Int = Functions.tailrecToNonTailrec(n, 1) + +// This is required to check that default arguments are counter correctly even for inherited classes. +open class StableOpenClass { + open fun firstDefaultValueInFunction(a: Int = 42, b: Int): Int = a + b + open fun lastDefaultValueInFunction(a: Int, b: Int = 42): Int = a + b +} +open class StableClassImpl : StableOpenClass() +class StableClassImpl2 : StableClassImpl() { + override fun firstDefaultValueInFunction(a: Int, b: Int): Int = a - b + override fun lastDefaultValueInFunction(a: Int, b: Int): Int = a - b +} + +fun firstDefaultValueInFunctionInStableOpenClass(stableOpenClass: StableOpenClass, n: Int): Int = stableOpenClass.firstDefaultValueInFunction(b = n) +fun lastDefaultValueInFunctionInStableOpenClass(stableOpenClass: StableOpenClass, n: Int): Int = stableOpenClass.lastDefaultValueInFunction(a = n) +fun firstDefaultValueInFunctionInStableClassImpl(stableClassImpl: StableClassImpl, n: Int): Int = stableClassImpl.firstDefaultValueInFunction(b = n) +fun lastDefaultValueInFunctionInStableClassImpl(stableClassImpl: StableClassImpl, n: Int): Int = stableClassImpl.lastDefaultValueInFunction(a = n) +fun firstDefaultValueInFunctionInStableClassImpl2(stableClassImpl2: StableClassImpl2, n: Int): Int = stableClassImpl2.firstDefaultValueInFunction(b = n) +fun lastDefaultValueInFunctionInStableClassImpl2(stableClassImpl2: StableClassImpl2, n: Int): Int = stableClassImpl2.lastDefaultValueInFunction(a = n) + +fun removedFirstDefaultValueInFunction(n: Int): Int = Functions.removedFirstDefaultValue(b = n) +fun removedVarargFirstDefaultValueInFunction(n: Int): Int = Functions.removedVarargFirstDefaultValue(b = n) +fun removedLastDefaultValueInFunction(n: Int): Int = Functions.removedLastDefaultValue(a = n) +fun removedVarargLastDefaultValueInFunction(n: Int): Int = Functions.removedVarargLastDefaultValue(a = n) +fun removedFirstDefaultValueInConstructor(n: Int): Int = RemovedFirstDefaultValueInConstructor(b = n).value +fun removedLastDefaultValueInConstructor(n: Int): Int = RemovedLastDefaultValueInConstructor(a = n).value + +fun singleVarargArgument(vararg elements: Int): Int = elements.sum() +fun singleVarargArgumentWithDefaultValue(vararg elements: Int = intArrayOf(-1, -2, -3)): Int = elements.sum() +fun varargArgumentAndOtherArguments(first: Int, vararg elements: Int, last: Int): Int = first + elements.sum() + last +fun varargArgumentAndOtherArgumentsWithDefaultValues(first: Int = -100, vararg elements: Int, last: Int = -10): Int = first + elements.sum() + last +fun varargArgumentWithDefaultValueAndOtherArguments(first: Int, vararg elements: Int = intArrayOf(-1, -2, -3), last: Int): Int = first + elements.sum() + last +fun varargArgumentWithDefaultValueAndOtherArgumentsWithDefaultValues(first: Int = -100, vararg elements: Int = intArrayOf(-1, -2, -3), last: Int = -10): Int = first + elements.sum() + last + +fun suspendToNonSuspendFunction1(x: Int): Int = runCoroutine { Functions.suspendToNonSuspendFunction(x) } +fun suspendToNonSuspendFunction2(x: Int): Int = runCoroutine { Functions.wrapCoroutine { Functions.suspendToNonSuspendFunction(x) } } +fun suspendToNonSuspendFunction3(x: Int): Int = runCoroutine { runInlined { Functions.suspendToNonSuspendFunction(x) } } +fun nonSuspendToSuspendFunction1(x: Int): Int = Functions.nonSuspendToSuspendFunction(x) +fun nonSuspendToSuspendFunction2(x: Int): Int = runCoroutine { Functions.nonSuspendToSuspendFunction(x) } +fun nonSuspendToSuspendFunction3(x: Int): Int = runInlined { Functions.nonSuspendToSuspendFunction(x) } +fun nonSuspendToSuspendFunction4(x: Int): Int = runCoroutine { runInlined { Functions.nonSuspendToSuspendFunction(x) } } + +class InterfaceImpl : Interface { + override suspend fun suspendToNonSuspendFunction(x: Int): String = Functions.wrapCoroutine { "InterfaceImpl.suspendToNonSuspendFunction($x)" } + override fun nonSuspendToSuspendFunction(x: Int): String = "InterfaceImpl.nonSuspendToSuspendFunction($x)" +} + +class AbstractClassImpl : AbstractClass() { + override suspend fun suspendToNonSuspendFunction(x: Int): String = Functions.wrapCoroutine { "AbstractClassImpl.suspendToNonSuspendFunction($x)" } + override fun nonSuspendToSuspendFunction(x: Int): String = "AbstractClassImpl.nonSuspendToSuspendFunction($x)" +} + +class OpenClassImpl : OpenClass() { + override suspend fun suspendToNonSuspendFunction(x: Int): String = Functions.wrapCoroutine { "OpenClassImpl.suspendToNonSuspendFunction($x)" } + override fun nonSuspendToSuspendFunction(x: Int): String = "OpenClassImpl.nonSuspendToSuspendFunction($x)" + + override suspend fun suspendToNonSuspendFunctionWithDelegation(x: Int): String = super.suspendToNonSuspendFunctionWithDelegation(x) + " called from OpenClassImpl.suspendToNonSuspendFunctionWithDelegation($x)" + override fun nonSuspendToSuspendFunctionWithDelegation(x: Int): String = super.nonSuspendToSuspendFunctionWithDelegation(x) + " called from OpenClassImpl.nonSuspendToSuspendFunctionWithDelegation($x)" + + override fun openNonInlineToInlineFunction(x: Int): String = "OpenClassImpl.openNonInlineToInlineFunction($x)" + override fun openNonInlineToInlineFunctionWithDelegation(x: Int): String = super.openNonInlineToInlineFunctionWithDelegation(x) + " called from OpenClassImpl.openNonInlineToInlineFunctionWithDelegation($x)" + fun newInlineFunction1(x: Int): String = "OpenClassImpl.newInlineFunction1($x)" // overrides accidentally appeared inline function + inline fun newInlineFunction2(x: Int): String = "OpenClassImpl.newInlineFunction2($x)" // overrides accidentally appeared inline function + inline fun newNonInlineFunction(x: Int): String = "OpenClassImpl.newNonInlineFunction($x)" // overrides accidentally appeared non-inline function +} + +fun suspendToNonSuspendFunctionInInterface(i: Interface, x: Int): String = runCoroutine { i.suspendToNonSuspendFunction(x) } +fun nonSuspendToSuspendFunctionInInterface(i: Interface, x: Int): String = i.nonSuspendToSuspendFunction(x) +fun suspendToNonSuspendFunctionInInterfaceImpl(ii: InterfaceImpl, x: Int): String = runCoroutine { ii.suspendToNonSuspendFunction(x) } +fun nonSuspendToSuspendFunctionInInterfaceImpl(ii: InterfaceImpl, x: Int): String = ii.nonSuspendToSuspendFunction(x) +fun suspendToNonSuspendFunctionInAbstractClass(ac: AbstractClass, x: Int): String = runCoroutine { ac.suspendToNonSuspendFunction(x) } +fun nonSuspendToSuspendFunctionInAbstractClass(ac: AbstractClass, x: Int): String = ac.nonSuspendToSuspendFunction(x) +fun suspendToNonSuspendFunctionInAbstractClassImpl(aci: AbstractClassImpl, x: Int): String = runCoroutine { aci.suspendToNonSuspendFunction(x) } +fun nonSuspendToSuspendFunctionInAbstractClassImpl(aci: AbstractClassImpl, x: Int): String = aci.nonSuspendToSuspendFunction(x) +fun suspendToNonSuspendFunctionInOpenClass(oc: OpenClass, x: Int): String = runCoroutine { oc.suspendToNonSuspendFunction(x) } +fun nonSuspendToSuspendFunctionInOpenClass(oc: OpenClass, x: Int): String = oc.nonSuspendToSuspendFunction(x) +fun suspendToNonSuspendFunctionInOpenClassImpl(oci: OpenClassImpl, x: Int): String = runCoroutine { oci.suspendToNonSuspendFunction(x) } +fun nonSuspendToSuspendFunctionInOpenClassImpl(oci: OpenClassImpl, x: Int): String = oci.nonSuspendToSuspendFunction(x) +fun suspendToNonSuspendFunctionWithDelegation(oci: OpenClassImpl, x: Int): String = runCoroutine { oci.suspendToNonSuspendFunctionWithDelegation(x) } +fun nonSuspendToSuspendFunctionWithDelegation(oci: OpenClassImpl, x: Int): String = oci.nonSuspendToSuspendFunctionWithDelegation(x) + +fun openNonInlineToInlineFunctionInOpenClass(oc: OpenClass, x: Int): String = oc.openNonInlineToInlineFunction(x) +fun openNonInlineToInlineFunctionWithDelegationInOpenClass(oc: OpenClass, x: Int): String = oc.openNonInlineToInlineFunctionWithDelegation(x) +fun newInlineFunction1InOpenClass(oc: OpenClass, x: Int): String = oc.newInlineFunction1Caller(x) +fun newInlineFunction2InOpenClass(oc: OpenClass, x: Int): String = oc.newInlineFunction2Caller(x) +fun newNonInlineFunctionInOpenClass(oc: OpenClass, x: Int): String = oc.newNonInlineFunctionCaller(x) +fun openNonInlineToInlineFunctionInOpenClassImpl(oci: OpenClassImpl, x: Int): String = oci.openNonInlineToInlineFunction(x) +fun openNonInlineToInlineFunctionWithDelegationInOpenClassImpl(oci: OpenClassImpl, x: Int): String = oci.openNonInlineToInlineFunctionWithDelegation(x) +fun newInlineFunction1InOpenClassImpl(oci: OpenClassImpl, x: Int): String = oci.newInlineFunction1(x) +fun newInlineFunction2InOpenClassImpl(oci: OpenClassImpl, x: Int): String = oci.newInlineFunction2(x) +fun newNonInlineFunctionInOpenClassImpl(oci: OpenClassImpl, x: Int): String = oci.newNonInlineFunction(x) + +fun inlineLambdaToNoinlineLambda(x: Int): String = Functions.inlineLambdaToNoinlineLambda(x) { if (it > 0) it.toString() else return "inlineLambdaToNoinlineLambda($x)" } +fun inlineLambdaToCrossinlineLambda(x: Int): String = Functions.inlineLambdaToCrossinlineLambda(x) { if (it > 0) it.toString() else return "inlineLambdaToCrossinlineLambda($x)" } diff --git a/compiler/testData/klibABI/removeClassAsConstructorCall/lib2/module.info b/compiler/testData/klibABI/functionTransformations/lib2/module.info similarity index 100% rename from compiler/testData/klibABI/removeClassAsConstructorCall/lib2/module.info rename to compiler/testData/klibABI/functionTransformations/lib2/module.info diff --git a/compiler/testData/klibABI/functionTransformations/main/m.kt b/compiler/testData/klibABI/functionTransformations/main/m.kt new file mode 100644 index 00000000000..f5cf60959b1 --- /dev/null +++ b/compiler/testData/klibABI/functionTransformations/main/m.kt @@ -0,0 +1,122 @@ +@file:Suppress("RemoveRedundantSpreadOperator") + +import abitestutils.abiTest + +fun box() = abiTest { + val ii: InterfaceImpl = InterfaceImpl() + val i: Interface = ii + val aci: AbstractClassImpl = AbstractClassImpl() + val ac: AbstractClass = aci + val oci: OpenClassImpl = OpenClassImpl() + val oc: OpenClass = oci + val soc: StableOpenClass = StableOpenClass() + val sci: StableClassImpl = StableClassImpl() + val sci2: StableClassImpl2 = StableClassImpl2() + + expectSuccess("memberOperatorsToNonOperators: a=Alice,b=Bob") { memberOperatorsToNonOperators("a" to "Alice", "b" to "Bob") } + expectSuccess("extensionOperatorsToNonOperators: a=Alice,b=Bob") { extensionOperatorsToNonOperators("a" to "Alice", "b" to "Bob") } + expectSuccess("memberNonOperatorsToOperators: a=Alice,b=Bob") { memberNonOperatorsToOperators("a" to "Alice", "b" to "Bob") } + expectSuccess("extensionNonOperatorsToOperators: a=Alice,b=Bob") { extensionNonOperatorsToOperators("a" to "Alice", "b" to "Bob") } + + expectSuccess(3) { memberNonInfixToInfix(1, 2) } + expectSuccess(3) { extensionNonInfixToInfix(1, 2) } + expectSuccess(3) { memberInfixToNonInfix(1, 2) } + expectSuccess(3) { extensionInfixToNonInfix(1, 2) } + + expectSuccess(6) { nonTailrecToTailrec(3) } + expectSuccess(6) { tailrecToNonTailrec(3) } + + expectSuccess(142) { firstDefaultValueInFunctionInStableOpenClass(soc, 100) } + expectSuccess(142) { lastDefaultValueInFunctionInStableOpenClass(soc, 100) } + expectSuccess(142) { firstDefaultValueInFunctionInStableClassImpl(sci, 100) } + expectSuccess(142) { lastDefaultValueInFunctionInStableClassImpl(sci, 100) } + expectSuccess(-58) { firstDefaultValueInFunctionInStableClassImpl2(sci2, 100) } + expectSuccess(58) { lastDefaultValueInFunctionInStableClassImpl2(sci2, 100) } + + expectFailure(linkage("Function 'removedFirstDefaultValue' can not be called: The call site provides less value arguments (1) than the function requires (2)")) { removedFirstDefaultValueInFunction(1) } + expectSuccess(100) { removedVarargFirstDefaultValueInFunction(100) } // Default IntArray value disappears. So it contrinutes 0 to the sum. + expectFailure(linkage("Function 'removedLastDefaultValue' can not be called: The call site provides less value arguments (1) than the function requires (2)")) { removedLastDefaultValueInFunction(1) } + expectSuccess(100) { removedVarargLastDefaultValueInFunction(100) } // Default IntArray value disappears. So it contrinutes 0 to the sum. + expectFailure(linkage("Constructor 'RemovedFirstDefaultValueInConstructor.' can not be called: The call site provides less value arguments (1) than the constructor requires (2)")) { removedFirstDefaultValueInConstructor(1) } + expectFailure(linkage("Constructor 'RemovedLastDefaultValueInConstructor.' can not be called: The call site provides less value arguments (1) than the constructor requires (2)")) { removedLastDefaultValueInConstructor(1) } + + expectSuccess(0) { singleVarargArgument() } + expectSuccess(1) { singleVarargArgument(1) } + expectSuccess(3) { singleVarargArgument(1, 2) } + expectSuccess(1) { singleVarargArgument(*intArrayOf(1)) } + expectSuccess(3) { singleVarargArgument(*intArrayOf(1, 2)) } + expectSuccess(-6) { singleVarargArgumentWithDefaultValue() } + expectSuccess(1) { singleVarargArgumentWithDefaultValue(1) } + expectSuccess(3) { singleVarargArgumentWithDefaultValue(1, 2) } + expectSuccess(1) { singleVarargArgumentWithDefaultValue(*intArrayOf(1)) } + expectSuccess(3) { singleVarargArgumentWithDefaultValue(*intArrayOf(1, 2)) } + expectSuccess(110) { varargArgumentAndOtherArguments(100, last = 10) } + expectSuccess(111) { varargArgumentAndOtherArguments(100, 1, last = 10) } + expectSuccess(113) { varargArgumentAndOtherArguments(100, 1, 2, last = 10) } + expectSuccess(111) { varargArgumentAndOtherArguments(100, *intArrayOf(1), last = 10) } + expectSuccess(113) { varargArgumentAndOtherArguments(100, *intArrayOf(1, 2), last = 10) } + expectSuccess(-110) { varargArgumentAndOtherArgumentsWithDefaultValues() } + expectSuccess(90) { varargArgumentAndOtherArgumentsWithDefaultValues(100) } + expectSuccess(110) { varargArgumentAndOtherArgumentsWithDefaultValues(100, last = 10) } + expectSuccess(91) { varargArgumentAndOtherArgumentsWithDefaultValues(100, 1) } + expectSuccess(93) { varargArgumentAndOtherArgumentsWithDefaultValues(100, 1, 2) } + expectSuccess(113) { varargArgumentAndOtherArgumentsWithDefaultValues(100, 1, 2, last = 10) } + expectSuccess(-109) { varargArgumentAndOtherArgumentsWithDefaultValues(elements = *intArrayOf(1)) } + expectSuccess(-107) { varargArgumentAndOtherArgumentsWithDefaultValues(elements = *intArrayOf(1, 2)) } + expectSuccess(104) { varargArgumentWithDefaultValueAndOtherArguments(100, last = 10) } + expectSuccess(111) { varargArgumentWithDefaultValueAndOtherArguments(100, 1, last = 10) } + expectSuccess(113) { varargArgumentWithDefaultValueAndOtherArguments(100, 1, 2, last = 10) } + expectSuccess(111) { varargArgumentWithDefaultValueAndOtherArguments(100, *intArrayOf(1), last = 10) } + expectSuccess(113) { varargArgumentWithDefaultValueAndOtherArguments(100, *intArrayOf(1, 2), last = 10) } + expectSuccess(-116) { varargArgumentWithDefaultValueAndOtherArgumentsWithDefaultValues() } + expectSuccess(84) { varargArgumentWithDefaultValueAndOtherArgumentsWithDefaultValues(100) } + expectSuccess(104) { varargArgumentWithDefaultValueAndOtherArgumentsWithDefaultValues(100, last = 10) } + expectSuccess(91) { varargArgumentWithDefaultValueAndOtherArgumentsWithDefaultValues(100, 1) } + expectSuccess(93) { varargArgumentWithDefaultValueAndOtherArgumentsWithDefaultValues(100, 1, 2) } + expectSuccess(113) { varargArgumentWithDefaultValueAndOtherArgumentsWithDefaultValues(100, 1, 2, last = 10) } + expectSuccess(-109) { varargArgumentWithDefaultValueAndOtherArgumentsWithDefaultValues(elements = *intArrayOf(1)) } + expectSuccess(-107) { varargArgumentWithDefaultValueAndOtherArgumentsWithDefaultValues(elements = *intArrayOf(1, 2)) } + + expectSuccess(-1) { suspendToNonSuspendFunction1(1) } + expectSuccess(-2) { suspendToNonSuspendFunction2(2) } + expectSuccess(-3) { suspendToNonSuspendFunction3(3) } + expectFailure(linkage("Function 'nonSuspendToSuspendFunction' can not be called: Suspend function can be called only from a coroutine or another suspend function")) { nonSuspendToSuspendFunction1(4) } + expectSuccess(-5) { nonSuspendToSuspendFunction2(5) } + expectFailure(linkage("Function 'nonSuspendToSuspendFunction' can not be called: Suspend function can be called only from a coroutine or another suspend function")) { nonSuspendToSuspendFunction3(6) } + expectSuccess(-7) { nonSuspendToSuspendFunction4(7) } + + expectFailure(linkage("Abstract function 'suspendToNonSuspendFunction' is not implemented in non-abstract class 'InterfaceImpl'")) { suspendToNonSuspendFunctionInInterface(i, 1) } + expectFailure(linkage("Function 'nonSuspendToSuspendFunction' can not be called: Suspend function can be called only from a coroutine or another suspend function")) { nonSuspendToSuspendFunctionInInterface(i, 2) } + expectSuccess("InterfaceImpl.suspendToNonSuspendFunction(3)") { suspendToNonSuspendFunctionInInterfaceImpl(ii, 3) } + expectSuccess("InterfaceImpl.nonSuspendToSuspendFunction(4)") { nonSuspendToSuspendFunctionInInterfaceImpl(ii, 4) } + + expectFailure(linkage("Abstract function 'suspendToNonSuspendFunction' is not implemented in non-abstract class 'AbstractClassImpl'")) { suspendToNonSuspendFunctionInAbstractClass(ac, 5) } + expectFailure(linkage("Function 'nonSuspendToSuspendFunction' can not be called: Suspend function can be called only from a coroutine or another suspend function")) { nonSuspendToSuspendFunctionInAbstractClass(ac, 6) } + expectSuccess("AbstractClassImpl.suspendToNonSuspendFunction(7)") { suspendToNonSuspendFunctionInAbstractClassImpl(aci, 7) } + expectSuccess("AbstractClassImpl.nonSuspendToSuspendFunction(8)") { nonSuspendToSuspendFunctionInAbstractClassImpl(aci, 8) } + + expectSuccess("OpenClassV2.suspendToNonSuspendFunction(9)") { suspendToNonSuspendFunctionInOpenClass(oc, 9) } // Function of the base class is called instead of overridden function in inherited class. + expectFailure(linkage("Function 'nonSuspendToSuspendFunction' can not be called: Suspend function can be called only from a coroutine or another suspend function")) { nonSuspendToSuspendFunctionInOpenClass(oc, 10) } + expectSuccess("OpenClassImpl.suspendToNonSuspendFunction(11)") { suspendToNonSuspendFunctionInOpenClassImpl(oci, 11) } + expectSuccess("OpenClassImpl.nonSuspendToSuspendFunction(12)") { nonSuspendToSuspendFunctionInOpenClassImpl(oci, 12) } + expectSuccess("OpenClassV2.suspendToNonSuspendFunctionWithDelegation(13) called from OpenClassImpl.suspendToNonSuspendFunctionWithDelegation(13)") { suspendToNonSuspendFunctionWithDelegation(oci, 13) } + expectFailure(linkage("Function 'nonSuspendToSuspendFunctionWithDelegation' can not be called: Suspend function can be called only from a coroutine or another suspend function")) { nonSuspendToSuspendFunctionWithDelegation(oci, 14) } + + expectSuccess("OpenClassV2.openNonInlineToInlineFunction(1)") { openNonInlineToInlineFunctionInOpenClass(oc, 1) } + expectSuccess("OpenClassV2.openNonInlineToInlineFunctionWithDelegation(2)") { openNonInlineToInlineFunctionWithDelegationInOpenClass(oc, 2) } + expectSuccess("OpenClassV2.newInlineFunction1(3)") { newInlineFunction1InOpenClass(oc, 3) } + expectSuccess("OpenClassV2.newInlineFunction2(4)") { newInlineFunction2InOpenClass(oc, 4) } + expectSuccess( // TODO: this should be fixed in JS, KT-56762 + if (testMode.isJs) "OpenClassImpl.newNonInlineFunction(5)" else "OpenClassV2.newNonInlineFunction(5)" + ) { newNonInlineFunctionInOpenClass(oc, 5) } + expectSuccess("OpenClassImpl.openNonInlineToInlineFunction(6)") { openNonInlineToInlineFunctionInOpenClassImpl(oci, 6) } + expectSuccess("OpenClassV2.openNonInlineToInlineFunctionWithDelegation(7) called from OpenClassImpl.openNonInlineToInlineFunctionWithDelegation(7)") { openNonInlineToInlineFunctionWithDelegationInOpenClassImpl(oci, 7) } + expectSuccess("OpenClassImpl.newInlineFunction1(8)") { newInlineFunction1InOpenClassImpl(oci, 8) } + expectSuccess("OpenClassImpl.newInlineFunction2(9)") { newInlineFunction2InOpenClassImpl(oci, 9) } + expectSuccess("OpenClassImpl.newNonInlineFunction(10)") { newNonInlineFunctionInOpenClassImpl(oci, 10) } + + expectSuccess("Functions.inlineLambdaToNoinlineLambda(3) { 6 }") { inlineLambdaToNoinlineLambda(3) } + expectFailure(linkage("Illegal non-local return: The return target is function 'inlineLambdaToNoinlineLambda' while only the following return targets are allowed: lambda in function 'inlineLambdaToNoinlineLambda'")) { inlineLambdaToNoinlineLambda(-3) } + expectSuccess("Functions.inlineLambdaToCrossinlineLambda(5) { 10 }") { inlineLambdaToCrossinlineLambda(5) } + expectFailure(linkage("Illegal non-local return: The return target is function 'inlineLambdaToCrossinlineLambda' while only the following return targets are allowed: lambda in function 'inlineLambdaToCrossinlineLambda'")) { inlineLambdaToCrossinlineLambda(-5) } +} diff --git a/compiler/testData/klibABI/removeClassAsReturnType/main/module.info b/compiler/testData/klibABI/functionTransformations/main/module.info similarity index 100% rename from compiler/testData/klibABI/removeClassAsReturnType/main/module.info rename to compiler/testData/klibABI/functionTransformations/main/module.info diff --git a/compiler/testData/klibABI/nonAbstractPropertyInAbstractClassBecomesAbstract/project.info b/compiler/testData/klibABI/functionTransformations/project.info similarity index 100% rename from compiler/testData/klibABI/nonAbstractPropertyInAbstractClassBecomesAbstract/project.info rename to compiler/testData/klibABI/functionTransformations/project.info diff --git a/compiler/testData/klibABI/inheritanceIssues/lib1/l1.kt b/compiler/testData/klibABI/inheritanceIssues/lib1/l1.kt new file mode 100644 index 00000000000..dfd9964e07b --- /dev/null +++ b/compiler/testData/klibABI/inheritanceIssues/lib1/l1.kt @@ -0,0 +1,64 @@ +interface InterfaceToAbstractClass +interface InterfaceToOpenClass +interface InterfaceToFinalClass +interface InterfaceToAnnotationClass +interface InterfaceToObject +interface InterfaceToEnumClass +interface InterfaceToValueClass +interface InterfaceToDataClass + +open class OpenClassToFinalClass(val x: Int) +open class OpenClassToAnnotationClass(val x: Int) +open class OpenClassToObject(val x: Int) +open class OpenClassToEnumClass(val x: Int) +open class OpenClassToValueClass(val x: Int) +open class OpenClassToDataClass(val x: Int) +open class OpenClassToInterface(val x: Int) + +interface InterfaceToAbstractClass1 +interface InterfaceToAbstractClass2 +abstract class AbstractClass + +interface RemovedInterface { + fun abstractFun(): String + fun abstractFunWithDefaultImpl(): String = "RemovedInterface.abstractFunWithDefaultImpl" + val abstractVal: String + val abstractValWithDefaultImpl: String get() = "RemovedInterface.abstractValWithDefaultImpl" +} + +abstract class RemovedAbstractClass { + abstract fun abstractFun(): String + open fun openFun(): String = "RemovedAbstractClass.openFun" + fun finalFun(): String = "RemovedAbstractClass.finalFun" + abstract val abstractVal: String + open val openVal: String get() = "RemovedAbstractClass.openVal" + val finalVal: String get() = "RemovedAbstractClass.finalVal" +} + +open class RemovedOpenClass { + open fun openFun(): String = "RemovedOpenClass.openFun" + fun finalFun(): String = "RemovedOpenClass.finalFun" + open val openVal: String get() = "RemovedOpenClass.openVal" + val finalVal: String get() = "RemovedOpenClass.finalVal" +} + +abstract class AbstractClassWithChangedConstructorSignature(name: String) { + val greeting = "Hello, $name!" +} + +open class OpenClassWithChangedConstructorSignature(name: String) { + val greeting = "Hello, $name!" +} + +open class SuperSuperClass { + open fun inheritsFrom() = "SuperSuperClass -> Any" +} +open class SuperClass : SuperSuperClass() { + override fun inheritsFrom() = "SuperClass -> " + super.inheritsFrom() +} +class SuperSuperClassReplacedBySuperClass : SuperSuperClass() { + override fun inheritsFrom() = "SuperSuperClassReplacedBySuperClass -> " + super.inheritsFrom() +} +class SuperClassReplacedBySuperSuperClass : SuperClass() { + override fun inheritsFrom() = "SuperClassReplacedBySuperSuperClass -> " + super.inheritsFrom() +} diff --git a/compiler/testData/klibABI/inheritanceIssues/lib1/l1.kt.1 b/compiler/testData/klibABI/inheritanceIssues/lib1/l1.kt.1 new file mode 100644 index 00000000000..9b6dda21900 --- /dev/null +++ b/compiler/testData/klibABI/inheritanceIssues/lib1/l1.kt.1 @@ -0,0 +1,64 @@ +abstract class InterfaceToAbstractClass +open class InterfaceToOpenClass +class InterfaceToFinalClass +annotation class InterfaceToAnnotationClass +object InterfaceToObject +enum class InterfaceToEnumClass +value class InterfaceToValueClass(val x: Int) +data class InterfaceToDataClass(val x: Int) + +final class OpenClassToFinalClass(val x: Int) +annotation class OpenClassToAnnotationClass(val x: Int) +object OpenClassToObject { val x: Int = 42 } +enum class OpenClassToEnumClass(val x: Int) +value class OpenClassToValueClass(val x: Int) +data class OpenClassToDataClass(val x: Int) +interface OpenClassToInterface { val x: Int } + +abstract class InterfaceToAbstractClass1 +abstract class InterfaceToAbstractClass2 +abstract class AbstractClass + +//interface RemovedInterface { +// fun abstractFun(): String +// fun abstractFunWithDefaultImpl(): String = "RemovedInterface.abstractFunWithDefaultImpl" +// val abstractVal: String +// val abstractValWithDefaultImpl: String get() = "RemovedInterface.abstractValWithDefaultImpl" +//} +// +//abstract class RemovedAbstractClass { +// abstract fun abstractFun(): String +// open fun openFun(): String = "RemovedAbstractClass.openFun" +// fun finalFun(): String = "RemovedAbstractClass.finalFun" +// abstract val abstractVal: String +// open val openVal: String get() = "RemovedAbstractClass.openVal" +// val finalVal: String get() = "RemovedAbstractClass.finalVal" +//} +// +//open class RemovedOpenClass { +// open fun openFun(): String = "RemovedOpenClass.openFun" +// fun finalFun(): String = "RemovedOpenClass.finalFun" +// open val openVal: String get() = "RemovedOpenClass.openVal" +// val finalVal: String get() = "RemovedOpenClass.finalVal" +//} + +abstract class AbstractClassWithChangedConstructorSignature(name: String, city: String) { + val greeting = "Hello, $name from $city!" +} + +open class OpenClassWithChangedConstructorSignature(name: String, city: String) { + val greeting = "Hello, $name from $city!" +} + +open class SuperSuperClass { + open fun inheritsFrom() = "SuperSuperClass -> Any" +} +open class SuperClass : SuperSuperClass() { + override fun inheritsFrom() = "SuperClass -> " + super.inheritsFrom() +} +class SuperSuperClassReplacedBySuperClass : /*SuperSuperClass()*/ SuperClass() { + override fun inheritsFrom() = "SuperSuperClassReplacedBySuperClass -> " + super.inheritsFrom() +} +class SuperClassReplacedBySuperSuperClass : /*SuperClass()*/ SuperSuperClass() { + override fun inheritsFrom() = "SuperClassReplacedBySuperSuperClass -> " + super.inheritsFrom() +} diff --git a/compiler/testData/klibABI/removeClassAsVariableType/lib1/module.info b/compiler/testData/klibABI/inheritanceIssues/lib1/module.info similarity index 100% rename from compiler/testData/klibABI/removeClassAsVariableType/lib1/module.info rename to compiler/testData/klibABI/inheritanceIssues/lib1/module.info diff --git a/compiler/testData/klibABI/inheritanceIssues/lib2/l2.kt b/compiler/testData/klibABI/inheritanceIssues/lib2/l2.kt new file mode 100644 index 00000000000..8f45b1219f5 --- /dev/null +++ b/compiler/testData/klibABI/inheritanceIssues/lib2/l2.kt @@ -0,0 +1,253 @@ +fun getInterfaceToAbstractClass() = object : InterfaceToAbstractClass {} +inline fun getInterfaceToAbstractClassInline() = object : InterfaceToAbstractClass {} +fun getInterfaceToAbstractClassAsAny(): Any = object : InterfaceToAbstractClass {} +inline fun getInterfaceToAbstractClassAsAnyInline(): Any = object : InterfaceToAbstractClass {} +fun getInterfaceToAbstractClassAsAny2(): Any { class Local : InterfaceToAbstractClass; return Local() } + +fun getInterfaceToOpenClass() = object : InterfaceToOpenClass {} +inline fun getInterfaceToOpenClassInline() = object : InterfaceToOpenClass {} +fun getInterfaceToOpenClassAsAny(): Any = object : InterfaceToOpenClass {} +inline fun getInterfaceToOpenClassAsAnyInline(): Any = object : InterfaceToOpenClass {} +fun getInterfaceToOpenClassAsAny2(): Any { class Local : InterfaceToOpenClass; return Local() } + +fun getInterfaceToFinalClass() = object : InterfaceToFinalClass {} +inline fun getInterfaceToFinalClassInline() = object : InterfaceToFinalClass {} +fun getInterfaceToFinalClassAsAny(): Any = object : InterfaceToFinalClass {} +inline fun getInterfaceToFinalClassAsAnyInline(): Any = object : InterfaceToFinalClass {} +fun getInterfaceToFinalClassAsAny2(): Any { class Local : InterfaceToFinalClass; return Local() } + +open class InterfaceToAbstractClassImpl : InterfaceToAbstractClass +class InterfaceToAbstractClassImpl2 : InterfaceToAbstractClassImpl() +open class InterfaceToOpenClassImpl : InterfaceToOpenClass +class InterfaceToOpenClassImpl2 : InterfaceToOpenClassImpl() +open class InterfaceToFinalClassImpl : InterfaceToFinalClass +class InterfaceToFinalClassImpl2 : InterfaceToFinalClassImpl() + +class InterfaceToAbstractClassContainer { + open class InterfaceToAbstractClassImpl : InterfaceToAbstractClass + class InterfaceToAbstractClassImpl2 : InterfaceToAbstractClassImpl() + inner class InterfaceToAbstractClassInnerImpl : InterfaceToAbstractClass +} +class InterfaceToOpenClassContainer { + open class InterfaceToOpenClassImpl : InterfaceToOpenClass + class InterfaceToOpenClassImpl2 : InterfaceToOpenClassImpl() + inner class InterfaceToOpenClassInnerImpl : InterfaceToOpenClass +} +class InterfaceToFinalClassContainer { + open class InterfaceToFinalClassImpl : InterfaceToFinalClass + class InterfaceToFinalClassImpl2 : InterfaceToFinalClassImpl() + inner class InterfaceToFinalClassInnerImpl : InterfaceToFinalClass +} + +fun getInterfaceToAbstractClassImpl() = InterfaceToAbstractClassImpl() +inline fun getInterfaceToAbstractClassImplInline() = InterfaceToAbstractClassImpl() +fun getInterfaceToAbstractClassImplAsAny(): Any = InterfaceToAbstractClassImpl() +inline fun getInterfaceToAbstractClassImplAsAnyInline(): Any = InterfaceToAbstractClassImpl() + +fun getInterfaceToAbstractClassImpl2() = InterfaceToAbstractClassImpl2() +inline fun getInterfaceToAbstractClassImpl2Inline() = InterfaceToAbstractClassImpl2() +fun getInterfaceToAbstractClassImpl2AsAny(): Any = InterfaceToAbstractClassImpl2() +inline fun getInterfaceToAbstractClassImpl2AsAnyInline(): Any = InterfaceToAbstractClassImpl2() + +fun getInterfaceToOpenClassImpl() = InterfaceToOpenClassImpl() +inline fun getInterfaceToOpenClassImplInline() = InterfaceToOpenClassImpl() +fun getInterfaceToOpenClassImplAsAny(): Any = InterfaceToOpenClassImpl() +inline fun getInterfaceToOpenClassImplAsAnyInline(): Any = InterfaceToOpenClassImpl() + +fun getInterfaceToOpenClassImpl2() = InterfaceToOpenClassImpl2() +inline fun getInterfaceToOpenClassImpl2Inline() = InterfaceToOpenClassImpl2() +fun getInterfaceToOpenClassImpl2AsAny(): Any = InterfaceToOpenClassImpl2() +inline fun getInterfaceToOpenClassImpl2AsAnyInline(): Any = InterfaceToOpenClassImpl2() + +fun getInterfaceToFinalClassImpl() = InterfaceToFinalClassImpl() +inline fun getInterfaceToFinalClassImplInline() = InterfaceToFinalClassImpl() +fun getInterfaceToFinalClassImplAsAny(): Any = InterfaceToFinalClassImpl() +inline fun getInterfaceToFinalClassImplAsAnyInline(): Any = InterfaceToFinalClassImpl() + +fun getInterfaceToFinalClassImpl2() = InterfaceToFinalClassImpl2() +inline fun getInterfaceToFinalClassImpl2Inline() = InterfaceToFinalClassImpl2() +fun getInterfaceToFinalClassImpl2AsAny(): Any = InterfaceToFinalClassImpl2() +inline fun getInterfaceToFinalClassImpl2AsAnyInline(): Any = InterfaceToFinalClassImpl2() + +fun getInterfaceToAbstractClassNestedImpl() = InterfaceToAbstractClassContainer.InterfaceToAbstractClassImpl() +inline fun getInterfaceToAbstractClassNestedImplInline() = InterfaceToAbstractClassContainer.InterfaceToAbstractClassImpl() +fun getInterfaceToAbstractClassNestedImplAsAny(): Any = InterfaceToAbstractClassContainer.InterfaceToAbstractClassImpl() +inline fun getInterfaceToAbstractClassNestedImplAsAnyInline(): Any = InterfaceToAbstractClassContainer.InterfaceToAbstractClassImpl() + +fun getInterfaceToAbstractClassNestedImpl2() = InterfaceToAbstractClassContainer.InterfaceToAbstractClassImpl2() +inline fun getInterfaceToAbstractClassNestedImpl2Inline() = InterfaceToAbstractClassContainer.InterfaceToAbstractClassImpl2() +fun getInterfaceToAbstractClassNestedImpl2AsAny(): Any = InterfaceToAbstractClassContainer.InterfaceToAbstractClassImpl2() +inline fun getInterfaceToAbstractClassNestedImpl2AsAnyInline(): Any = InterfaceToAbstractClassContainer.InterfaceToAbstractClassImpl2() + +fun getInterfaceToAbstractClassInnerImpl() = InterfaceToAbstractClassContainer().InterfaceToAbstractClassInnerImpl() +inline fun getInterfaceToAbstractClassInnerImplInline() = InterfaceToAbstractClassContainer().InterfaceToAbstractClassInnerImpl() +fun getInterfaceToAbstractClassInnerImplAsAny(): Any = InterfaceToAbstractClassContainer().InterfaceToAbstractClassInnerImpl() +inline fun getInterfaceToAbstractClassInnerImplAsAnyInline(): Any = InterfaceToAbstractClassContainer().InterfaceToAbstractClassInnerImpl() + +fun getInterfaceToOpenClassNestedImpl() = InterfaceToOpenClassContainer.InterfaceToOpenClassImpl() +inline fun getInterfaceToOpenClassNestedImplInline() = InterfaceToOpenClassContainer.InterfaceToOpenClassImpl() +fun getInterfaceToOpenClassNestedImplAsAny(): Any = InterfaceToOpenClassContainer.InterfaceToOpenClassImpl() +inline fun getInterfaceToOpenClassNestedImplAsAnyInline(): Any = InterfaceToOpenClassContainer.InterfaceToOpenClassImpl() + +fun getInterfaceToOpenClassNestedImpl2() = InterfaceToOpenClassContainer.InterfaceToOpenClassImpl2() +inline fun getInterfaceToOpenClassNestedImpl2Inline() = InterfaceToOpenClassContainer.InterfaceToOpenClassImpl2() +fun getInterfaceToOpenClassNestedImpl2AsAny(): Any = InterfaceToOpenClassContainer.InterfaceToOpenClassImpl2() +inline fun getInterfaceToOpenClassNestedImpl2AsAnyInline(): Any = InterfaceToOpenClassContainer.InterfaceToOpenClassImpl2() + +fun getInterfaceToOpenClassInnerImpl() = InterfaceToOpenClassContainer().InterfaceToOpenClassInnerImpl() +inline fun getInterfaceToOpenClassInnerImplInline() = InterfaceToOpenClassContainer().InterfaceToOpenClassInnerImpl() +fun getInterfaceToOpenClassInnerImplAsAny(): Any = InterfaceToOpenClassContainer().InterfaceToOpenClassInnerImpl() +inline fun getInterfaceToOpenClassInnerImplAsAnyInline(): Any = InterfaceToOpenClassContainer().InterfaceToOpenClassInnerImpl() + +fun getInterfaceToFinalClassNestedImpl() = InterfaceToFinalClassContainer.InterfaceToFinalClassImpl() +inline fun getInterfaceToFinalClassNestedImplInline() = InterfaceToFinalClassContainer.InterfaceToFinalClassImpl() +fun getInterfaceToFinalClassNestedImplAsAny(): Any = InterfaceToFinalClassContainer.InterfaceToFinalClassImpl() +inline fun getInterfaceToFinalClassNestedImplAsAnyInline(): Any = InterfaceToFinalClassContainer.InterfaceToFinalClassImpl() + +fun getInterfaceToFinalClassNestedImpl2() = InterfaceToFinalClassContainer.InterfaceToFinalClassImpl2() +inline fun getInterfaceToFinalClassNestedImpl2Inline() = InterfaceToFinalClassContainer.InterfaceToFinalClassImpl2() +fun getInterfaceToFinalClassNestedImpl2AsAny(): Any = InterfaceToFinalClassContainer.InterfaceToFinalClassImpl2() +inline fun getInterfaceToFinalClassNestedImpl2AsAnyInline(): Any = InterfaceToFinalClassContainer.InterfaceToFinalClassImpl2() + +fun getInterfaceToFinalClassInnerImpl() = InterfaceToFinalClassContainer().InterfaceToFinalClassInnerImpl() +inline fun getInterfaceToFinalClassInnerImplInline() = InterfaceToFinalClassContainer().InterfaceToFinalClassInnerImpl() +fun getInterfaceToFinalClassInnerImplAsAny(): Any = InterfaceToFinalClassContainer().InterfaceToFinalClassInnerImpl() +inline fun getInterfaceToFinalClassInnerImplAsAnyInline(): Any = InterfaceToFinalClassContainer().InterfaceToFinalClassInnerImpl() + +fun referenceToInterfaceToAbstractClassImpl() = InterfaceToAbstractClassImpl::class.simpleName.orEmpty() +inline fun referenceToInterfaceToAbstractClassImplInline() = InterfaceToAbstractClassImpl::class.simpleName.orEmpty() +fun referenceToInterfaceToAbstractClassImpl2() = InterfaceToAbstractClassImpl2::class.simpleName.orEmpty() +inline fun referenceToInterfaceToAbstractClassImpl2Inline() = InterfaceToAbstractClassImpl2::class.simpleName.orEmpty() + +fun referenceToInterfaceToFinalClassImpl() = check(InterfaceToFinalClassImpl::class.simpleName != null) +inline fun referenceToInterfaceToFinalClassImplInline() = check(InterfaceToFinalClassImpl::class.simpleName != null) +fun referenceToInterfaceToFinalClassImpl2() = check(InterfaceToFinalClassImpl2::class.simpleName != null) +inline fun referenceToInterfaceToFinalClassImpl2Inline() = check(InterfaceToFinalClassImpl2::class.simpleName != null) + +class InterfaceToAnnotationClassImpl : InterfaceToAnnotationClass +class InterfaceToObjectImpl : InterfaceToObject +class InterfaceToEnumClassImpl : InterfaceToEnumClass +class InterfaceToValueClassImpl : InterfaceToValueClass +class InterfaceToDataClassImpl : InterfaceToDataClass + +fun getInterfaceToAnnotationClassImpl() = InterfaceToAnnotationClassImpl() +fun getInterfaceToAnnotationClassImplAsAny(): Any = InterfaceToAnnotationClassImpl() +fun getInterfaceToObjectImpl() = InterfaceToObjectImpl() +fun getInterfaceToObjectImplAsAny(): Any = InterfaceToObjectImpl() +fun getInterfaceToEnumClassImpl() = InterfaceToEnumClassImpl() +fun getInterfaceToEnumClassImplAsAny(): Any = InterfaceToEnumClassImpl() +fun getInterfaceToValueClassImpl() = InterfaceToValueClassImpl() +fun getInterfaceToValueClassImplAny(): Any = InterfaceToValueClassImpl() +fun getInterfaceToDataClassImpl() = InterfaceToDataClassImpl() +fun getInterfaceToDataClassImplAny(): Any = InterfaceToDataClassImpl() + +class OpenClassToFinalClassImpl : OpenClassToFinalClass(42) +class OpenClassToAnnotationClassImpl : OpenClassToAnnotationClass(42) +class OpenClassToObjectImpl : OpenClassToObject(42) +class OpenClassToEnumClassImpl : OpenClassToEnumClass(42) +class OpenClassToValueClassImpl : OpenClassToValueClass(42) +class OpenClassToDataClassImpl : OpenClassToDataClass(42) +class OpenClassToInterfaceImpl : OpenClassToInterface(42) + +fun getOpenClassToFinalClassImpl() = OpenClassToFinalClassImpl() +fun getOpenClassToFinalClassImplAsAny(): Any = OpenClassToFinalClassImpl() +fun getOpenClassToAnnotationClassImpl() = OpenClassToAnnotationClassImpl() +fun getOpenClassToAnnotationClassImplAsAny(): Any = OpenClassToAnnotationClassImpl() +fun getOpenClassToObjectImpl() = OpenClassToObjectImpl() +fun getOpenClassToObjectImplAsAny(): Any = OpenClassToObjectImpl() +fun getOpenClassToEnumClassImpl() = OpenClassToEnumClassImpl() +fun getOpenClassToEnumClassImplAsAny(): Any = OpenClassToEnumClassImpl() +fun getOpenClassToValueClassImpl() = OpenClassToValueClassImpl() +fun getOpenClassToValueClassImplAsAny(): Any = OpenClassToValueClassImpl() +fun getOpenClassToDataClassImpl() = OpenClassToDataClassImpl() +fun getOpenClassToDataClassImplAsAny(): Any = OpenClassToDataClassImpl() +fun getOpenClassToInterfaceImpl() = OpenClassToInterfaceImpl() +fun getOpenClassToInterfaceImplAsAny(): Any = OpenClassToInterfaceImpl() + +value class ValueClassInheritsAbstractClass(val x: Int) : InterfaceToAbstractClass +enum class EnumClassInheritsAbstractClass : InterfaceToAbstractClass { ENTRY } + +fun getValueClassInheritsAbstractClass() = ValueClassInheritsAbstractClass(42) +fun getValueClassInheritsAbstractClassAsAny(): Any = ValueClassInheritsAbstractClass(42) +fun getEnumClassInheritsAbstractClass() = EnumClassInheritsAbstractClass.ENTRY +fun getEnumClassInheritsAbstractClassAsAny(): Any = EnumClassInheritsAbstractClass.ENTRY + +fun getInterfaceToAbstractClass12_1(): InterfaceToAbstractClass1 = object : InterfaceToAbstractClass1, InterfaceToAbstractClass2 {} +inline fun getInterfaceToAbstractClass12_1Inline(): InterfaceToAbstractClass1 = object : InterfaceToAbstractClass1, InterfaceToAbstractClass2 {} +fun getInterfaceToAbstractClass12_2(): InterfaceToAbstractClass2 = object : InterfaceToAbstractClass1, InterfaceToAbstractClass2 {} +inline fun getInterfaceToAbstractClass12_2Inline(): InterfaceToAbstractClass2 = object : InterfaceToAbstractClass1, InterfaceToAbstractClass2 {} +fun getInterfaceToAbstractClass12AsAny(): Any = object : InterfaceToAbstractClass1, InterfaceToAbstractClass2 {} +inline fun getInterfaceToAbstractClass12AsAnyInline(): Any = object : InterfaceToAbstractClass1, InterfaceToAbstractClass2 {} + +fun getInterfaceToAbstractClassAndAbstractClass_1(): InterfaceToAbstractClass1 = object : InterfaceToAbstractClass1, AbstractClass() {} +inline fun getInterfaceToAbstractClassAndAbstractClass_1Inline(): InterfaceToAbstractClass1 = object : InterfaceToAbstractClass1, AbstractClass() {} +fun getInterfaceToAbstractClassAndAbstractClass_2(): AbstractClass = object : InterfaceToAbstractClass1, AbstractClass() {} +inline fun getInterfaceToAbstractClassAndAbstractClass_2Inline(): AbstractClass = object : InterfaceToAbstractClass1, AbstractClass() {} +fun getInterfaceToAbstractClassAndAbstractClassAsAny(): Any = object : InterfaceToAbstractClass1, AbstractClass() {} +inline fun getInterfaceToAbstractClassAndAbstractClassAsAnyInline(): Any = object : InterfaceToAbstractClass1, AbstractClass() {} + +open class InterfaceToAbstractClass12Impl : InterfaceToAbstractClass1, InterfaceToAbstractClass2 +class InterfaceToAbstractClass12Impl2 : InterfaceToAbstractClass12Impl() +open class InterfaceToAbstractClassAndAbstractClassImpl : InterfaceToAbstractClass1, AbstractClass() +class InterfaceToAbstractClassAndAbstractClassImpl2 : InterfaceToAbstractClassAndAbstractClassImpl() + +fun getInterfaceToAbstractClass12Impl() = InterfaceToAbstractClass12Impl() +inline fun getInterfaceToAbstractClass12ImplInline() = InterfaceToAbstractClass12Impl() +fun getInterfaceToAbstractClass12ImplAsAny(): Any = InterfaceToAbstractClass12Impl() +inline fun getInterfaceToAbstractClass12ImplAsAnyInline(): Any = InterfaceToAbstractClass12Impl() + +fun getInterfaceToAbstractClass12Impl2() = InterfaceToAbstractClass12Impl2() +inline fun getInterfaceToAbstractClass12Impl2Inline() = InterfaceToAbstractClass12Impl2() +fun getInterfaceToAbstractClass12Impl2AsAny(): Any = InterfaceToAbstractClass12Impl2() +inline fun getInterfaceToAbstractClass12Impl2AsAnyInline(): Any = InterfaceToAbstractClass12Impl2() + +fun getInterfaceToAbstractClassAndAbstractClassImpl() = InterfaceToAbstractClassAndAbstractClassImpl() +inline fun getInterfaceToAbstractClassAndAbstractClassImplInline() = InterfaceToAbstractClassAndAbstractClassImpl() +fun getInterfaceToAbstractClassAndAbstractClassImplAsAny(): Any = InterfaceToAbstractClassAndAbstractClassImpl() +inline fun getInterfaceToAbstractClassAndAbstractClassImplAsAnyInline(): Any = InterfaceToAbstractClassAndAbstractClassImpl() + +fun getInterfaceToAbstractClassAndAbstractClassImpl2() = InterfaceToAbstractClassAndAbstractClassImpl2() +inline fun getInterfaceToAbstractClassAndAbstractClassImpl2Inline() = InterfaceToAbstractClassAndAbstractClassImpl2() +fun getInterfaceToAbstractClassAndAbstractClassImpl2AsAny(): Any = InterfaceToAbstractClassAndAbstractClassImpl2() +inline fun getInterfaceToAbstractClassAndAbstractClassImpl2AsAnyInline(): Any = InterfaceToAbstractClassAndAbstractClassImpl2() + +fun referenceToInterfaceToAbstractClass12Impl() = check(InterfaceToAbstractClass12Impl::class.simpleName != null) +inline fun referenceToInterfaceToAbstractClass12ImplInline() = check(InterfaceToAbstractClass12Impl::class.simpleName != null) +fun referenceToInterfaceToAbstractClass12Impl2Impl() = check(InterfaceToAbstractClass12Impl2::class.simpleName != null) +inline fun referenceToInterfaceToAbstractClass12Impl2Inline() = check(InterfaceToAbstractClass12Impl2::class.simpleName != null) +fun referenceToInterfaceToAbstractClassAndAbstractClassImpl() = check(InterfaceToAbstractClassAndAbstractClassImpl::class.simpleName != null) +inline fun referenceToInterfaceToAbstractClassAndAbstractClassImplInline() = check(InterfaceToAbstractClassAndAbstractClassImpl::class.simpleName != null) +fun referenceToInterfaceToAbstractClassAndAbstractClassImpl2Impl() = check(InterfaceToAbstractClassAndAbstractClassImpl2::class.simpleName != null) +inline fun referenceToInterfaceToAbstractClassAndAbstractClassImpl2Inline() = check(InterfaceToAbstractClassAndAbstractClassImpl2::class.simpleName != null) + +class RemovedInterfaceImpl1 : RemovedInterface { + override fun abstractFun() = "RemovedInterfaceImpl1.abstractFun" + override val abstractVal get() = "RemovedInterfaceImpl1.abstractVal" +} + +class RemovedInterfaceImpl2 : RemovedInterface { + override fun abstractFun() = abstractFunWithDefaultImpl() + override val abstractVal get() = abstractValWithDefaultImpl +} + +class RemovedAbstractClassImpl1 : RemovedAbstractClass() { + override fun abstractFun() = "RemovedAbstractClassImpl1.abstractFun" + override fun openFun() = "RemovedAbstractClassImpl1.openFun" + override val abstractVal get() = "RemovedAbstractClassImpl1.abstractVal" + override val openVal get() = "RemovedAbstractClassImpl1.openVal" +} + +class RemovedAbstractClassImpl2 : RemovedAbstractClass() { + override fun abstractFun() = "${openFun()}:${finalFun()}" + override val abstractVal get() = "$openVal: $finalVal" +} + +class RemovedOpenClassImpl1 : RemovedOpenClass() { + override fun openFun() = "RemovedOpenClassImpl1.openFun" + override val openVal get() = "RemovedOpenClassImpl1.openVal" +} + +class RemovedOpenClassImpl2 : RemovedOpenClass() + +class AbstractClassWithChangedConstructorSignatureImpl() : AbstractClassWithChangedConstructorSignature("Alice") +class OpenClassWithChangedConstructorSignatureImpl() : OpenClassWithChangedConstructorSignature("Bob") diff --git a/compiler/testData/klibABI/removeClassAsParameterType/lib2/module.info b/compiler/testData/klibABI/inheritanceIssues/lib2/module.info similarity index 100% rename from compiler/testData/klibABI/removeClassAsParameterType/lib2/module.info rename to compiler/testData/klibABI/inheritanceIssues/lib2/module.info diff --git a/compiler/testData/klibABI/inheritanceIssues/main/m.kt b/compiler/testData/klibABI/inheritanceIssues/main/m.kt new file mode 100644 index 00000000000..fbc7efc6cf0 --- /dev/null +++ b/compiler/testData/klibABI/inheritanceIssues/main/m.kt @@ -0,0 +1,234 @@ +import abitestutils.abiTest + +fun box() = abiTest { + val removedInterfaceImpl1 = RemovedInterfaceImpl1() + val removedInterfaceImpl2 = RemovedInterfaceImpl2() + val removedAbstractClassImpl1 = RemovedAbstractClassImpl1() + val removedAbstractClassImpl2 = RemovedAbstractClassImpl2() + val removedOpenClassImpl1 = RemovedOpenClassImpl1() + val removedOpenClassImpl2 = RemovedOpenClassImpl2() + val superSuperClassReplacedBySuperClass = SuperSuperClassReplacedBySuperClass() + val superClassReplacedBySuperSuperClass = SuperClassReplacedBySuperSuperClass() + + expectFailure(linkage("Anonymous object initialization error: Constructor '' should call a constructor of direct super class 'InterfaceToAbstractClass' but calls 'Any.' instead")) { getInterfaceToAbstractClass() } + expectFailure(linkage("Anonymous object initialization error: Constructor '' should call a constructor of direct super class 'InterfaceToAbstractClass' but calls 'Any.' instead")) { getInterfaceToAbstractClassInline() } + expectFailure(linkage("Anonymous object initialization error: Constructor '' should call a constructor of direct super class 'InterfaceToAbstractClass' but calls 'Any.' instead")) { getInterfaceToAbstractClassAsAny() } + expectFailure(linkage("Anonymous object initialization error: Constructor '' should call a constructor of direct super class 'InterfaceToAbstractClass' but calls 'Any.' instead")) { getInterfaceToAbstractClassAsAnyInline() } + expectFailure(linkage("Class initialization error: Constructor 'Local.' should call a constructor of direct super class 'InterfaceToAbstractClass' but calls 'Any.' instead")) { getInterfaceToAbstractClassAsAny2() } + + expectFailure(linkage("Anonymous object initialization error: Constructor '' should call a constructor of direct super class 'InterfaceToOpenClass' but calls 'Any.' instead")) { getInterfaceToOpenClass() } + expectFailure(linkage("Anonymous object initialization error: Constructor '' should call a constructor of direct super class 'InterfaceToOpenClass' but calls 'Any.' instead")) { getInterfaceToOpenClassInline() } + expectFailure(linkage("Anonymous object initialization error: Constructor '' should call a constructor of direct super class 'InterfaceToOpenClass' but calls 'Any.' instead")) { getInterfaceToOpenClassAsAny() } + expectFailure(linkage("Anonymous object initialization error: Constructor '' should call a constructor of direct super class 'InterfaceToOpenClass' but calls 'Any.' instead")) { getInterfaceToOpenClassAsAnyInline() } + expectFailure(linkage("Class initialization error: Constructor 'Local.' should call a constructor of direct super class 'InterfaceToOpenClass' but calls 'Any.' instead")) { getInterfaceToOpenClassAsAny2() } + + expectFailure(linkage("Constructor '' can not be called: Anonymous object inherits from final class 'InterfaceToFinalClass'")) { getInterfaceToFinalClass() } + expectFailure(linkage("Constructor '' can not be called: Anonymous object inherits from final class 'InterfaceToFinalClass'")) { getInterfaceToFinalClassInline() } + expectFailure(linkage("Constructor '' can not be called: Anonymous object inherits from final class 'InterfaceToFinalClass'")) { getInterfaceToFinalClassAsAny() } + expectFailure(linkage("Constructor '' can not be called: Anonymous object inherits from final class 'InterfaceToFinalClass'")) { getInterfaceToFinalClassAsAnyInline() } + expectFailure(linkage("Constructor 'Local.' can not be called: Class 'Local' inherits from final class 'InterfaceToFinalClass'")) { getInterfaceToFinalClassAsAny2() } + + expectFailure(linkage("Class initialization error: Constructor 'InterfaceToAbstractClassImpl.' should call a constructor of direct super class 'InterfaceToAbstractClass' but calls 'Any.' instead")) { getInterfaceToAbstractClassImpl() } + expectFailure(linkage("Class initialization error: Constructor 'InterfaceToAbstractClassImpl.' should call a constructor of direct super class 'InterfaceToAbstractClass' but calls 'Any.' instead")) { getInterfaceToAbstractClassImplInline() } + expectFailure(linkage("Class initialization error: Constructor 'InterfaceToAbstractClassImpl.' should call a constructor of direct super class 'InterfaceToAbstractClass' but calls 'Any.' instead")) { getInterfaceToAbstractClassImplAsAny() } + expectFailure(linkage("Class initialization error: Constructor 'InterfaceToAbstractClassImpl.' should call a constructor of direct super class 'InterfaceToAbstractClass' but calls 'Any.' instead")) { getInterfaceToAbstractClassImplAsAnyInline() } + + expectFailure(linkage("Class initialization error: Constructor 'InterfaceToAbstractClassImpl.' should call a constructor of direct super class 'InterfaceToAbstractClass' but calls 'Any.' instead")) { getInterfaceToAbstractClassImpl2() } + expectFailure(linkage("Class initialization error: Constructor 'InterfaceToAbstractClassImpl.' should call a constructor of direct super class 'InterfaceToAbstractClass' but calls 'Any.' instead")) { getInterfaceToAbstractClassImpl2Inline() } + expectFailure(linkage("Class initialization error: Constructor 'InterfaceToAbstractClassImpl.' should call a constructor of direct super class 'InterfaceToAbstractClass' but calls 'Any.' instead")) { getInterfaceToAbstractClassImpl2AsAny() } + expectFailure(linkage("Class initialization error: Constructor 'InterfaceToAbstractClassImpl.' should call a constructor of direct super class 'InterfaceToAbstractClass' but calls 'Any.' instead")) { getInterfaceToAbstractClassImpl2AsAnyInline() } + + expectFailure(linkage("Class initialization error: Constructor 'InterfaceToOpenClassImpl.' should call a constructor of direct super class 'InterfaceToOpenClass' but calls 'Any.' instead")) { getInterfaceToOpenClassImpl() } + expectFailure(linkage("Class initialization error: Constructor 'InterfaceToOpenClassImpl.' should call a constructor of direct super class 'InterfaceToOpenClass' but calls 'Any.' instead")) { getInterfaceToOpenClassImplInline() } + expectFailure(linkage("Class initialization error: Constructor 'InterfaceToOpenClassImpl.' should call a constructor of direct super class 'InterfaceToOpenClass' but calls 'Any.' instead")) { getInterfaceToOpenClassImplAsAny() } + expectFailure(linkage("Class initialization error: Constructor 'InterfaceToOpenClassImpl.' should call a constructor of direct super class 'InterfaceToOpenClass' but calls 'Any.' instead")) { getInterfaceToOpenClassImplAsAnyInline() } + + expectFailure(linkage("Class initialization error: Constructor 'InterfaceToOpenClassImpl.' should call a constructor of direct super class 'InterfaceToOpenClass' but calls 'Any.' instead")) { getInterfaceToOpenClassImpl2() } + expectFailure(linkage("Class initialization error: Constructor 'InterfaceToOpenClassImpl.' should call a constructor of direct super class 'InterfaceToOpenClass' but calls 'Any.' instead")) { getInterfaceToOpenClassImpl2Inline() } + expectFailure(linkage("Class initialization error: Constructor 'InterfaceToOpenClassImpl.' should call a constructor of direct super class 'InterfaceToOpenClass' but calls 'Any.' instead")) { getInterfaceToOpenClassImpl2AsAny() } + expectFailure(linkage("Class initialization error: Constructor 'InterfaceToOpenClassImpl.' should call a constructor of direct super class 'InterfaceToOpenClass' but calls 'Any.' instead")) { getInterfaceToOpenClassImpl2AsAnyInline() } + + expectFailure(linkage("Function 'getInterfaceToFinalClassImpl' can not be called: Function uses class 'InterfaceToFinalClassImpl' that inherits from final class 'InterfaceToFinalClass'")) { getInterfaceToFinalClassImpl() } + expectFailure(linkage("Function 'getInterfaceToFinalClassImplInline' can not be called: Function uses class 'InterfaceToFinalClassImpl' that inherits from final class 'InterfaceToFinalClass'")) { getInterfaceToFinalClassImplInline() } + expectFailure(linkage("Constructor 'InterfaceToFinalClassImpl.' can not be called: Class 'InterfaceToFinalClassImpl' inherits from final class 'InterfaceToFinalClass'")) { getInterfaceToFinalClassImplAsAny() } + expectFailure(linkage("Constructor 'InterfaceToFinalClassImpl.' can not be called: Class 'InterfaceToFinalClassImpl' inherits from final class 'InterfaceToFinalClass'")) { getInterfaceToFinalClassImplAsAnyInline() } + + expectFailure(linkage("Function 'getInterfaceToFinalClassImpl2' can not be called: Function uses class 'InterfaceToFinalClassImpl' (via class 'InterfaceToFinalClassImpl2') that inherits from final class 'InterfaceToFinalClass'")) { getInterfaceToFinalClassImpl2() } + expectFailure(linkage("Function 'getInterfaceToFinalClassImpl2Inline' can not be called: Function uses class 'InterfaceToFinalClassImpl' (via class 'InterfaceToFinalClassImpl2') that inherits from final class 'InterfaceToFinalClass'")) { getInterfaceToFinalClassImpl2Inline() } + expectFailure(linkage("Constructor 'InterfaceToFinalClassImpl2.' can not be called: Class 'InterfaceToFinalClassImpl2' uses class 'InterfaceToFinalClassImpl' that inherits from final class 'InterfaceToFinalClass'")) { getInterfaceToFinalClassImpl2AsAny() } + expectFailure(linkage("Constructor 'InterfaceToFinalClassImpl2.' can not be called: Class 'InterfaceToFinalClassImpl2' uses class 'InterfaceToFinalClassImpl' that inherits from final class 'InterfaceToFinalClass'")) { getInterfaceToFinalClassImpl2AsAnyInline() } + + expectFailure(linkage("Class initialization error: Constructor 'InterfaceToAbstractClassImpl.' should call a constructor of direct super class 'InterfaceToAbstractClass' but calls 'Any.' instead")) { getInterfaceToAbstractClassNestedImpl() } + expectFailure(linkage("Class initialization error: Constructor 'InterfaceToAbstractClassImpl.' should call a constructor of direct super class 'InterfaceToAbstractClass' but calls 'Any.' instead")) { getInterfaceToAbstractClassNestedImplInline() } + expectFailure(linkage("Class initialization error: Constructor 'InterfaceToAbstractClassImpl.' should call a constructor of direct super class 'InterfaceToAbstractClass' but calls 'Any.' instead")) { getInterfaceToAbstractClassNestedImplAsAny() } + expectFailure(linkage("Class initialization error: Constructor 'InterfaceToAbstractClassImpl.' should call a constructor of direct super class 'InterfaceToAbstractClass' but calls 'Any.' instead")) { getInterfaceToAbstractClassNestedImplAsAnyInline() } + + expectFailure(linkage("Class initialization error: Constructor 'InterfaceToAbstractClassImpl.' should call a constructor of direct super class 'InterfaceToAbstractClass' but calls 'Any.' instead")) { getInterfaceToAbstractClassNestedImpl2() } + expectFailure(linkage("Class initialization error: Constructor 'InterfaceToAbstractClassImpl.' should call a constructor of direct super class 'InterfaceToAbstractClass' but calls 'Any.' instead")) { getInterfaceToAbstractClassNestedImpl2Inline() } + expectFailure(linkage("Class initialization error: Constructor 'InterfaceToAbstractClassImpl.' should call a constructor of direct super class 'InterfaceToAbstractClass' but calls 'Any.' instead")) { getInterfaceToAbstractClassNestedImpl2AsAny() } + expectFailure(linkage("Class initialization error: Constructor 'InterfaceToAbstractClassImpl.' should call a constructor of direct super class 'InterfaceToAbstractClass' but calls 'Any.' instead")) { getInterfaceToAbstractClassNestedImpl2AsAnyInline() } + + expectFailure(linkage("Inner class initialization error: Constructor 'InterfaceToAbstractClassInnerImpl.' should call a constructor of direct super class 'InterfaceToAbstractClass' but calls 'Any.' instead")) { getInterfaceToAbstractClassInnerImpl() } + expectFailure(linkage("Inner class initialization error: Constructor 'InterfaceToAbstractClassInnerImpl.' should call a constructor of direct super class 'InterfaceToAbstractClass' but calls 'Any.' instead")) { getInterfaceToAbstractClassInnerImplInline() } + expectFailure(linkage("Inner class initialization error: Constructor 'InterfaceToAbstractClassInnerImpl.' should call a constructor of direct super class 'InterfaceToAbstractClass' but calls 'Any.' instead")) { getInterfaceToAbstractClassInnerImplAsAny() } + expectFailure(linkage("Inner class initialization error: Constructor 'InterfaceToAbstractClassInnerImpl.' should call a constructor of direct super class 'InterfaceToAbstractClass' but calls 'Any.' instead")) { getInterfaceToAbstractClassInnerImplAsAnyInline() } + + expectFailure(linkage("Class initialization error: Constructor 'InterfaceToOpenClassImpl.' should call a constructor of direct super class 'InterfaceToOpenClass' but calls 'Any.' instead")) { getInterfaceToOpenClassNestedImpl() } + expectFailure(linkage("Class initialization error: Constructor 'InterfaceToOpenClassImpl.' should call a constructor of direct super class 'InterfaceToOpenClass' but calls 'Any.' instead")) { getInterfaceToOpenClassNestedImplInline() } + expectFailure(linkage("Class initialization error: Constructor 'InterfaceToOpenClassImpl.' should call a constructor of direct super class 'InterfaceToOpenClass' but calls 'Any.' instead")) { getInterfaceToOpenClassNestedImplAsAny() } + expectFailure(linkage("Class initialization error: Constructor 'InterfaceToOpenClassImpl.' should call a constructor of direct super class 'InterfaceToOpenClass' but calls 'Any.' instead")) { getInterfaceToOpenClassNestedImplAsAnyInline() } + + expectFailure(linkage("Class initialization error: Constructor 'InterfaceToOpenClassImpl.' should call a constructor of direct super class 'InterfaceToOpenClass' but calls 'Any.' instead")) { getInterfaceToOpenClassNestedImpl2() } + expectFailure(linkage("Class initialization error: Constructor 'InterfaceToOpenClassImpl.' should call a constructor of direct super class 'InterfaceToOpenClass' but calls 'Any.' instead")) { getInterfaceToOpenClassNestedImpl2Inline() } + expectFailure(linkage("Class initialization error: Constructor 'InterfaceToOpenClassImpl.' should call a constructor of direct super class 'InterfaceToOpenClass' but calls 'Any.' instead")) { getInterfaceToOpenClassNestedImpl2AsAny() } + expectFailure(linkage("Class initialization error: Constructor 'InterfaceToOpenClassImpl.' should call a constructor of direct super class 'InterfaceToOpenClass' but calls 'Any.' instead")) { getInterfaceToOpenClassNestedImpl2AsAnyInline() } + + expectFailure(linkage("Inner class initialization error: Constructor 'InterfaceToOpenClassInnerImpl.' should call a constructor of direct super class 'InterfaceToOpenClass' but calls 'Any.' instead")) { getInterfaceToOpenClassInnerImpl() } + expectFailure(linkage("Inner class initialization error: Constructor 'InterfaceToOpenClassInnerImpl.' should call a constructor of direct super class 'InterfaceToOpenClass' but calls 'Any.' instead")) { getInterfaceToOpenClassInnerImplInline() } + expectFailure(linkage("Inner class initialization error: Constructor 'InterfaceToOpenClassInnerImpl.' should call a constructor of direct super class 'InterfaceToOpenClass' but calls 'Any.' instead")) { getInterfaceToOpenClassInnerImplAsAny() } + expectFailure(linkage("Inner class initialization error: Constructor 'InterfaceToOpenClassInnerImpl.' should call a constructor of direct super class 'InterfaceToOpenClass' but calls 'Any.' instead")) { getInterfaceToOpenClassInnerImplAsAnyInline() } + + expectFailure(linkage("Function 'getInterfaceToFinalClassNestedImpl' can not be called: Function uses class 'InterfaceToFinalClassImpl' that inherits from final class 'InterfaceToFinalClass'")) { getInterfaceToFinalClassNestedImpl() } + expectFailure(linkage("Function 'getInterfaceToFinalClassNestedImplInline' can not be called: Function uses class 'InterfaceToFinalClassImpl' that inherits from final class 'InterfaceToFinalClass'")) { getInterfaceToFinalClassNestedImplInline() } + expectFailure(linkage("Constructor 'InterfaceToFinalClassImpl.' can not be called: Class 'InterfaceToFinalClassImpl' inherits from final class 'InterfaceToFinalClass'")) { getInterfaceToFinalClassNestedImplAsAny() } + expectFailure(linkage("Constructor 'InterfaceToFinalClassImpl.' can not be called: Class 'InterfaceToFinalClassImpl' inherits from final class 'InterfaceToFinalClass'")) { getInterfaceToFinalClassNestedImplAsAnyInline() } + + expectFailure(linkage("Function 'getInterfaceToFinalClassNestedImpl2' can not be called: Function uses class 'InterfaceToFinalClassImpl' (via class 'InterfaceToFinalClassImpl2') that inherits from final class 'InterfaceToFinalClass'")) { getInterfaceToFinalClassNestedImpl2() } + expectFailure(linkage("Function 'getInterfaceToFinalClassNestedImpl2Inline' can not be called: Function uses class 'InterfaceToFinalClassImpl' (via class 'InterfaceToFinalClassImpl2') that inherits from final class 'InterfaceToFinalClass'")) { getInterfaceToFinalClassNestedImpl2Inline() } + expectFailure(linkage("Constructor 'InterfaceToFinalClassImpl2.' can not be called: Class 'InterfaceToFinalClassImpl2' uses class 'InterfaceToFinalClassImpl' that inherits from final class 'InterfaceToFinalClass'")) { getInterfaceToFinalClassNestedImpl2AsAny() } + expectFailure(linkage("Constructor 'InterfaceToFinalClassImpl2.' can not be called: Class 'InterfaceToFinalClassImpl2' uses class 'InterfaceToFinalClassImpl' that inherits from final class 'InterfaceToFinalClass'")) { getInterfaceToFinalClassNestedImpl2AsAnyInline() } + + expectFailure(linkage("Function 'getInterfaceToFinalClassInnerImpl' can not be called: Function uses inner class 'InterfaceToFinalClassInnerImpl' that inherits from final class 'InterfaceToFinalClass'")) { getInterfaceToFinalClassInnerImpl() } + expectFailure(linkage("Function 'getInterfaceToFinalClassInnerImplInline' can not be called: Function uses inner class 'InterfaceToFinalClassInnerImpl' that inherits from final class 'InterfaceToFinalClass'")) { getInterfaceToFinalClassInnerImplInline() } + expectFailure(linkage("Constructor 'InterfaceToFinalClassInnerImpl.' can not be called: Inner class 'InterfaceToFinalClassInnerImpl' inherits from final class 'InterfaceToFinalClass'")) { getInterfaceToFinalClassInnerImplAsAny() } + expectFailure(linkage("Constructor 'InterfaceToFinalClassInnerImpl.' can not be called: Inner class 'InterfaceToFinalClassInnerImpl' inherits from final class 'InterfaceToFinalClass'")) { getInterfaceToFinalClassInnerImplAsAnyInline() } + + expectSuccess("InterfaceToAbstractClassImpl") { referenceToInterfaceToAbstractClassImpl() } + expectSuccess("InterfaceToAbstractClassImpl") { referenceToInterfaceToAbstractClassImplInline() } + expectSuccess("InterfaceToAbstractClassImpl2") { referenceToInterfaceToAbstractClassImpl2() } + expectSuccess("InterfaceToAbstractClassImpl2") { referenceToInterfaceToAbstractClassImpl2Inline() } + + expectFailure(linkage("Reference to class 'InterfaceToFinalClassImpl' can not be evaluated: Expression uses class 'InterfaceToFinalClassImpl' that inherits from final class 'InterfaceToFinalClass'")) { referenceToInterfaceToFinalClassImpl() } + expectFailure(linkage("Reference to class 'InterfaceToFinalClassImpl' can not be evaluated: Expression uses class 'InterfaceToFinalClassImpl' that inherits from final class 'InterfaceToFinalClass'")) { referenceToInterfaceToFinalClassImplInline() } + expectFailure(linkage("Reference to class 'InterfaceToFinalClassImpl2' can not be evaluated: Expression uses class 'InterfaceToFinalClassImpl' (via class 'InterfaceToFinalClassImpl2') that inherits from final class 'InterfaceToFinalClass'")) { referenceToInterfaceToFinalClassImpl2() } + expectFailure(linkage("Reference to class 'InterfaceToFinalClassImpl2' can not be evaluated: Expression uses class 'InterfaceToFinalClassImpl' (via class 'InterfaceToFinalClassImpl2') that inherits from final class 'InterfaceToFinalClass'")) { referenceToInterfaceToFinalClassImpl2Inline() } + + expectFailure(linkage("Function 'getInterfaceToAnnotationClassImpl' can not be called: Function uses class 'InterfaceToAnnotationClassImpl' that has illegal inheritance from annotation class 'InterfaceToAnnotationClass'")) { getInterfaceToAnnotationClassImpl() } + expectFailure(linkage("Constructor 'InterfaceToAnnotationClassImpl.' can not be called: Class 'InterfaceToAnnotationClassImpl' has illegal inheritance from annotation class 'InterfaceToAnnotationClass'")) { getInterfaceToAnnotationClassImplAsAny() } + expectFailure(linkage("Function 'getInterfaceToObjectImpl' can not be called: Function uses class 'InterfaceToObjectImpl' that inherits from final object 'InterfaceToObject'")) { getInterfaceToObjectImpl() } + expectFailure(linkage("Constructor 'InterfaceToObjectImpl.' can not be called: Class 'InterfaceToObjectImpl' inherits from final object 'InterfaceToObject'")) { getInterfaceToObjectImplAsAny() } + expectFailure(linkage("Function 'getInterfaceToEnumClassImpl' can not be called: Function uses class 'InterfaceToEnumClassImpl' that inherits from final enum class 'InterfaceToEnumClass'")) { getInterfaceToEnumClassImpl() } + expectFailure(linkage("Constructor 'InterfaceToEnumClassImpl.' can not be called: Class 'InterfaceToEnumClassImpl' inherits from final enum class 'InterfaceToEnumClass'")) { getInterfaceToEnumClassImplAsAny() } + expectFailure(linkage("Function 'getInterfaceToValueClassImpl' can not be called: Function uses class 'InterfaceToValueClassImpl' that inherits from final value class 'InterfaceToValueClass'")) { getInterfaceToValueClassImpl() } + expectFailure(linkage("Constructor 'InterfaceToValueClassImpl.' can not be called: Class 'InterfaceToValueClassImpl' inherits from final value class 'InterfaceToValueClass'")) { getInterfaceToValueClassImplAny() } + expectFailure(linkage("Function 'getInterfaceToDataClassImpl' can not be called: Function uses class 'InterfaceToDataClassImpl' that inherits from final data class 'InterfaceToDataClass'")) { getInterfaceToDataClassImpl() } + expectFailure(linkage("Constructor 'InterfaceToDataClassImpl.' can not be called: Class 'InterfaceToDataClassImpl' inherits from final data class 'InterfaceToDataClass'")) { getInterfaceToDataClassImplAny() } + + expectFailure(linkage("Function 'getOpenClassToFinalClassImpl' can not be called: Function uses class 'OpenClassToFinalClassImpl' that inherits from final class 'OpenClassToFinalClass'")) { getOpenClassToFinalClassImpl() } + expectFailure(linkage("Constructor 'OpenClassToFinalClassImpl.' can not be called: Class 'OpenClassToFinalClassImpl' inherits from final class 'OpenClassToFinalClass'")) { getOpenClassToFinalClassImplAsAny() } + expectFailure(linkage("Function 'getOpenClassToAnnotationClassImpl' can not be called: Function uses class 'OpenClassToAnnotationClassImpl' that has illegal inheritance from annotation class 'OpenClassToAnnotationClass'")) { getOpenClassToAnnotationClassImpl() } + expectFailure(linkage("Constructor 'OpenClassToAnnotationClassImpl.' can not be called: Class 'OpenClassToAnnotationClassImpl' has illegal inheritance from annotation class 'OpenClassToAnnotationClass'")) { getOpenClassToAnnotationClassImplAsAny() } + expectFailure(linkage("Function 'getOpenClassToObjectImpl' can not be called: Function uses class 'OpenClassToObjectImpl' that inherits from final object 'OpenClassToObject'")) { getOpenClassToObjectImpl() } + expectFailure(linkage("Constructor 'OpenClassToObjectImpl.' can not be called: Class 'OpenClassToObjectImpl' inherits from final object 'OpenClassToObject'")) { getOpenClassToObjectImplAsAny() } + expectFailure(linkage("Function 'getOpenClassToEnumClassImpl' can not be called: Function uses class 'OpenClassToEnumClassImpl' that inherits from final enum class 'OpenClassToEnumClass'")) { getOpenClassToEnumClassImpl() } + expectFailure(linkage("Constructor 'OpenClassToEnumClassImpl.' can not be called: Class 'OpenClassToEnumClassImpl' inherits from final enum class 'OpenClassToEnumClass'")) { getOpenClassToEnumClassImplAsAny() } + expectFailure(linkage("Function 'getOpenClassToValueClassImpl' can not be called: Function uses class 'OpenClassToValueClassImpl' that inherits from final value class 'OpenClassToValueClass'")) { getOpenClassToValueClassImpl() } + expectFailure(linkage("Constructor 'OpenClassToValueClassImpl.' can not be called: Class 'OpenClassToValueClassImpl' inherits from final value class 'OpenClassToValueClass'")) { getOpenClassToValueClassImplAsAny() } + expectFailure(linkage("Function 'getOpenClassToDataClassImpl' can not be called: Function uses class 'OpenClassToDataClassImpl' that inherits from final data class 'OpenClassToDataClass'")) { getOpenClassToDataClassImpl() } + expectFailure(linkage("Constructor 'OpenClassToDataClassImpl.' can not be called: Class 'OpenClassToDataClassImpl' inherits from final data class 'OpenClassToDataClass'")) { getOpenClassToDataClassImplAsAny() } + expectFailure(linkage("Class initialization error: Constructor 'OpenClassToInterfaceImpl.' should call a constructor of direct super class 'Any' but calls 'OpenClassToInterface.' instead")) { getOpenClassToInterfaceImpl() } + expectFailure(linkage("Class initialization error: Constructor 'OpenClassToInterfaceImpl.' should call a constructor of direct super class 'Any' but calls 'OpenClassToInterface.' instead")) { getOpenClassToInterfaceImplAsAny() } + + expectFailure(linkage("Function 'getValueClassInheritsAbstractClass' can not be called: Function uses value class 'ValueClassInheritsAbstractClass' that has illegal inheritance from class 'InterfaceToAbstractClass'")) { getValueClassInheritsAbstractClass() } + expectFailure(linkage("Constructor 'ValueClassInheritsAbstractClass.' can not be called: Value class 'ValueClassInheritsAbstractClass' has illegal inheritance from class 'InterfaceToAbstractClass'")) { getValueClassInheritsAbstractClassAsAny() } + expectFailure(linkage("Function 'getEnumClassInheritsAbstractClass' can not be called: Function uses enum class 'EnumClassInheritsAbstractClass' that simultaneously inherits from 2 classes: 'Enum', 'InterfaceToAbstractClass'")) { getEnumClassInheritsAbstractClass() } + expectFailure(linkage("Can not get instance of singleton 'EnumClassInheritsAbstractClass.ENTRY': Expression uses enum class 'EnumClassInheritsAbstractClass' that simultaneously inherits from 2 classes: 'Enum', 'InterfaceToAbstractClass'")) { getEnumClassInheritsAbstractClassAsAny() } + + expectFailure(linkage("Constructor '' can not be called: Anonymous object simultaneously inherits from 2 classes: 'InterfaceToAbstractClass1', 'InterfaceToAbstractClass2'")) { getInterfaceToAbstractClass12_1() } + expectFailure(linkage("Constructor '' can not be called: Anonymous object simultaneously inherits from 2 classes: 'InterfaceToAbstractClass1', 'InterfaceToAbstractClass2'")) { getInterfaceToAbstractClass12_1Inline() } + expectFailure(linkage("Constructor '' can not be called: Anonymous object simultaneously inherits from 2 classes: 'InterfaceToAbstractClass1', 'InterfaceToAbstractClass2'")) { getInterfaceToAbstractClass12_2() } + expectFailure(linkage("Constructor '' can not be called: Anonymous object simultaneously inherits from 2 classes: 'InterfaceToAbstractClass1', 'InterfaceToAbstractClass2'")) { getInterfaceToAbstractClass12_2Inline() } + expectFailure(linkage("Constructor '' can not be called: Anonymous object simultaneously inherits from 2 classes: 'InterfaceToAbstractClass1', 'InterfaceToAbstractClass2'")) { getInterfaceToAbstractClass12AsAny() } + expectFailure(linkage("Constructor '' can not be called: Anonymous object simultaneously inherits from 2 classes: 'InterfaceToAbstractClass1', 'InterfaceToAbstractClass2'")) { getInterfaceToAbstractClass12AsAnyInline() } + + expectFailure(linkage("Constructor '' can not be called: Anonymous object simultaneously inherits from 2 classes: 'AbstractClass', 'InterfaceToAbstractClass1'")) { getInterfaceToAbstractClassAndAbstractClass_1() } + expectFailure(linkage("Constructor '' can not be called: Anonymous object simultaneously inherits from 2 classes: 'AbstractClass', 'InterfaceToAbstractClass1'")) { getInterfaceToAbstractClassAndAbstractClass_1Inline() } + expectFailure(linkage("Constructor '' can not be called: Anonymous object simultaneously inherits from 2 classes: 'AbstractClass', 'InterfaceToAbstractClass1'")) { getInterfaceToAbstractClassAndAbstractClass_2() } + expectFailure(linkage("Constructor '' can not be called: Anonymous object simultaneously inherits from 2 classes: 'AbstractClass', 'InterfaceToAbstractClass1'")) { getInterfaceToAbstractClassAndAbstractClass_2Inline() } + expectFailure(linkage("Constructor '' can not be called: Anonymous object simultaneously inherits from 2 classes: 'AbstractClass', 'InterfaceToAbstractClass1'")) { getInterfaceToAbstractClassAndAbstractClassAsAny() } + expectFailure(linkage("Constructor '' can not be called: Anonymous object simultaneously inherits from 2 classes: 'AbstractClass', 'InterfaceToAbstractClass1'")) { getInterfaceToAbstractClassAndAbstractClassAsAnyInline() } + + expectFailure(linkage("Function 'getInterfaceToAbstractClass12Impl' can not be called: Function uses class 'InterfaceToAbstractClass12Impl' that simultaneously inherits from 2 classes: 'InterfaceToAbstractClass1', 'InterfaceToAbstractClass2'")) { getInterfaceToAbstractClass12Impl() } + expectFailure(linkage("Function 'getInterfaceToAbstractClass12ImplInline' can not be called: Function uses class 'InterfaceToAbstractClass12Impl' that simultaneously inherits from 2 classes: 'InterfaceToAbstractClass1', 'InterfaceToAbstractClass2'")) { getInterfaceToAbstractClass12ImplInline() } + expectFailure(linkage("Constructor 'InterfaceToAbstractClass12Impl.' can not be called: Class 'InterfaceToAbstractClass12Impl' simultaneously inherits from 2 classes: 'InterfaceToAbstractClass1', 'InterfaceToAbstractClass2'")) { getInterfaceToAbstractClass12ImplAsAny() } + expectFailure(linkage("Constructor 'InterfaceToAbstractClass12Impl.' can not be called: Class 'InterfaceToAbstractClass12Impl' simultaneously inherits from 2 classes: 'InterfaceToAbstractClass1', 'InterfaceToAbstractClass2'")) { getInterfaceToAbstractClass12ImplAsAnyInline() } + + expectFailure(linkage("Function 'getInterfaceToAbstractClass12Impl2' can not be called: Function uses class 'InterfaceToAbstractClass12Impl' (via class 'InterfaceToAbstractClass12Impl2') that simultaneously inherits from 2 classes: 'InterfaceToAbstractClass1', 'InterfaceToAbstractClass2'")) { getInterfaceToAbstractClass12Impl2() } + expectFailure(linkage("Function 'getInterfaceToAbstractClass12Impl2Inline' can not be called: Function uses class 'InterfaceToAbstractClass12Impl' (via class 'InterfaceToAbstractClass12Impl2') that simultaneously inherits from 2 classes: 'InterfaceToAbstractClass1', 'InterfaceToAbstractClass2'")) { getInterfaceToAbstractClass12Impl2Inline() } + expectFailure(linkage("Constructor 'InterfaceToAbstractClass12Impl2.' can not be called: Class 'InterfaceToAbstractClass12Impl2' uses class 'InterfaceToAbstractClass12Impl' that simultaneously inherits from 2 classes: 'InterfaceToAbstractClass1', 'InterfaceToAbstractClass2'")) { getInterfaceToAbstractClass12Impl2AsAny() } + expectFailure(linkage("Constructor 'InterfaceToAbstractClass12Impl2.' can not be called: Class 'InterfaceToAbstractClass12Impl2' uses class 'InterfaceToAbstractClass12Impl' that simultaneously inherits from 2 classes: 'InterfaceToAbstractClass1', 'InterfaceToAbstractClass2'")) { getInterfaceToAbstractClass12Impl2AsAnyInline() } + + expectFailure(linkage("Function 'getInterfaceToAbstractClassAndAbstractClassImpl' can not be called: Function uses class 'InterfaceToAbstractClassAndAbstractClassImpl' that simultaneously inherits from 2 classes: 'AbstractClass', 'InterfaceToAbstractClass1'")) { getInterfaceToAbstractClassAndAbstractClassImpl() } + expectFailure(linkage("Function 'getInterfaceToAbstractClassAndAbstractClassImplInline' can not be called: Function uses class 'InterfaceToAbstractClassAndAbstractClassImpl' that simultaneously inherits from 2 classes: 'AbstractClass', 'InterfaceToAbstractClass1'")) { getInterfaceToAbstractClassAndAbstractClassImplInline() } + expectFailure(linkage("Constructor 'InterfaceToAbstractClassAndAbstractClassImpl.' can not be called: Class 'InterfaceToAbstractClassAndAbstractClassImpl' simultaneously inherits from 2 classes: 'AbstractClass', 'InterfaceToAbstractClass1'")) { getInterfaceToAbstractClassAndAbstractClassImplAsAny() } + expectFailure(linkage("Constructor 'InterfaceToAbstractClassAndAbstractClassImpl.' can not be called: Class 'InterfaceToAbstractClassAndAbstractClassImpl' simultaneously inherits from 2 classes: 'AbstractClass', 'InterfaceToAbstractClass1'")) { getInterfaceToAbstractClassAndAbstractClassImplAsAnyInline() } + + expectFailure(linkage("Function 'getInterfaceToAbstractClassAndAbstractClassImpl2' can not be called: Function uses class 'InterfaceToAbstractClassAndAbstractClassImpl' (via class 'InterfaceToAbstractClassAndAbstractClassImpl2') that simultaneously inherits from 2 classes: 'AbstractClass', 'InterfaceToAbstractClass1'")) { getInterfaceToAbstractClassAndAbstractClassImpl2() } + expectFailure(linkage("Function 'getInterfaceToAbstractClassAndAbstractClassImpl2Inline' can not be called: Function uses class 'InterfaceToAbstractClassAndAbstractClassImpl' (via class 'InterfaceToAbstractClassAndAbstractClassImpl2') that simultaneously inherits from 2 classes: 'AbstractClass', 'InterfaceToAbstractClass1'")) { getInterfaceToAbstractClassAndAbstractClassImpl2Inline() } + expectFailure(linkage("Constructor 'InterfaceToAbstractClassAndAbstractClassImpl2.' can not be called: Class 'InterfaceToAbstractClassAndAbstractClassImpl2' uses class 'InterfaceToAbstractClassAndAbstractClassImpl' that simultaneously inherits from 2 classes: 'AbstractClass', 'InterfaceToAbstractClass1'")) { getInterfaceToAbstractClassAndAbstractClassImpl2AsAny() } + expectFailure(linkage("Constructor 'InterfaceToAbstractClassAndAbstractClassImpl2.' can not be called: Class 'InterfaceToAbstractClassAndAbstractClassImpl2' uses class 'InterfaceToAbstractClassAndAbstractClassImpl' that simultaneously inherits from 2 classes: 'AbstractClass', 'InterfaceToAbstractClass1'")) { getInterfaceToAbstractClassAndAbstractClassImpl2AsAnyInline() } + + expectFailure(linkage("Reference to class 'InterfaceToAbstractClass12Impl' can not be evaluated: Expression uses class 'InterfaceToAbstractClass12Impl' that simultaneously inherits from 2 classes: 'InterfaceToAbstractClass1', 'InterfaceToAbstractClass2'")) { referenceToInterfaceToAbstractClass12Impl() } + expectFailure(linkage("Reference to class 'InterfaceToAbstractClass12Impl' can not be evaluated: Expression uses class 'InterfaceToAbstractClass12Impl' that simultaneously inherits from 2 classes: 'InterfaceToAbstractClass1', 'InterfaceToAbstractClass2'")) { referenceToInterfaceToAbstractClass12ImplInline() } + expectFailure(linkage("Reference to class 'InterfaceToAbstractClass12Impl2' can not be evaluated: Expression uses class 'InterfaceToAbstractClass12Impl' (via class 'InterfaceToAbstractClass12Impl2') that simultaneously inherits from 2 classes: 'InterfaceToAbstractClass1', 'InterfaceToAbstractClass2'")) { referenceToInterfaceToAbstractClass12Impl2Impl() } + expectFailure(linkage("Reference to class 'InterfaceToAbstractClass12Impl2' can not be evaluated: Expression uses class 'InterfaceToAbstractClass12Impl' (via class 'InterfaceToAbstractClass12Impl2') that simultaneously inherits from 2 classes: 'InterfaceToAbstractClass1', 'InterfaceToAbstractClass2'")) { referenceToInterfaceToAbstractClass12Impl2Inline() } + expectFailure(linkage("Reference to class 'InterfaceToAbstractClassAndAbstractClassImpl' can not be evaluated: Expression uses class 'InterfaceToAbstractClassAndAbstractClassImpl' that simultaneously inherits from 2 classes: 'AbstractClass', 'InterfaceToAbstractClass1'")) { referenceToInterfaceToAbstractClassAndAbstractClassImpl() } + expectFailure(linkage("Reference to class 'InterfaceToAbstractClassAndAbstractClassImpl' can not be evaluated: Expression uses class 'InterfaceToAbstractClassAndAbstractClassImpl' that simultaneously inherits from 2 classes: 'AbstractClass', 'InterfaceToAbstractClass1'")) { referenceToInterfaceToAbstractClassAndAbstractClassImplInline() } + expectFailure(linkage("Reference to class 'InterfaceToAbstractClassAndAbstractClassImpl2' can not be evaluated: Expression uses class 'InterfaceToAbstractClassAndAbstractClassImpl' (via class 'InterfaceToAbstractClassAndAbstractClassImpl2') that simultaneously inherits from 2 classes: 'AbstractClass', 'InterfaceToAbstractClass1'")) { referenceToInterfaceToAbstractClassAndAbstractClassImpl2Impl() } + expectFailure(linkage("Reference to class 'InterfaceToAbstractClassAndAbstractClassImpl2' can not be evaluated: Expression uses class 'InterfaceToAbstractClassAndAbstractClassImpl' (via class 'InterfaceToAbstractClassAndAbstractClassImpl2') that simultaneously inherits from 2 classes: 'AbstractClass', 'InterfaceToAbstractClass1'")) { referenceToInterfaceToAbstractClassAndAbstractClassImpl2Inline() } + + expectFailure(linkage("Can not read value from variable 'removedInterfaceImpl1': Variable uses unlinked class symbol '/RemovedInterface' (via class 'RemovedInterfaceImpl1')")) { removedInterfaceImpl1.abstractFun() } + expectFailure(linkage("Can not read value from variable 'removedInterfaceImpl1': Variable uses unlinked class symbol '/RemovedInterface' (via class 'RemovedInterfaceImpl1')")) { removedInterfaceImpl1.abstractFunWithDefaultImpl() } + expectFailure(linkage("Can not read value from variable 'removedInterfaceImpl1': Variable uses unlinked class symbol '/RemovedInterface' (via class 'RemovedInterfaceImpl1')")) { removedInterfaceImpl1.abstractVal } + expectFailure(linkage("Can not read value from variable 'removedInterfaceImpl1': Variable uses unlinked class symbol '/RemovedInterface' (via class 'RemovedInterfaceImpl1')")) { removedInterfaceImpl1.abstractValWithDefaultImpl } + + expectFailure(linkage("Can not read value from variable 'removedInterfaceImpl2': Variable uses unlinked class symbol '/RemovedInterface' (via class 'RemovedInterfaceImpl2')")) { removedInterfaceImpl2.abstractFun() } + expectFailure(linkage("Can not read value from variable 'removedInterfaceImpl2': Variable uses unlinked class symbol '/RemovedInterface' (via class 'RemovedInterfaceImpl2')")) { removedInterfaceImpl2.abstractFunWithDefaultImpl() } + expectFailure(linkage("Can not read value from variable 'removedInterfaceImpl2': Variable uses unlinked class symbol '/RemovedInterface' (via class 'RemovedInterfaceImpl2')")) { removedInterfaceImpl2.abstractVal } + expectFailure(linkage("Can not read value from variable 'removedInterfaceImpl2': Variable uses unlinked class symbol '/RemovedInterface' (via class 'RemovedInterfaceImpl2')")) { removedInterfaceImpl2.abstractValWithDefaultImpl } + + expectFailure(linkage("Can not read value from variable 'removedAbstractClassImpl1': Variable uses unlinked class symbol '/RemovedAbstractClass' (via class 'RemovedAbstractClassImpl1')")) { removedAbstractClassImpl1.abstractFun() } + expectFailure(linkage("Can not read value from variable 'removedAbstractClassImpl1': Variable uses unlinked class symbol '/RemovedAbstractClass' (via class 'RemovedAbstractClassImpl1')")) { removedAbstractClassImpl1.openFun() } + expectFailure(linkage("Can not read value from variable 'removedAbstractClassImpl1': Variable uses unlinked class symbol '/RemovedAbstractClass' (via class 'RemovedAbstractClassImpl1')")) { removedAbstractClassImpl1.finalFun() } + expectFailure(linkage("Can not read value from variable 'removedAbstractClassImpl1': Variable uses unlinked class symbol '/RemovedAbstractClass' (via class 'RemovedAbstractClassImpl1')")) { removedAbstractClassImpl1.abstractVal } + expectFailure(linkage("Can not read value from variable 'removedAbstractClassImpl1': Variable uses unlinked class symbol '/RemovedAbstractClass' (via class 'RemovedAbstractClassImpl1')")) { removedAbstractClassImpl1.openVal } + expectFailure(linkage("Can not read value from variable 'removedAbstractClassImpl1': Variable uses unlinked class symbol '/RemovedAbstractClass' (via class 'RemovedAbstractClassImpl1')")) { removedAbstractClassImpl1.finalVal } + + expectFailure(linkage("Can not read value from variable 'removedAbstractClassImpl2': Variable uses unlinked class symbol '/RemovedAbstractClass' (via class 'RemovedAbstractClassImpl2')")) { removedAbstractClassImpl2.abstractFun() } + expectFailure(linkage("Can not read value from variable 'removedAbstractClassImpl2': Variable uses unlinked class symbol '/RemovedAbstractClass' (via class 'RemovedAbstractClassImpl2')")) { removedAbstractClassImpl2.openFun() } + expectFailure(linkage("Can not read value from variable 'removedAbstractClassImpl2': Variable uses unlinked class symbol '/RemovedAbstractClass' (via class 'RemovedAbstractClassImpl2')")) { removedAbstractClassImpl2.finalFun() } + expectFailure(linkage("Can not read value from variable 'removedAbstractClassImpl2': Variable uses unlinked class symbol '/RemovedAbstractClass' (via class 'RemovedAbstractClassImpl2')")) { removedAbstractClassImpl2.abstractVal } + expectFailure(linkage("Can not read value from variable 'removedAbstractClassImpl2': Variable uses unlinked class symbol '/RemovedAbstractClass' (via class 'RemovedAbstractClassImpl2')")) { removedAbstractClassImpl2.openVal } + expectFailure(linkage("Can not read value from variable 'removedAbstractClassImpl2': Variable uses unlinked class symbol '/RemovedAbstractClass' (via class 'RemovedAbstractClassImpl2')")) { removedAbstractClassImpl2.finalVal } + + expectFailure(linkage("Can not read value from variable 'removedOpenClassImpl1': Variable uses unlinked class symbol '/RemovedOpenClass' (via class 'RemovedOpenClassImpl1')")) { removedOpenClassImpl1.openFun() } + expectFailure(linkage("Can not read value from variable 'removedOpenClassImpl1': Variable uses unlinked class symbol '/RemovedOpenClass' (via class 'RemovedOpenClassImpl1')")) { removedOpenClassImpl1.finalFun() } + expectFailure(linkage("Can not read value from variable 'removedOpenClassImpl1': Variable uses unlinked class symbol '/RemovedOpenClass' (via class 'RemovedOpenClassImpl1')")) { removedOpenClassImpl1.openVal } + expectFailure(linkage("Can not read value from variable 'removedOpenClassImpl1': Variable uses unlinked class symbol '/RemovedOpenClass' (via class 'RemovedOpenClassImpl1')")) { removedOpenClassImpl1.finalVal } + + expectFailure(linkage("Can not read value from variable 'removedOpenClassImpl2': Variable uses unlinked class symbol '/RemovedOpenClass' (via class 'RemovedOpenClassImpl2')")) { removedOpenClassImpl2.openFun() } + expectFailure(linkage("Can not read value from variable 'removedOpenClassImpl2': Variable uses unlinked class symbol '/RemovedOpenClass' (via class 'RemovedOpenClassImpl2')")) { removedOpenClassImpl2.finalFun() } + expectFailure(linkage("Can not read value from variable 'removedOpenClassImpl2': Variable uses unlinked class symbol '/RemovedOpenClass' (via class 'RemovedOpenClassImpl2')")) { removedOpenClassImpl2.openVal } + expectFailure(linkage("Can not read value from variable 'removedOpenClassImpl2': Variable uses unlinked class symbol '/RemovedOpenClass' (via class 'RemovedOpenClassImpl2')")) { removedOpenClassImpl2.finalVal } + + expectFailure(linkage("Constructor 'AbstractClassWithChangedConstructorSignature.' can not be called: No constructor found for symbol '/AbstractClassWithChangedConstructorSignature.'")) { AbstractClassWithChangedConstructorSignatureImpl() } + expectFailure(linkage("Constructor 'OpenClassWithChangedConstructorSignature.' can not be called: No constructor found for symbol '/OpenClassWithChangedConstructorSignature.'")) { OpenClassWithChangedConstructorSignatureImpl() } + + expectSuccess("SuperSuperClassReplacedBySuperClass -> SuperClass -> SuperSuperClass -> Any") { superSuperClassReplacedBySuperClass.inheritsFrom() } + expectSuccess(true) { SuperSuperClass::class.isInstance(superSuperClassReplacedBySuperClass) } // This check is done during the runtime. + expectSuccess(true) { SuperClass::class.isInstance(superSuperClassReplacedBySuperClass) } // This check is done during the runtime. + + expectSuccess("SuperClassReplacedBySuperSuperClass -> SuperSuperClass -> Any") { superClassReplacedBySuperSuperClass.inheritsFrom() } + expectSuccess(true) { SuperSuperClass::class.isInstance(superClassReplacedBySuperSuperClass) } // This check is done during the runtime. + expectSuccess(false) { SuperClass::class.isInstance(superClassReplacedBySuperSuperClass) } // This check is done during the runtime. +} diff --git a/compiler/testData/klibABI/removeClassAsSuperTypeArgument/main/module.info b/compiler/testData/klibABI/inheritanceIssues/main/module.info similarity index 100% rename from compiler/testData/klibABI/removeClassAsSuperTypeArgument/main/module.info rename to compiler/testData/klibABI/inheritanceIssues/main/module.info diff --git a/compiler/testData/klibABI/nonAbstractPropertyInInterfaceBecomesAbstract/project.info b/compiler/testData/klibABI/inheritanceIssues/project.info similarity index 100% rename from compiler/testData/klibABI/nonAbstractPropertyInInterfaceBecomesAbstract/project.info rename to compiler/testData/klibABI/inheritanceIssues/project.info diff --git a/compiler/testData/klibABI/nonAbstractCallableBecomesAbstract/lib1/l1.kt.0 b/compiler/testData/klibABI/nonAbstractCallableBecomesAbstract/lib1/l1.kt.0 new file mode 100644 index 00000000000..e3224d82f93 --- /dev/null +++ b/compiler/testData/klibABI/nonAbstractCallableBecomesAbstract/lib1/l1.kt.0 @@ -0,0 +1,26 @@ +package lib1 + +abstract class AbstractClassWithFunctions { + fun foo(): Int = 42 + open fun bar(): Int = 42 + open fun baz(): Int = 42 +} + +interface InterfaceWithFunctions { + fun foo(): Int = 42 + fun bar(): Int = 42 +} + +abstract class AbstractClassWithProperties { + val foo1: Int = 42 + val foo2: Int get() = 42 + open val bar1: Int = 42 + open val bar2: Int get() = 42 + open val baz1: Int = 42 + open val baz2: Int get() = 42 +} + +interface InterfaceWithProperties { + val foo: Int get() = 42 + val bar: Int get() = 42 +} diff --git a/compiler/testData/klibABI/nonAbstractCallableBecomesAbstract/lib1/l1.kt.1 b/compiler/testData/klibABI/nonAbstractCallableBecomesAbstract/lib1/l1.kt.1 new file mode 100644 index 00000000000..132c5777afd --- /dev/null +++ b/compiler/testData/klibABI/nonAbstractCallableBecomesAbstract/lib1/l1.kt.1 @@ -0,0 +1,26 @@ +package lib1 + +abstract class AbstractClassWithFunctions { + abstract fun foo(): Int + abstract fun bar(): Int + abstract fun baz(): Int +} + +interface InterfaceWithFunctions { + fun foo(): Int + fun bar(): Int +} + +abstract class AbstractClassWithProperties { + abstract val foo1: Int + abstract val foo2: Int + abstract val bar1: Int + abstract val bar2: Int + abstract val baz1: Int + abstract val baz2: Int +} + +interface InterfaceWithProperties { + val foo: Int + val bar: Int +} diff --git a/compiler/testData/klibABI/nonAbstractFunctionInAbstractClassBecomesAbstract/lib1/module.info b/compiler/testData/klibABI/nonAbstractCallableBecomesAbstract/lib1/module.info similarity index 100% rename from compiler/testData/klibABI/nonAbstractFunctionInAbstractClassBecomesAbstract/lib1/module.info rename to compiler/testData/klibABI/nonAbstractCallableBecomesAbstract/lib1/module.info diff --git a/compiler/testData/klibABI/nonAbstractCallableBecomesAbstract/lib2/l2.kt b/compiler/testData/klibABI/nonAbstractCallableBecomesAbstract/lib2/l2.kt new file mode 100644 index 00000000000..3d3e256503d --- /dev/null +++ b/compiler/testData/klibABI/nonAbstractCallableBecomesAbstract/lib2/l2.kt @@ -0,0 +1,68 @@ +package lib2 + +import lib1.* + +class AbstractClassWithFunctionsImpl1 : AbstractClassWithFunctions() { + override fun baz() = -42 + val unlinkedFunctionUsage get() = foo() + bar() +} + +class AbstractClassWithFunctionsImpl2 : AbstractClassWithFunctions() { + override fun baz() = -42 + val unlinkedFunctionUsage = foo() // Expected failure on class instance initialization. +} + +class AbstractClassWithFunctionsImpl3 : AbstractClassWithFunctions() { + override fun baz() = -42 + val unlinkedFunctionUsage = bar() // Expected failure on class instance initialization. +} + +class InterfaceWithFunctionsImpl1 : InterfaceWithFunctions { + override fun bar() = -42 + val unlinkedFunctionUsage get() = foo() +} + +class InterfaceWithFunctionsImpl2 : InterfaceWithFunctions { + override fun bar() = -42 + val unlinkedFunctionUsage = foo() // Expected failure on class instance initialization. +} + +class AbstractClassWithPropertiesImpl1 : AbstractClassWithProperties() { + override val baz1 = -42 + override val baz2 get() = -42 + val unlinkedPropertyUsage get() = foo1 + foo2 + bar1 + bar2 +} + +class AbstractClassWithPropertiesImpl2 : AbstractClassWithProperties() { + override val baz1 = -42 + override val baz2 get() = -42 + val unlinkedPropertyUsage = foo1 +} + +class AbstractClassWithPropertiesImpl3 : AbstractClassWithProperties() { + override val baz1 = -42 + override val baz2 get() = -42 + val unlinkedPropertyUsage = foo2 +} + +class AbstractClassWithPropertiesImpl4 : AbstractClassWithProperties() { + override val baz1 = -42 + override val baz2 get() = -42 + val unlinkedPropertyUsage = bar1 +} + +class AbstractClassWithPropertiesImpl5 : AbstractClassWithProperties() { + override val baz1 = -42 + override val baz2 get() = -42 + val unlinkedPropertyUsage = bar2 +} + +class InterfaceWithPropertiesImpl1 : InterfaceWithProperties { + override val bar get() = -42 + val unlinkedPropertyUsage get() = foo +} + +class InterfaceWithPropertiesImpl2 : InterfaceWithProperties { + override val bar get() = -42 + val unlinkedPropertyUsage = foo +} diff --git a/compiler/testData/klibABI/removeClassAsReturnType/lib2/module.info b/compiler/testData/klibABI/nonAbstractCallableBecomesAbstract/lib2/module.info similarity index 100% rename from compiler/testData/klibABI/removeClassAsReturnType/lib2/module.info rename to compiler/testData/klibABI/nonAbstractCallableBecomesAbstract/lib2/module.info diff --git a/compiler/testData/klibABI/nonAbstractCallableBecomesAbstract/main/m.kt b/compiler/testData/klibABI/nonAbstractCallableBecomesAbstract/main/m.kt new file mode 100644 index 00000000000..e5f6ecd98f0 --- /dev/null +++ b/compiler/testData/klibABI/nonAbstractCallableBecomesAbstract/main/m.kt @@ -0,0 +1,43 @@ +import abitestutils.abiTest +import lib1.* +import lib2.* + +fun box() = abiTest { + val abstractClassWithFunctions: AbstractClassWithFunctions = AbstractClassWithFunctionsImpl1() + val abstractClassWithFunctionsImpl1 = AbstractClassWithFunctionsImpl1() + val interfaceWithFunctions: InterfaceWithFunctions = InterfaceWithFunctionsImpl1() + val interfaceWithFunctionsImpl1 = InterfaceWithFunctionsImpl1() + val abstractClassWithProperties: AbstractClassWithProperties = AbstractClassWithPropertiesImpl1() + val abstractClassWithPropertiesImpl1 = AbstractClassWithPropertiesImpl1() + val interfaceWithProperties: InterfaceWithProperties = InterfaceWithPropertiesImpl1() + val interfaceWithPropertiesImpl1 = InterfaceWithPropertiesImpl1() + + expectFailure(nonImplementedCallable("function 'foo'", "class 'AbstractClassWithFunctionsImpl1'")) { abstractClassWithFunctions.foo() } + expectFailure(nonImplementedCallable("function 'bar'", "class 'AbstractClassWithFunctionsImpl1'")) { abstractClassWithFunctions.bar() } + expectSuccess(-42) { abstractClassWithFunctions.baz() } + expectFailure(nonImplementedCallable("function 'foo'", "class 'AbstractClassWithFunctionsImpl1'")) { abstractClassWithFunctionsImpl1.unlinkedFunctionUsage } + expectFailure(nonImplementedCallable("function 'foo'", "class 'AbstractClassWithFunctionsImpl2'")) { AbstractClassWithFunctionsImpl2() } + expectFailure(nonImplementedCallable("function 'bar'", "class 'AbstractClassWithFunctionsImpl3'")) { AbstractClassWithFunctionsImpl3() } + + expectFailure(nonImplementedCallable("function 'foo'", "class 'InterfaceWithFunctionsImpl1'")) { interfaceWithFunctions.foo() } + expectSuccess(-42) { interfaceWithFunctions.bar() } + expectFailure(nonImplementedCallable("function 'foo'", "class 'InterfaceWithFunctionsImpl1'")) { interfaceWithFunctionsImpl1.unlinkedFunctionUsage } + expectFailure(nonImplementedCallable("function 'foo'", "class 'InterfaceWithFunctionsImpl2'")) { InterfaceWithFunctionsImpl2() } + + expectFailure(nonImplementedCallable("property accessor 'foo1.'", "class 'AbstractClassWithPropertiesImpl1'")) { abstractClassWithProperties.foo1 } + expectFailure(nonImplementedCallable("property accessor 'foo2.'", "class 'AbstractClassWithPropertiesImpl1'")) { abstractClassWithProperties.foo2 } + expectFailure(nonImplementedCallable("property accessor 'bar1.'", "class 'AbstractClassWithPropertiesImpl1'")) { abstractClassWithProperties.bar1 } + expectFailure(nonImplementedCallable("property accessor 'bar2.'", "class 'AbstractClassWithPropertiesImpl1'")) { abstractClassWithProperties.bar2 } + expectSuccess(-42) { abstractClassWithProperties.baz1 } + expectSuccess(-42) { abstractClassWithProperties.baz2 } + expectFailure(nonImplementedCallable("property accessor 'foo1.'", "class 'AbstractClassWithPropertiesImpl1'")) { abstractClassWithPropertiesImpl1.unlinkedPropertyUsage } + expectFailure(nonImplementedCallable("property accessor 'foo1.'", "class 'AbstractClassWithPropertiesImpl2'")) { AbstractClassWithPropertiesImpl2() } + expectFailure(nonImplementedCallable("property accessor 'foo2.'", "class 'AbstractClassWithPropertiesImpl3'")) { AbstractClassWithPropertiesImpl3() } + expectFailure(nonImplementedCallable("property accessor 'bar1.'", "class 'AbstractClassWithPropertiesImpl4'")) { AbstractClassWithPropertiesImpl4() } + expectFailure(nonImplementedCallable("property accessor 'bar2.'", "class 'AbstractClassWithPropertiesImpl5'")) { AbstractClassWithPropertiesImpl5() } + + expectFailure(nonImplementedCallable("property accessor 'foo.'", "class 'InterfaceWithPropertiesImpl1'")) { interfaceWithProperties.foo } + expectSuccess(-42) { interfaceWithProperties.bar } + expectFailure(nonImplementedCallable("property accessor 'foo.'", "class 'InterfaceWithPropertiesImpl1'")) { interfaceWithPropertiesImpl1.unlinkedPropertyUsage } + expectFailure(nonImplementedCallable("property accessor 'foo.'", "class 'InterfaceWithPropertiesImpl2'")) { InterfaceWithPropertiesImpl2() } +} diff --git a/compiler/testData/klibABI/nonAbstractFunctionInAbstractClassBecomesAbstract/main/module.info b/compiler/testData/klibABI/nonAbstractCallableBecomesAbstract/main/module.info similarity index 100% rename from compiler/testData/klibABI/nonAbstractFunctionInAbstractClassBecomesAbstract/main/module.info rename to compiler/testData/klibABI/nonAbstractCallableBecomesAbstract/main/module.info diff --git a/compiler/testData/klibABI/removeClassAsConstructorCall/project.info b/compiler/testData/klibABI/nonAbstractCallableBecomesAbstract/project.info similarity index 100% rename from compiler/testData/klibABI/removeClassAsConstructorCall/project.info rename to compiler/testData/klibABI/nonAbstractCallableBecomesAbstract/project.info diff --git a/compiler/testData/klibABI/nonAbstractFunctionInAbstractClassBecomesAbstract/lib1/l1.kt.0 b/compiler/testData/klibABI/nonAbstractFunctionInAbstractClassBecomesAbstract/lib1/l1.kt.0 deleted file mode 100644 index b57eb23fbf4..00000000000 --- a/compiler/testData/klibABI/nonAbstractFunctionInAbstractClassBecomesAbstract/lib1/l1.kt.0 +++ /dev/null @@ -1,7 +0,0 @@ -package lib1 - -abstract class A { - fun foo(): Int = 42 - open fun bar(): Int = 42 - open fun baz(): Int = 42 -} diff --git a/compiler/testData/klibABI/nonAbstractFunctionInAbstractClassBecomesAbstract/lib1/l1.kt.1 b/compiler/testData/klibABI/nonAbstractFunctionInAbstractClassBecomesAbstract/lib1/l1.kt.1 deleted file mode 100644 index 2873ec58c00..00000000000 --- a/compiler/testData/klibABI/nonAbstractFunctionInAbstractClassBecomesAbstract/lib1/l1.kt.1 +++ /dev/null @@ -1,7 +0,0 @@ -package lib1 - -abstract class A { - abstract fun foo(): Int - abstract fun bar(): Int - abstract fun baz(): Int -} diff --git a/compiler/testData/klibABI/nonAbstractFunctionInAbstractClassBecomesAbstract/lib2/l2.kt b/compiler/testData/klibABI/nonAbstractFunctionInAbstractClassBecomesAbstract/lib2/l2.kt deleted file mode 100644 index 733b79b357e..00000000000 --- a/compiler/testData/klibABI/nonAbstractFunctionInAbstractClassBecomesAbstract/lib2/l2.kt +++ /dev/null @@ -1,21 +0,0 @@ -package lib2 - -import lib1.A - -class B : A() { - override fun baz() = -42 - - val unlinkedFunctionUsage get() = foo() + bar() -} - -class B1 : A() { - override fun baz() = -42 - - val unlinkedFunctionUsage = foo() // Expected failure on class instance initialization. -} - -class B2 : A() { - override fun baz() = -42 - - val unlinkedFunctionUsage = bar() // Expected failure on class instance initialization. -} diff --git a/compiler/testData/klibABI/nonAbstractFunctionInAbstractClassBecomesAbstract/main/m.kt b/compiler/testData/klibABI/nonAbstractFunctionInAbstractClassBecomesAbstract/main/m.kt deleted file mode 100644 index d41c6bf963f..00000000000 --- a/compiler/testData/klibABI/nonAbstractFunctionInAbstractClassBecomesAbstract/main/m.kt +++ /dev/null @@ -1,16 +0,0 @@ -import abitestutils.abiTest -import lib1.A -import lib2.B -import lib2.B1 -import lib2.B2 - -fun box() = abiTest { - val a: A = B() - val b = B() - expectFailure(nonImplementedCallable("function foo", "class B")) { a.foo() } - expectFailure(nonImplementedCallable("function bar", "class B")) { a.bar() } - expectSuccess(-42) { a.baz() } - expectFailure(nonImplementedCallable("function foo", "class B")) { b.unlinkedFunctionUsage } - expectFailure(nonImplementedCallable("function foo", "class B1")) { B1() } - expectFailure(nonImplementedCallable("function bar", "class B2")) { B2() } -} diff --git a/compiler/testData/klibABI/nonAbstractFunctionInInterfaceBecomesAbstract/lib1/l1.kt.0 b/compiler/testData/klibABI/nonAbstractFunctionInInterfaceBecomesAbstract/lib1/l1.kt.0 deleted file mode 100644 index 9319100a46e..00000000000 --- a/compiler/testData/klibABI/nonAbstractFunctionInInterfaceBecomesAbstract/lib1/l1.kt.0 +++ /dev/null @@ -1,6 +0,0 @@ -package lib1 - -interface A { - fun foo(): Int = 42 - fun bar(): Int = 42 -} diff --git a/compiler/testData/klibABI/nonAbstractFunctionInInterfaceBecomesAbstract/lib1/l1.kt.1 b/compiler/testData/klibABI/nonAbstractFunctionInInterfaceBecomesAbstract/lib1/l1.kt.1 deleted file mode 100644 index 0e04eaf9bfe..00000000000 --- a/compiler/testData/klibABI/nonAbstractFunctionInInterfaceBecomesAbstract/lib1/l1.kt.1 +++ /dev/null @@ -1,6 +0,0 @@ -package lib1 - -interface A { - fun foo(): Int - fun bar(): Int -} diff --git a/compiler/testData/klibABI/nonAbstractFunctionInInterfaceBecomesAbstract/lib2/l2.kt b/compiler/testData/klibABI/nonAbstractFunctionInInterfaceBecomesAbstract/lib2/l2.kt deleted file mode 100644 index eb0b51ce193..00000000000 --- a/compiler/testData/klibABI/nonAbstractFunctionInInterfaceBecomesAbstract/lib2/l2.kt +++ /dev/null @@ -1,15 +0,0 @@ -package lib2 - -import lib1.A - -class B : A { - override fun bar() = -42 - - val unlinkedFunctionUsage get() = foo() -} - -class B1 : A { - override fun bar() = -42 - - val unlinkedFunctionUsage = foo() // Expected failure on class instance initialization. -} diff --git a/compiler/testData/klibABI/nonAbstractFunctionInInterfaceBecomesAbstract/main/m.kt b/compiler/testData/klibABI/nonAbstractFunctionInInterfaceBecomesAbstract/main/m.kt deleted file mode 100644 index 0c48d857a6e..00000000000 --- a/compiler/testData/klibABI/nonAbstractFunctionInInterfaceBecomesAbstract/main/m.kt +++ /dev/null @@ -1,13 +0,0 @@ -import abitestutils.abiTest -import lib1.A -import lib2.B -import lib2.B1 - -fun box() = abiTest { - val a: A = B() - val b = B() - expectFailure(nonImplementedCallable("function foo", "class B")) { a.foo() } - expectSuccess(-42) { a.bar() } - expectFailure(nonImplementedCallable("function foo", "class B")) { b.unlinkedFunctionUsage } - expectFailure(nonImplementedCallable("function foo", "class B1")) { B1() } -} diff --git a/compiler/testData/klibABI/nonAbstractPropertyInAbstractClassBecomesAbstract/lib1/l1.kt.0 b/compiler/testData/klibABI/nonAbstractPropertyInAbstractClassBecomesAbstract/lib1/l1.kt.0 deleted file mode 100644 index 8de6be7a9e7..00000000000 --- a/compiler/testData/klibABI/nonAbstractPropertyInAbstractClassBecomesAbstract/lib1/l1.kt.0 +++ /dev/null @@ -1,10 +0,0 @@ -package lib1 - -abstract class A { - val foo1: Int = 42 - val foo2: Int get() = 42 - open val bar1: Int = 42 - open val bar2: Int get() = 42 - open val baz1: Int = 42 - open val baz2: Int get() = 42 -} diff --git a/compiler/testData/klibABI/nonAbstractPropertyInAbstractClassBecomesAbstract/lib1/l1.kt.1 b/compiler/testData/klibABI/nonAbstractPropertyInAbstractClassBecomesAbstract/lib1/l1.kt.1 deleted file mode 100644 index 1828df6f146..00000000000 --- a/compiler/testData/klibABI/nonAbstractPropertyInAbstractClassBecomesAbstract/lib1/l1.kt.1 +++ /dev/null @@ -1,10 +0,0 @@ -package lib1 - -abstract class A { - abstract val foo1: Int - abstract val foo2: Int - abstract val bar1: Int - abstract val bar2: Int - abstract val baz1: Int - abstract val baz2: Int -} diff --git a/compiler/testData/klibABI/nonAbstractPropertyInAbstractClassBecomesAbstract/lib1/module.info b/compiler/testData/klibABI/nonAbstractPropertyInAbstractClassBecomesAbstract/lib1/module.info deleted file mode 100644 index 1b0feb46a14..00000000000 --- a/compiler/testData/klibABI/nonAbstractPropertyInAbstractClassBecomesAbstract/lib1/module.info +++ /dev/null @@ -1,12 +0,0 @@ -STEP 0: - dependencies: stdlib - modifications: - U : l1.kt.0 -> l1.kt -STEP 1: - dependencies: stdlib - modifications: - U : l1.kt.1 -> l1.kt -STEP 2: - dependencies: stdlib - modifications: - U : l1.kt.0 -> l1.kt diff --git a/compiler/testData/klibABI/nonAbstractPropertyInAbstractClassBecomesAbstract/lib2/l2.kt b/compiler/testData/klibABI/nonAbstractPropertyInAbstractClassBecomesAbstract/lib2/l2.kt deleted file mode 100644 index d0eed724263..00000000000 --- a/compiler/testData/klibABI/nonAbstractPropertyInAbstractClassBecomesAbstract/lib2/l2.kt +++ /dev/null @@ -1,38 +0,0 @@ -package lib2 - -import lib1.A - -class B : A() { - override val baz1 = -42 - override val baz2 get() = -42 - - val unlinkedPropertyUsage get() = foo1 + foo2 + bar1 + bar2 -} - -class B1 : A() { - override val baz1 = -42 - override val baz2 get() = -42 - - val unlinkedPropertyUsage = foo1 -} - -class B2 : A() { - override val baz1 = -42 - override val baz2 get() = -42 - - val unlinkedPropertyUsage = foo2 -} - -class B3 : A() { - override val baz1 = -42 - override val baz2 get() = -42 - - val unlinkedPropertyUsage = bar1 -} - -class B4 : A() { - override val baz1 = -42 - override val baz2 get() = -42 - - val unlinkedPropertyUsage = bar2 -} diff --git a/compiler/testData/klibABI/nonAbstractPropertyInAbstractClassBecomesAbstract/main/m.kt b/compiler/testData/klibABI/nonAbstractPropertyInAbstractClassBecomesAbstract/main/m.kt deleted file mode 100644 index 4f6d2f2d9da..00000000000 --- a/compiler/testData/klibABI/nonAbstractPropertyInAbstractClassBecomesAbstract/main/m.kt +++ /dev/null @@ -1,23 +0,0 @@ -import abitestutils.abiTest -import lib1.A -import lib2.B -import lib2.B1 -import lib2.B2 -import lib2.B3 -import lib2.B4 - -fun box() = abiTest { - val a: A = B() - val b = B() - expectFailure(nonImplementedCallable("property accessor foo1.", "class B")) { a.foo1 } - expectFailure(nonImplementedCallable("property accessor foo2.", "class B")) { a.foo2 } - expectFailure(nonImplementedCallable("property accessor bar1.", "class B")) { a.bar1 } - expectFailure(nonImplementedCallable("property accessor bar2.", "class B")) { a.bar2 } - expectSuccess(-42) { a.baz1 } - expectSuccess(-42) { a.baz2 } - expectFailure(nonImplementedCallable("property accessor foo1.", "class B")) { b.unlinkedPropertyUsage } - expectFailure(nonImplementedCallable("property accessor foo1.", "class B1")) { B1() } - expectFailure(nonImplementedCallable("property accessor foo2.", "class B2")) { B2() } - expectFailure(nonImplementedCallable("property accessor bar1.", "class B3")) { B3() } - expectFailure(nonImplementedCallable("property accessor bar2.", "class B4")) { B4() } -} diff --git a/compiler/testData/klibABI/nonAbstractPropertyInAbstractClassBecomesAbstract/main/module.info b/compiler/testData/klibABI/nonAbstractPropertyInAbstractClassBecomesAbstract/main/module.info deleted file mode 100644 index c086bdb447b..00000000000 --- a/compiler/testData/klibABI/nonAbstractPropertyInAbstractClassBecomesAbstract/main/module.info +++ /dev/null @@ -1,2 +0,0 @@ -STEP 0: - dependencies: stdlib, lib1, lib2 diff --git a/compiler/testData/klibABI/nonAbstractPropertyInInterfaceBecomesAbstract/lib1/l1.kt.0 b/compiler/testData/klibABI/nonAbstractPropertyInInterfaceBecomesAbstract/lib1/l1.kt.0 deleted file mode 100644 index f4045d60bcf..00000000000 --- a/compiler/testData/klibABI/nonAbstractPropertyInInterfaceBecomesAbstract/lib1/l1.kt.0 +++ /dev/null @@ -1,6 +0,0 @@ -package lib1 - -interface A { - val foo: Int get() = 42 - val bar: Int get() = 42 -} diff --git a/compiler/testData/klibABI/nonAbstractPropertyInInterfaceBecomesAbstract/lib1/l1.kt.1 b/compiler/testData/klibABI/nonAbstractPropertyInInterfaceBecomesAbstract/lib1/l1.kt.1 deleted file mode 100644 index bb732268c84..00000000000 --- a/compiler/testData/klibABI/nonAbstractPropertyInInterfaceBecomesAbstract/lib1/l1.kt.1 +++ /dev/null @@ -1,6 +0,0 @@ -package lib1 - -interface A { - val foo: Int - val bar: Int -} diff --git a/compiler/testData/klibABI/nonAbstractPropertyInInterfaceBecomesAbstract/lib1/module.info b/compiler/testData/klibABI/nonAbstractPropertyInInterfaceBecomesAbstract/lib1/module.info deleted file mode 100644 index 1b0feb46a14..00000000000 --- a/compiler/testData/klibABI/nonAbstractPropertyInInterfaceBecomesAbstract/lib1/module.info +++ /dev/null @@ -1,12 +0,0 @@ -STEP 0: - dependencies: stdlib - modifications: - U : l1.kt.0 -> l1.kt -STEP 1: - dependencies: stdlib - modifications: - U : l1.kt.1 -> l1.kt -STEP 2: - dependencies: stdlib - modifications: - U : l1.kt.0 -> l1.kt diff --git a/compiler/testData/klibABI/nonAbstractPropertyInInterfaceBecomesAbstract/lib2/l2.kt b/compiler/testData/klibABI/nonAbstractPropertyInInterfaceBecomesAbstract/lib2/l2.kt deleted file mode 100644 index 98590395db9..00000000000 --- a/compiler/testData/klibABI/nonAbstractPropertyInInterfaceBecomesAbstract/lib2/l2.kt +++ /dev/null @@ -1,15 +0,0 @@ -package lib2 - -import lib1.A - -class B : A { - override val bar get() = -42 - - val unlinkedPropertyUsage get() = foo -} - -class B1 : A { - override val bar get() = -42 - - val unlinkedPropertyUsage = foo -} diff --git a/compiler/testData/klibABI/nonAbstractPropertyInInterfaceBecomesAbstract/main/m.kt b/compiler/testData/klibABI/nonAbstractPropertyInInterfaceBecomesAbstract/main/m.kt deleted file mode 100644 index fdc20d90b47..00000000000 --- a/compiler/testData/klibABI/nonAbstractPropertyInInterfaceBecomesAbstract/main/m.kt +++ /dev/null @@ -1,13 +0,0 @@ -import abitestutils.abiTest -import lib1.A -import lib2.B -import lib2.B1 - -fun box() = abiTest { - val a: A = B() - val b = B() - expectFailure(nonImplementedCallable("property accessor foo.", "class B")) { a.foo } - expectSuccess(-42) { a.bar } - expectFailure(nonImplementedCallable("property accessor foo.", "class B")) { b.unlinkedPropertyUsage } - expectFailure(nonImplementedCallable("property accessor foo.", "class B1")) { B1() } -} diff --git a/compiler/testData/klibABI/nonAbstractPropertyInInterfaceBecomesAbstract/main/module.info b/compiler/testData/klibABI/nonAbstractPropertyInInterfaceBecomesAbstract/main/module.info deleted file mode 100644 index c086bdb447b..00000000000 --- a/compiler/testData/klibABI/nonAbstractPropertyInInterfaceBecomesAbstract/main/module.info +++ /dev/null @@ -1,2 +0,0 @@ -STEP 0: - dependencies: stdlib, lib1, lib2 diff --git a/compiler/testData/klibABI/nonExhaustivenessOfWhenClause/lib1/l1.kt b/compiler/testData/klibABI/nonExhaustivenessOfWhenClause/lib1/l1.kt new file mode 100644 index 00000000000..2cc256f6b28 --- /dev/null +++ b/compiler/testData/klibABI/nonExhaustivenessOfWhenClause/lib1/l1.kt @@ -0,0 +1,27 @@ +sealed interface SI1 { + class A : SI1 + class B : SI1 +} + +sealed class SC1 { + class A: SC1() + class B: SC1() +} + +enum class E1 { + A, B +} + +enum class E2 { + A, B +} + +sealed interface SI2 { + class ClassToObject : SI2 + object ObjectToClass : SI2 +} + +sealed class SC2 { + class ClassToObject : SC2() + object ObjectToClass : SC2() +} diff --git a/compiler/testData/klibABI/nonExhaustivenessOfWhenClause/lib1/l1.kt.1 b/compiler/testData/klibABI/nonExhaustivenessOfWhenClause/lib1/l1.kt.1 new file mode 100644 index 00000000000..98a568ce9e8 --- /dev/null +++ b/compiler/testData/klibABI/nonExhaustivenessOfWhenClause/lib1/l1.kt.1 @@ -0,0 +1,29 @@ +/*sealed*/ interface SI1 { + class A : SI1 + class B : SI1 +} + +/*sealed*/ abstract class SC1 { + class A: SC1() + class B: SC1() +} + +abstract class E1 { + object A : E1() + object B : E1() +} + +abstract class E2 { + class A : E2() + class B : E2() +} + +sealed interface SI2 { + object ClassToObject : SI2 + class ObjectToClass : SI2 +} + +sealed class SC2 { + object ClassToObject : SC2() + class ObjectToClass : SC2() +} diff --git a/compiler/testData/klibABI/removeFunction/lib1/module.info b/compiler/testData/klibABI/nonExhaustivenessOfWhenClause/lib1/module.info similarity index 100% rename from compiler/testData/klibABI/removeFunction/lib1/module.info rename to compiler/testData/klibABI/nonExhaustivenessOfWhenClause/lib1/module.info diff --git a/compiler/testData/klibABI/nonExhaustivenessOfWhenClause/lib2/l2.kt b/compiler/testData/klibABI/nonExhaustivenessOfWhenClause/lib2/l2.kt new file mode 100644 index 00000000000..d33acf75f94 --- /dev/null +++ b/compiler/testData/klibABI/nonExhaustivenessOfWhenClause/lib2/l2.kt @@ -0,0 +1,29 @@ +fun computeSC1(sealedClass: SC1): String = when (sealedClass) { + is SC1.A -> "A" + is SC1.B -> "B" +} + +fun computeSI1(sealedInterface: SI1): String = when (sealedInterface) { + is SI1.A -> "A" + is SI1.B -> "B" +} + +fun computeE1(enum: E1): String = when (enum) { + E1.A -> "A" + E1.B -> "B" +} + +fun computeE2(enum: E2): String = when (enum) { + E2.A -> "A" + E2.B -> "B" +} + +fun computeSC2(sealedClass: SC2): String = when (sealedClass) { + is SC2.ClassToObject -> "ClassToObject" + SC2.ObjectToClass -> "ObjectToClass" +} + +fun computeSI2(sealedInterface: SI2): String = when (sealedInterface) { + is SI2.ClassToObject -> "ClassToObject" + SI2.ObjectToClass -> "ObjectToClass" +} diff --git a/compiler/testData/klibABI/removeClassAsSuperTypeArgument/lib2/module.info b/compiler/testData/klibABI/nonExhaustivenessOfWhenClause/lib2/module.info similarity index 100% rename from compiler/testData/klibABI/removeClassAsSuperTypeArgument/lib2/module.info rename to compiler/testData/klibABI/nonExhaustivenessOfWhenClause/lib2/module.info diff --git a/compiler/testData/klibABI/nonExhaustivenessOfWhenClause/main/m.kt b/compiler/testData/klibABI/nonExhaustivenessOfWhenClause/main/m.kt new file mode 100644 index 00000000000..e96975c2d64 --- /dev/null +++ b/compiler/testData/klibABI/nonExhaustivenessOfWhenClause/main/m.kt @@ -0,0 +1,30 @@ +import abitestutils.abiTest + +fun box() = abiTest { + class SI1_C : SI1 + class SC1_C : SC1() + class E1_C : E1() + class E2_C : E2() + + expectSuccess("A") { computeSI1(SI1.A()) } + expectFailure(noWhenBranch()) { computeSI1(SI1_C()) } + expectSuccess("B") { computeSI1(SI1.B()) } + + expectSuccess("A") { computeSC1(SC1.A()) } + expectFailure(noWhenBranch()) { computeSC1(SC1_C()) } + expectSuccess("B") { computeSC1(SC1.B()) } + + expectFailure(linkage("Can not get instance of singleton 'E1.A': No enum entry found for symbol '/E1.A'")) { computeE1(E1.A) } + expectFailure(linkage("Can not get instance of singleton 'E1.A': No enum entry found for symbol '/E1.A'")) { computeE1(E1_C()) } + expectFailure(linkage("Can not get instance of singleton 'E1.A': No enum entry found for symbol '/E1.A'")) { computeE1(E1.B) } + + expectFailure(linkage("Can not get instance of singleton 'E2.A': No enum entry found for symbol '/E2.A'")) { computeE2(E2.A()) } + expectFailure(linkage("Can not get instance of singleton 'E2.A': No enum entry found for symbol '/E2.A'")) { computeE2(E2_C()) } + expectFailure(linkage("Can not get instance of singleton 'E2.A': No enum entry found for symbol '/E2.A'")) { computeE2(E2.B()) } + + expectSuccess("ClassToObject") { computeSI2(SI2.ClassToObject) } + expectFailure(linkage("Can not get instance of singleton 'ObjectToClass': 'ObjectToClass' is class while object is expected")) { computeSI2(SI2.ObjectToClass()) } + + expectSuccess("ClassToObject") { computeSC2(SC2.ClassToObject) } + expectFailure(linkage("Can not get instance of singleton 'ObjectToClass': 'ObjectToClass' is class while object is expected")) { computeSC2(SC2.ObjectToClass()) } +} diff --git a/compiler/testData/klibABI/removeOpenProperty/main/module.info b/compiler/testData/klibABI/nonExhaustivenessOfWhenClause/main/module.info similarity index 81% rename from compiler/testData/klibABI/removeOpenProperty/main/module.info rename to compiler/testData/klibABI/nonExhaustivenessOfWhenClause/main/module.info index 62f7f4fab07..de4760c9c67 100644 --- a/compiler/testData/klibABI/removeOpenProperty/main/module.info +++ b/compiler/testData/klibABI/nonExhaustivenessOfWhenClause/main/module.info @@ -1,2 +1,2 @@ -STEP 0: +STEP 1: dependencies: stdlib, lib1, lib2 \ No newline at end of file diff --git a/compiler/testData/klibABI/removeAbstractPropertyFromAbstractClass/project.info b/compiler/testData/klibABI/nonExhaustivenessOfWhenClause/project.info similarity index 56% rename from compiler/testData/klibABI/removeAbstractPropertyFromAbstractClass/project.info rename to compiler/testData/klibABI/nonExhaustivenessOfWhenClause/project.info index 01ef0b966c5..f006dfc6fe8 100644 --- a/compiler/testData/klibABI/removeAbstractPropertyFromAbstractClass/project.info +++ b/compiler/testData/klibABI/nonExhaustivenessOfWhenClause/project.info @@ -1,10 +1,7 @@ MODULES: lib1, lib2, main STEP 0: - libs: lib1, lib2, main - -STEP 1: libs: lib1, lib2 -STEP 2: - libs: lib1 +STEP 1: + libs: lib1, main \ No newline at end of file diff --git a/compiler/testData/klibABI/propertyTransformations/lib1/l1.kt b/compiler/testData/klibABI/propertyTransformations/lib1/l1.kt new file mode 100644 index 00000000000..0971a813be8 --- /dev/null +++ b/compiler/testData/klibABI/propertyTransformations/lib1/l1.kt @@ -0,0 +1,34 @@ +@file:Suppress("unused", "UNUSED_PARAMETER", "NOTHING_TO_INLINE") + +open class OpenClass { + @Suppress("MemberVisibilityCanBePrivate") + var lastRecordedState: String = "" + + open var openNonInlineToInlineProperty: String + get() = "OpenClass.openNonInlineToInlineProperty" + set(value) { lastRecordedState = "OpenClass.openNonInlineToInlineProperty=$value" } + + open var openNonInlineToInlinePropertyWithDelegation: String + get() = "OpenClass.openNonInlineToInlinePropertyWithDelegation" + set(value) { lastRecordedState = "OpenClass.openNonInlineToInlinePropertyWithDelegation=$value" } + + //inline var newInlineProperty1: String + // get() = "OpenClass.newInlineProperty1" + // set(value) { lastRecordedState = "OpenClass.newInlineProperty1=$value" } + + //inline var newInlineProperty2: String + // get() = "OpenClass.newInlineProperty2" + // set(value) { lastRecordedState = "OpenClass.newInlineProperty2=$value" } + + //var newNonInlineProperty: String + // get() = "OpenClass.newNonInlineProperty" + // set(value) { lastRecordedState = "OpenClass.newNonInlineProperty=$value" } + + fun newInlineProperty1Reader(): String = TODO("Not implemented: OpenClass.newInlineProperty1Reader()") + fun newInlineProperty2Reader(): String = TODO("Not implemented: OpenClass.newInlineProperty2Reader()") + fun newNonInlinePropertyReader(): String = TODO("Not implemented: OpenClass.newNonInlinePropertyReader()") + + fun newInlineProperty1Writer(value: String): Unit = TODO("Not implemented: OpenClass.newInlineProperty1Writer()") + fun newInlineProperty2Writer(value: String): Unit = TODO("Not implemented: OpenClass.newInlineProperty2Writer()") + fun newNonInlinePropertyWriter(value: String): Unit = TODO("Not implemented: OpenClass.newNonInlinePropertyWriter()") +} diff --git a/compiler/testData/klibABI/propertyTransformations/lib1/l1.kt.1 b/compiler/testData/klibABI/propertyTransformations/lib1/l1.kt.1 new file mode 100644 index 00000000000..649ba93b032 --- /dev/null +++ b/compiler/testData/klibABI/propertyTransformations/lib1/l1.kt.1 @@ -0,0 +1,34 @@ +@file:Suppress("unused", "UNUSED_PARAMETER", "NOTHING_TO_INLINE") + +open class OpenClass { + @Suppress("MemberVisibilityCanBePrivate") + var lastRecordedState: String = "" + + inline var openNonInlineToInlineProperty: String + get() = "OpenClassV2.openNonInlineToInlineProperty" + set(value) { lastRecordedState = "OpenClassV2.openNonInlineToInlineProperty=$value" } + + inline var openNonInlineToInlinePropertyWithDelegation: String + get() = "OpenClassV2.openNonInlineToInlinePropertyWithDelegation" + set(value) { lastRecordedState = "OpenClassV2.openNonInlineToInlinePropertyWithDelegation=$value" } + + inline var newInlineProperty1: String + get() = "OpenClassV2.newInlineProperty1" + set(value) { lastRecordedState = "OpenClassV2.newInlineProperty1=$value" } + + inline var newInlineProperty2: String + get() = "OpenClassV2.newInlineProperty2" + set(value) { lastRecordedState = "OpenClassV2.newInlineProperty2=$value" } + + var newNonInlineProperty: String + get() = "OpenClassV2.newNonInlineProperty" + set(value) { lastRecordedState = "OpenClassV2.newNonInlineProperty=$value" } + + fun newInlineProperty1Reader(): String = newInlineProperty1 + fun newInlineProperty2Reader(): String = newInlineProperty2 + fun newNonInlinePropertyReader(): String = newNonInlineProperty + + fun newInlineProperty1Writer(value: String) { newInlineProperty1 = value } + fun newInlineProperty2Writer(value: String) { newInlineProperty2 = value } + fun newNonInlinePropertyWriter(value: String) { newNonInlineProperty = value } +} diff --git a/compiler/testData/klibABI/removeInlinedClass/lib1/module.info b/compiler/testData/klibABI/propertyTransformations/lib1/module.info similarity index 100% rename from compiler/testData/klibABI/removeInlinedClass/lib1/module.info rename to compiler/testData/klibABI/propertyTransformations/lib1/module.info diff --git a/compiler/testData/klibABI/propertyTransformations/lib2/l2.kt b/compiler/testData/klibABI/propertyTransformations/lib2/l2.kt new file mode 100644 index 00000000000..eaee3127434 --- /dev/null +++ b/compiler/testData/klibABI/propertyTransformations/lib2/l2.kt @@ -0,0 +1,45 @@ +class OpenClassImpl : OpenClass() { + override var openNonInlineToInlineProperty: String + get() = "OpenClassImpl.openNonInlineToInlineProperty" + set(value) { lastRecordedState = "OpenClassImpl.openNonInlineToInlineProperty=$value" } + + override var openNonInlineToInlinePropertyWithDelegation: String + get() = super.openNonInlineToInlinePropertyWithDelegation + " called from OpenClassImpl.openNonInlineToInlinePropertyWithDelegation" + set(value) { super.openNonInlineToInlinePropertyWithDelegation = "$value called from OpenClassImpl.openNonInlineToInlinePropertyWithDelegation" } + + var newInlineProperty1: String // overrides accidentally appeared inline property + get() = "OpenClassImpl.newInlineProperty1" + set(value) { lastRecordedState = "OpenClassImpl.newInlineProperty1=$value" } + + inline var newInlineProperty2: String // overrides accidentally appeared inline property + get() = "OpenClassImpl.newInlineProperty2" + set(value) { lastRecordedState = "OpenClassImpl.newInlineProperty2=$value" } + + inline var newNonInlineProperty: String // overrides accidentally appeared non-inline function + get() = "OpenClassImpl.newNonInlineProperty" + set(value) { lastRecordedState = "OpenClassImpl.newNonInlineProperty=$value" } +} + +fun openNonInlineToInlinePropertyInOpenClass(oc: OpenClass): String = oc.openNonInlineToInlineProperty +fun openNonInlineToInlinePropertyWithDelegationInOpenClass(oc: OpenClass): String = oc.openNonInlineToInlinePropertyWithDelegation +fun newInlineProperty1InOpenClass(oc: OpenClass): String = oc.newInlineProperty1Reader() +fun newInlineProperty2InOpenClass(oc: OpenClass): String = oc.newInlineProperty2Reader() +fun newNonInlinePropertyInOpenClass(oc: OpenClass): String = oc.newNonInlinePropertyReader() + +fun openNonInlineToInlinePropertyInOpenClassImpl(oci: OpenClassImpl): String = oci.openNonInlineToInlineProperty +fun openNonInlineToInlinePropertyWithDelegationInOpenClassImpl(oci: OpenClassImpl): String = oci.openNonInlineToInlinePropertyWithDelegation +fun newInlineProperty1InOpenClassImpl(oci: OpenClassImpl): String = oci.newInlineProperty1 +fun newInlineProperty2InOpenClassImpl(oci: OpenClassImpl): String = oci.newInlineProperty2 +fun newNonInlinePropertyInOpenClassImpl(oci: OpenClassImpl): String = oci.newNonInlineProperty + +fun openNonInlineToInlinePropertyInOpenClass(oc: OpenClass, value: String): String { oc.openNonInlineToInlineProperty = value; return oc.lastRecordedState } +fun openNonInlineToInlinePropertyWithDelegationInOpenClass(oc: OpenClass, value: String): String { oc.openNonInlineToInlinePropertyWithDelegation = value; return oc.lastRecordedState } +fun newInlineProperty1InOpenClass(oc: OpenClass, value: String): String { oc.newInlineProperty1Writer(value); return oc.lastRecordedState } +fun newInlineProperty2InOpenClass(oc: OpenClass, value: String): String { oc.newInlineProperty2Writer(value); return oc.lastRecordedState } +fun newNonInlinePropertyInOpenClass(oc: OpenClass, value: String): String { oc.newNonInlinePropertyWriter(value); return oc.lastRecordedState } + +fun openNonInlineToInlinePropertyInOpenClassImpl(oci: OpenClassImpl, value: String): String { oci.openNonInlineToInlineProperty = value; return oci.lastRecordedState } +fun openNonInlineToInlinePropertyWithDelegationInOpenClassImpl(oci: OpenClassImpl, value: String): String { oci.openNonInlineToInlinePropertyWithDelegation = value; return oci.lastRecordedState } +fun newInlineProperty1InOpenClassImpl(oci: OpenClassImpl, value: String): String { oci.newInlineProperty1 = value; return oci.lastRecordedState } +fun newInlineProperty2InOpenClassImpl(oci: OpenClassImpl, value: String): String { oci.newInlineProperty2 = value; return oci.lastRecordedState } +fun newNonInlinePropertyInOpenClassImpl(oci: OpenClassImpl, value: String): String { oci.newNonInlineProperty = value; return oci.lastRecordedState } diff --git a/compiler/testData/klibABI/removeClassAsTypeArgument/lib2/module.info b/compiler/testData/klibABI/propertyTransformations/lib2/module.info similarity index 100% rename from compiler/testData/klibABI/removeClassAsTypeArgument/lib2/module.info rename to compiler/testData/klibABI/propertyTransformations/lib2/module.info diff --git a/compiler/testData/klibABI/propertyTransformations/main/m.kt b/compiler/testData/klibABI/propertyTransformations/main/m.kt new file mode 100644 index 00000000000..084ce76d9d1 --- /dev/null +++ b/compiler/testData/klibABI/propertyTransformations/main/m.kt @@ -0,0 +1,34 @@ +import abitestutils.abiTest + +fun box() = abiTest { + val oci: OpenClassImpl = OpenClassImpl() + val oc: OpenClass = oci + + expectSuccess("OpenClassV2.openNonInlineToInlineProperty") { openNonInlineToInlinePropertyInOpenClass(oc) } + expectSuccess("OpenClassV2.openNonInlineToInlinePropertyWithDelegation") { openNonInlineToInlinePropertyWithDelegationInOpenClass(oc) } + expectSuccess("OpenClassV2.newInlineProperty1") { newInlineProperty1InOpenClass(oc) } + expectSuccess("OpenClassV2.newInlineProperty2") { newInlineProperty2InOpenClass(oc) } + expectSuccess( // TODO: this should be fixed in JS, KT-56762 + if (testMode.isJs) "OpenClassImpl.newNonInlineProperty" else "OpenClassV2.newNonInlineProperty" + ) { newNonInlinePropertyInOpenClass(oc) } + + expectSuccess("OpenClassImpl.openNonInlineToInlineProperty") { openNonInlineToInlinePropertyInOpenClassImpl(oci) } + expectSuccess("OpenClassV2.openNonInlineToInlinePropertyWithDelegation called from OpenClassImpl.openNonInlineToInlinePropertyWithDelegation") { openNonInlineToInlinePropertyWithDelegationInOpenClassImpl(oci) } + expectSuccess("OpenClassImpl.newInlineProperty1") { newInlineProperty1InOpenClassImpl(oci) } + expectSuccess("OpenClassImpl.newInlineProperty2") { newInlineProperty2InOpenClassImpl(oci) } + expectSuccess("OpenClassImpl.newNonInlineProperty") { newNonInlinePropertyInOpenClassImpl(oci) } + + expectSuccess("OpenClassV2.openNonInlineToInlineProperty=a") { openNonInlineToInlinePropertyInOpenClass(oc, "a") } + expectSuccess("OpenClassV2.openNonInlineToInlinePropertyWithDelegation=b") { openNonInlineToInlinePropertyWithDelegationInOpenClass(oc, "b") } + expectSuccess("OpenClassV2.newInlineProperty1=c") { newInlineProperty1InOpenClass(oc, "c") } + expectSuccess("OpenClassV2.newInlineProperty2=d") { newInlineProperty2InOpenClass(oc, "d") } + expectSuccess( // TODO: this should be fixed in JS, KT-56762 + if (testMode.isJs) "OpenClassImpl.newNonInlineProperty=e" else "OpenClassV2.newNonInlineProperty=e" + ) { newNonInlinePropertyInOpenClass(oc, "e") } + + expectSuccess("OpenClassImpl.openNonInlineToInlineProperty=f") { openNonInlineToInlinePropertyInOpenClassImpl(oci, "f") } + expectSuccess("OpenClassV2.openNonInlineToInlinePropertyWithDelegation=h called from OpenClassImpl.openNonInlineToInlinePropertyWithDelegation") { openNonInlineToInlinePropertyWithDelegationInOpenClassImpl(oci, "h") } + expectSuccess("OpenClassImpl.newInlineProperty1=i") { newInlineProperty1InOpenClassImpl(oci, "i") } + expectSuccess("OpenClassImpl.newInlineProperty2=j") { newInlineProperty2InOpenClassImpl(oci, "j") } + expectSuccess("OpenClassImpl.newNonInlineProperty=k") { newNonInlinePropertyInOpenClassImpl(oci, "k") } +} diff --git a/compiler/testData/klibABI/removeClassAsTypeArgument/main/module.info b/compiler/testData/klibABI/propertyTransformations/main/module.info similarity index 100% rename from compiler/testData/klibABI/removeClassAsTypeArgument/main/module.info rename to compiler/testData/klibABI/propertyTransformations/main/module.info diff --git a/compiler/testData/klibABI/removeClassAsParameterType/project.info b/compiler/testData/klibABI/propertyTransformations/project.info similarity index 100% rename from compiler/testData/klibABI/removeClassAsParameterType/project.info rename to compiler/testData/klibABI/propertyTransformations/project.info diff --git a/compiler/testData/klibABI/referencingUnusableDeclarations/lib1/l1.kt b/compiler/testData/klibABI/referencingUnusableDeclarations/lib1/l1.kt new file mode 100644 index 00000000000..97132a7a2d5 --- /dev/null +++ b/compiler/testData/klibABI/referencingUnusableDeclarations/lib1/l1.kt @@ -0,0 +1,21 @@ +open class RemovedClass { + val p1 = "p1" + fun f1() = "f1" +} + +interface RemovedInterface { + val p1: String + val p2 get() = "p2" + fun f1(): String + fun f2() = "f2" +} + +class ClassWithChangedMembers { + fun removedFun() = "removedFun" + fun changedFun(x: String) = x +} + +interface InterfaceWithChangedMembers { + fun removedFun() = "removedFun" + fun changedFun(x: String) = x +} diff --git a/compiler/testData/klibABI/referencingUnusableDeclarations/lib1/l1.kt.1 b/compiler/testData/klibABI/referencingUnusableDeclarations/lib1/l1.kt.1 new file mode 100644 index 00000000000..e30553f2280 --- /dev/null +++ b/compiler/testData/klibABI/referencingUnusableDeclarations/lib1/l1.kt.1 @@ -0,0 +1,23 @@ +//open class RemovedClass { +// val p1 = "p1" +// fun f1() = "f1" +//} + +//interface RemovedInterface { +// val p1: String +// val p2 get() = "p2" +// fun f1(): String +// fun f2() = "f2" +//} + +class ClassWithChangedMembers { +// fun removedFun() = "removedFun" +// fun changedFun(x: String) = x + fun changedFun(x: Int) = x.toString() +} + +interface InterfaceWithChangedMembers { +// fun removedFun() = "removedFun" +// fun changedFun(x: String) = x + fun changedFun(x: Int) = x.toString() +} diff --git a/compiler/testData/klibABI/removeInlinedFunction/lib1/module.info b/compiler/testData/klibABI/referencingUnusableDeclarations/lib1/module.info similarity index 100% rename from compiler/testData/klibABI/removeInlinedFunction/lib1/module.info rename to compiler/testData/klibABI/referencingUnusableDeclarations/lib1/module.info diff --git a/compiler/testData/klibABI/referencingUnusableDeclarations/lib2/l2.kt b/compiler/testData/klibABI/referencingUnusableDeclarations/lib2/l2.kt new file mode 100644 index 00000000000..2281f1dcc8b --- /dev/null +++ b/compiler/testData/klibABI/referencingUnusableDeclarations/lib2/l2.kt @@ -0,0 +1,74 @@ +class RemovedClassImpl : RemovedClass() { + val p2 = "p2" + fun f2() = "f2" +} + +class RemovedInterfaceImpl : RemovedInterface { + override val p1 = "p1" + val p3 = "p3" + override fun f1() = "f1" + fun f3() = "f3" +} + +// This is required to check that function references for unchanged classes are evaluated correctly. +class StableClass { + fun foo(i: Int): String = i.toString() + inner class Inner { + fun bar(i: Int): String = i.toString() + } +} + +fun functionWithUnlinkedParameter(p: RemovedClass?) = "functionWithUnlinkedParameter" +fun functionWithUnlinkedReturnValue(): RemovedClass = TODO("functionWithUnlinkedReturnValue") +fun functionWithRemovedTypeParameter(a: Any?): T = TODO("functionWithRemovedTypeParameter") + +fun referenceRemovedClassReference(): String = RemovedClass::class.simpleName.orEmpty() +fun referenceRemovedClassConstructorReference(): String = ::RemovedClass.name +fun referenceRemovedClassProperty1Reference(): String = RemovedClass::p1.name +fun referenceRemovedClassFunction1Reference(): String = RemovedClass::f1.name + +fun referenceRemovedClassImplReference(): String = RemovedClassImpl::class.simpleName.orEmpty() +fun referenceRemovedClassImplConstructorReference(): String = ::RemovedClassImpl.name +fun referenceRemovedClassImplProperty1Reference(): String = RemovedClassImpl::p1.name +fun referenceRemovedClassImplProperty2Reference(): String = RemovedClassImpl::p2.name +fun referenceRemovedClassImplFunction1Reference(): String = RemovedClassImpl::f1.name +fun referenceRemovedClassImplFunction2Reference(): String = RemovedClassImpl::f2.name + +fun referenceRemovedInterfaceReference(): String = RemovedInterface::class.simpleName.orEmpty() +fun referenceRemovedInterfaceProperty1Reference(): String = RemovedInterface::p1.name +fun referenceRemovedInterfaceProperty2Reference(): String = RemovedInterface::p2.name +fun referenceRemovedInterfaceFunction1Reference(): String = RemovedInterface::f1.name +fun referenceRemovedInterfaceFunction2Reference(): String = RemovedInterface::f2.name + +fun referenceRemovedInterfaceImplReference(): String = RemovedInterfaceImpl::class.simpleName.orEmpty() +fun referenceRemovedInterfaceImplProperty1Reference(): String = RemovedInterfaceImpl::p1.name +fun referenceRemovedInterfaceImplProperty2Reference(): String = RemovedInterfaceImpl::p2.name +fun referenceRemovedInterfaceImplProperty3Reference(): String = RemovedInterfaceImpl::p3.name +fun referenceRemovedInterfaceImplFunction1Reference(): String = RemovedInterfaceImpl::f1.name +fun referenceRemovedInterfaceImplFunction2Reference(): String = RemovedInterfaceImpl::f2.name +fun referenceRemovedInterfaceImplFunction3Reference(): String = RemovedInterfaceImpl::f3.name + +fun referenceStableClassConstructor(): String = ::StableClass.name +fun referenceStableClassMemberFunctionWithoutDispatchReceiver(): String = StableClass::foo.name +fun referenceStableClassMemberFunctionWithDispatchReceiver(stableClass: StableClass): String = stableClass::foo.name +fun referenceStableClassInnerConstructorWithoutDispatchReceiver(): String = StableClass::Inner.name +fun referenceStableClassInnerConstructorWithDispatchReceiver(stableClass: StableClass): String = stableClass::Inner.name +fun referenceStableClassInnerMemberFunctionWithoutDispatchReceiver(): String = StableClass.Inner::bar.name +fun referenceStableClassInnerMemberFunctionWithDispatchReceiver(stableClassInner: StableClass.Inner): String = stableClassInner::bar.name + +fun referenceRemovedFunFromClass(): String = ClassWithChangedMembers::removedFun.name +fun referenceChangedFunFromClass(): String = ClassWithChangedMembers::changedFun.name +fun referenceRemovedFunFromInterface(): String = InterfaceWithChangedMembers::removedFun.name +fun referenceChangedFunFromInterface(): String = InterfaceWithChangedMembers::changedFun.name + +fun referenceFunctionWithUnlinkedParameter(): String = ::functionWithUnlinkedParameter.name +fun referenceFunctionWithUnlinkedReturnValue(): String = ::functionWithUnlinkedReturnValue.name +fun referenceFunctionWithRemovedTypeParameter(): String { + /* + * The syntax of function references does not allow explicitly specifying type arguments. + * The compiler will report "Not enough information to infer type variable T" error on + * `::functionWithRemovedTypeParameter` statement. So let's put the reference into + * the context with evident type arguments. + */ + return listOf(null).map(::functionWithRemovedTypeParameter).joinToString() +} diff --git a/compiler/testData/klibABI/removeClassAsVariableType/lib2/module.info b/compiler/testData/klibABI/referencingUnusableDeclarations/lib2/module.info similarity index 100% rename from compiler/testData/klibABI/removeClassAsVariableType/lib2/module.info rename to compiler/testData/klibABI/referencingUnusableDeclarations/lib2/module.info diff --git a/compiler/testData/klibABI/referencingUnusableDeclarations/main/m.kt b/compiler/testData/klibABI/referencingUnusableDeclarations/main/m.kt new file mode 100644 index 00000000000..9f4d8940913 --- /dev/null +++ b/compiler/testData/klibABI/referencingUnusableDeclarations/main/m.kt @@ -0,0 +1,49 @@ +import abitestutils.abiTest + +fun box() = abiTest { + val stableClass = StableClass() + val stableClassInner = stableClass.Inner() + + expectFailure(linkage("Reference to class 'RemovedClass' can not be evaluated: No class found for symbol '/RemovedClass'")) { referenceRemovedClassReference() } + expectFailure(linkage("Reference to constructor 'RemovedClass.' can not be evaluated: No constructor found for symbol '/RemovedClass.'")) { referenceRemovedClassConstructorReference() } + expectFailure(linkage("Reference to property 'p1' can not be evaluated: No property found for symbol '/RemovedClass.p1'")) { referenceRemovedClassProperty1Reference() } + expectFailure(linkage("Reference to function 'f1' can not be evaluated: No function found for symbol '/RemovedClass.f1'")) { referenceRemovedClassFunction1Reference() } + + expectFailure(linkage("Reference to class 'RemovedClassImpl' can not be evaluated: Expression uses unlinked class symbol '/RemovedClass' (via class 'RemovedClassImpl')")) { referenceRemovedClassImplReference() } + expectFailure(linkage("Reference to constructor 'RemovedClassImpl.' can not be evaluated: Class 'RemovedClassImpl' uses unlinked class symbol '/RemovedClass'")) { referenceRemovedClassImplConstructorReference() } + expectFailure(linkage("Reference to property 'p1' can not be evaluated: No property found for symbol '/RemovedClassImpl.p1'")) { referenceRemovedClassImplProperty1Reference() } + expectFailure(linkage("Reference to property 'p2' can not be evaluated: Dispatch receiver class 'RemovedClassImpl' uses unlinked class symbol '/RemovedClass'")) { referenceRemovedClassImplProperty2Reference() } + expectFailure(linkage("Reference to function 'f1' can not be evaluated: No function found for symbol '/RemovedClassImpl.f1'")) { referenceRemovedClassImplFunction1Reference() } + expectFailure(linkage("Reference to function 'f2' can not be evaluated: Dispatch receiver class 'RemovedClassImpl' uses unlinked class symbol '/RemovedClass'")) { referenceRemovedClassImplFunction2Reference() } + + expectFailure(linkage("Reference to class 'RemovedInterface' can not be evaluated: No class found for symbol '/RemovedInterface'")) { referenceRemovedInterfaceReference() } + expectFailure(linkage("Reference to property 'p1' can not be evaluated: No property found for symbol '/RemovedInterface.p1'")) { referenceRemovedInterfaceProperty1Reference() } + expectFailure(linkage("Reference to property 'p2' can not be evaluated: No property found for symbol '/RemovedInterface.p2'")) { referenceRemovedInterfaceProperty2Reference() } + expectFailure(linkage("Reference to function 'f1' can not be evaluated: No function found for symbol '/RemovedInterface.f1'")) { referenceRemovedInterfaceFunction1Reference() } + expectFailure(linkage("Reference to function 'f2' can not be evaluated: No function found for symbol '/RemovedInterface.f2'")) { referenceRemovedInterfaceFunction2Reference() } + + expectFailure(linkage("Reference to class 'RemovedInterfaceImpl' can not be evaluated: Expression uses unlinked class symbol '/RemovedInterface' (via class 'RemovedInterfaceImpl')")) { referenceRemovedInterfaceImplReference() } + expectFailure(linkage("Reference to property 'p1' can not be evaluated: Dispatch receiver class 'RemovedInterfaceImpl' uses unlinked class symbol '/RemovedInterface'")) { referenceRemovedInterfaceImplProperty1Reference() } + expectFailure(linkage("Reference to property 'p2' can not be evaluated: No property found for symbol '/RemovedInterfaceImpl.p2'")) { referenceRemovedInterfaceImplProperty2Reference() } + expectFailure(linkage("Reference to property 'p3' can not be evaluated: Dispatch receiver class 'RemovedInterfaceImpl' uses unlinked class symbol '/RemovedInterface'")) { referenceRemovedInterfaceImplProperty3Reference() } + expectFailure(linkage("Reference to function 'f1' can not be evaluated: Dispatch receiver class 'RemovedInterfaceImpl' uses unlinked class symbol '/RemovedInterface'")) { referenceRemovedInterfaceImplFunction1Reference() } + expectFailure(linkage("Reference to function 'f2' can not be evaluated: No function found for symbol '/RemovedInterfaceImpl.f2'")) { referenceRemovedInterfaceImplFunction2Reference() } + expectFailure(linkage("Reference to function 'f3' can not be evaluated: Dispatch receiver class 'RemovedInterfaceImpl' uses unlinked class symbol '/RemovedInterface'")) { referenceRemovedInterfaceImplFunction3Reference() } + + expectSuccess("") { referenceStableClassConstructor() } + expectSuccess("foo") { referenceStableClassMemberFunctionWithoutDispatchReceiver() } + expectSuccess("foo") { referenceStableClassMemberFunctionWithDispatchReceiver(stableClass) } + expectSuccess("") { referenceStableClassInnerConstructorWithoutDispatchReceiver() } + expectSuccess("") { referenceStableClassInnerConstructorWithDispatchReceiver(stableClass) } + expectSuccess("bar") { referenceStableClassInnerMemberFunctionWithoutDispatchReceiver() } + expectSuccess("bar") { referenceStableClassInnerMemberFunctionWithDispatchReceiver(stableClassInner) } + + expectFailure(linkage("Reference to function 'removedFun' can not be evaluated: No function found for symbol '/ClassWithChangedMembers.removedFun'")) { referenceRemovedFunFromClass() } + expectFailure(linkage("Reference to function 'changedFun' can not be evaluated: No function found for symbol '/ClassWithChangedMembers.changedFun'")) { referenceChangedFunFromClass() } + expectFailure(linkage("Reference to function 'removedFun' can not be evaluated: No function found for symbol '/InterfaceWithChangedMembers.removedFun'")) { referenceRemovedFunFromInterface() } + expectFailure(linkage("Reference to function 'changedFun' can not be evaluated: No function found for symbol '/InterfaceWithChangedMembers.changedFun'")) { referenceChangedFunFromInterface() } + + expectFailure(linkage("Reference to function 'functionWithUnlinkedParameter' can not be evaluated: Function uses unlinked class symbol '/RemovedClass'")) { referenceFunctionWithUnlinkedParameter() } + expectFailure(linkage("Reference to function 'functionWithUnlinkedReturnValue' can not be evaluated: Function uses unlinked class symbol '/RemovedClass'")) { referenceFunctionWithUnlinkedReturnValue() } + expectFailure(linkage("Reference to function 'functionWithRemovedTypeParameter' can not be evaluated: Function uses unlinked class symbol '/RemovedClass' (via type parameter 'T')")) { referenceFunctionWithRemovedTypeParameter() } +} diff --git a/compiler/testData/klibABI/removeClassAsVariableType/main/module.info b/compiler/testData/klibABI/referencingUnusableDeclarations/main/module.info similarity index 100% rename from compiler/testData/klibABI/removeClassAsVariableType/main/module.info rename to compiler/testData/klibABI/referencingUnusableDeclarations/main/module.info diff --git a/compiler/testData/klibABI/removeClassAsReturnType/project.info b/compiler/testData/klibABI/referencingUnusableDeclarations/project.info similarity index 100% rename from compiler/testData/klibABI/removeClassAsReturnType/project.info rename to compiler/testData/klibABI/referencingUnusableDeclarations/project.info diff --git a/compiler/testData/klibABI/removeAbstractCallableFromAbstractClassOrInterface/lib1/l1.kt.0 b/compiler/testData/klibABI/removeAbstractCallableFromAbstractClassOrInterface/lib1/l1.kt.0 new file mode 100644 index 00000000000..192fac41463 --- /dev/null +++ b/compiler/testData/klibABI/removeAbstractCallableFromAbstractClassOrInterface/lib1/l1.kt.0 @@ -0,0 +1,11 @@ +package lib1 + +abstract class AbstractClass { + abstract fun foo(): Int + abstract val bar: Int +} + +interface Interface { + fun foo(): Int + val bar: Int +} diff --git a/compiler/testData/klibABI/removeAbstractCallableFromAbstractClassOrInterface/lib1/l1.kt.1 b/compiler/testData/klibABI/removeAbstractCallableFromAbstractClassOrInterface/lib1/l1.kt.1 new file mode 100644 index 00000000000..17b4517822f --- /dev/null +++ b/compiler/testData/klibABI/removeAbstractCallableFromAbstractClassOrInterface/lib1/l1.kt.1 @@ -0,0 +1,4 @@ +package lib1 + +open class AbstractClass +interface Interface diff --git a/compiler/testData/klibABI/nonAbstractFunctionInInterfaceBecomesAbstract/lib1/module.info b/compiler/testData/klibABI/removeAbstractCallableFromAbstractClassOrInterface/lib1/module.info similarity index 100% rename from compiler/testData/klibABI/nonAbstractFunctionInInterfaceBecomesAbstract/lib1/module.info rename to compiler/testData/klibABI/removeAbstractCallableFromAbstractClassOrInterface/lib1/module.info diff --git a/compiler/testData/klibABI/removeAbstractCallableFromAbstractClassOrInterface/lib2/l2.kt b/compiler/testData/klibABI/removeAbstractCallableFromAbstractClassOrInterface/lib2/l2.kt new file mode 100644 index 00000000000..3af27625410 --- /dev/null +++ b/compiler/testData/klibABI/removeAbstractCallableFromAbstractClassOrInterface/lib2/l2.kt @@ -0,0 +1,13 @@ +package lib2 + +import lib1.* + +class AbstractClassImpl : AbstractClass() { + override fun foo() = 42 + override val bar = 42 +} + +class InterfaceImpl : Interface { + override fun foo() = 42 + override val bar = 42 +} diff --git a/compiler/testData/klibABI/removeAbstractCallableFromAbstractClassOrInterface/lib2/l2.kt.1 b/compiler/testData/klibABI/removeAbstractCallableFromAbstractClassOrInterface/lib2/l2.kt.1 new file mode 100644 index 00000000000..9b415feb857 --- /dev/null +++ b/compiler/testData/klibABI/removeAbstractCallableFromAbstractClassOrInterface/lib2/l2.kt.1 @@ -0,0 +1,6 @@ +package lib2 + +import lib1.* + +class AbstractClassImpl : AbstractClass() +class InterfaceImpl : Interface diff --git a/compiler/testData/klibABI/removeAbstractFunctionFromAbstractClass/lib2/module.info b/compiler/testData/klibABI/removeAbstractCallableFromAbstractClassOrInterface/lib2/module.info similarity index 100% rename from compiler/testData/klibABI/removeAbstractFunctionFromAbstractClass/lib2/module.info rename to compiler/testData/klibABI/removeAbstractCallableFromAbstractClassOrInterface/lib2/module.info diff --git a/compiler/testData/klibABI/removeAbstractCallableFromAbstractClassOrInterface/main/m.kt b/compiler/testData/klibABI/removeAbstractCallableFromAbstractClassOrInterface/main/m.kt new file mode 100644 index 00000000000..26e0a3a0380 --- /dev/null +++ b/compiler/testData/klibABI/removeAbstractCallableFromAbstractClassOrInterface/main/m.kt @@ -0,0 +1,13 @@ +import abitestutils.abiTest +import lib1.* +import lib2.* + +fun box() = abiTest { + val abstractClass: AbstractClass = AbstractClassImpl() + val _interface: Interface = InterfaceImpl() + + expectFailure(nonImplementedCallable("function 'foo'", "class 'AbstractClassImpl'")) { abstractClass.foo() } + expectFailure(nonImplementedCallable("property accessor 'bar.'", "class 'AbstractClassImpl'")) { abstractClass.bar } + expectFailure(nonImplementedCallable("function 'foo'", "class 'InterfaceImpl'")) { _interface.foo() } + expectFailure(nonImplementedCallable("property accessor 'bar.'", "class 'InterfaceImpl'")) { _interface.bar } +} diff --git a/compiler/testData/klibABI/nonAbstractFunctionInInterfaceBecomesAbstract/main/module.info b/compiler/testData/klibABI/removeAbstractCallableFromAbstractClassOrInterface/main/module.info similarity index 100% rename from compiler/testData/klibABI/nonAbstractFunctionInInterfaceBecomesAbstract/main/module.info rename to compiler/testData/klibABI/removeAbstractCallableFromAbstractClassOrInterface/main/module.info diff --git a/compiler/testData/klibABI/removeAbstractFunctionFromAbstractClass/project.info b/compiler/testData/klibABI/removeAbstractCallableFromAbstractClassOrInterface/project.info similarity index 100% rename from compiler/testData/klibABI/removeAbstractFunctionFromAbstractClass/project.info rename to compiler/testData/klibABI/removeAbstractCallableFromAbstractClassOrInterface/project.info diff --git a/compiler/testData/klibABI/removeAbstractFunctionFromAbstractClass/lib1/l1.kt.0 b/compiler/testData/klibABI/removeAbstractFunctionFromAbstractClass/lib1/l1.kt.0 deleted file mode 100644 index 041e4d719b2..00000000000 --- a/compiler/testData/klibABI/removeAbstractFunctionFromAbstractClass/lib1/l1.kt.0 +++ /dev/null @@ -1,5 +0,0 @@ -package lib1 - -abstract class A { - abstract fun foo(): Int -} diff --git a/compiler/testData/klibABI/removeAbstractFunctionFromAbstractClass/lib1/l1.kt.1 b/compiler/testData/klibABI/removeAbstractFunctionFromAbstractClass/lib1/l1.kt.1 deleted file mode 100644 index 643e7128adb..00000000000 --- a/compiler/testData/klibABI/removeAbstractFunctionFromAbstractClass/lib1/l1.kt.1 +++ /dev/null @@ -1,3 +0,0 @@ -package lib1 - -open class A diff --git a/compiler/testData/klibABI/removeAbstractFunctionFromAbstractClass/lib1/module.info b/compiler/testData/klibABI/removeAbstractFunctionFromAbstractClass/lib1/module.info deleted file mode 100644 index 1b0feb46a14..00000000000 --- a/compiler/testData/klibABI/removeAbstractFunctionFromAbstractClass/lib1/module.info +++ /dev/null @@ -1,12 +0,0 @@ -STEP 0: - dependencies: stdlib - modifications: - U : l1.kt.0 -> l1.kt -STEP 1: - dependencies: stdlib - modifications: - U : l1.kt.1 -> l1.kt -STEP 2: - dependencies: stdlib - modifications: - U : l1.kt.0 -> l1.kt diff --git a/compiler/testData/klibABI/removeAbstractFunctionFromAbstractClass/lib2/l2.kt b/compiler/testData/klibABI/removeAbstractFunctionFromAbstractClass/lib2/l2.kt deleted file mode 100644 index e4ea1d42149..00000000000 --- a/compiler/testData/klibABI/removeAbstractFunctionFromAbstractClass/lib2/l2.kt +++ /dev/null @@ -1,7 +0,0 @@ -package lib2 - -import lib1.A - -class B : A() { - override fun foo() = 42 -} diff --git a/compiler/testData/klibABI/removeAbstractFunctionFromAbstractClass/lib2/l2.kt.1 b/compiler/testData/klibABI/removeAbstractFunctionFromAbstractClass/lib2/l2.kt.1 deleted file mode 100644 index 689b57a3e7e..00000000000 --- a/compiler/testData/klibABI/removeAbstractFunctionFromAbstractClass/lib2/l2.kt.1 +++ /dev/null @@ -1,5 +0,0 @@ -package lib2 - -import lib1.A - -class B : A() diff --git a/compiler/testData/klibABI/removeAbstractFunctionFromAbstractClass/main/m.kt b/compiler/testData/klibABI/removeAbstractFunctionFromAbstractClass/main/m.kt deleted file mode 100644 index f500a7be4d8..00000000000 --- a/compiler/testData/klibABI/removeAbstractFunctionFromAbstractClass/main/m.kt +++ /dev/null @@ -1,8 +0,0 @@ -import abitestutils.abiTest -import lib1.A -import lib2.B - -fun box() = abiTest { - val a: A = B() - expectFailure(nonImplementedCallable("function foo", "class B")) { a.foo() } -} diff --git a/compiler/testData/klibABI/removeAbstractFunctionFromAbstractClass/main/module.info b/compiler/testData/klibABI/removeAbstractFunctionFromAbstractClass/main/module.info deleted file mode 100644 index c086bdb447b..00000000000 --- a/compiler/testData/klibABI/removeAbstractFunctionFromAbstractClass/main/module.info +++ /dev/null @@ -1,2 +0,0 @@ -STEP 0: - dependencies: stdlib, lib1, lib2 diff --git a/compiler/testData/klibABI/removeAbstractFunctionFromInterface/lib1/l1.kt.0 b/compiler/testData/klibABI/removeAbstractFunctionFromInterface/lib1/l1.kt.0 deleted file mode 100644 index 688079b8143..00000000000 --- a/compiler/testData/klibABI/removeAbstractFunctionFromInterface/lib1/l1.kt.0 +++ /dev/null @@ -1,5 +0,0 @@ -package lib1 - -interface A { - fun foo(): Int -} diff --git a/compiler/testData/klibABI/removeAbstractFunctionFromInterface/lib1/l1.kt.1 b/compiler/testData/klibABI/removeAbstractFunctionFromInterface/lib1/l1.kt.1 deleted file mode 100644 index 35f41d66f33..00000000000 --- a/compiler/testData/klibABI/removeAbstractFunctionFromInterface/lib1/l1.kt.1 +++ /dev/null @@ -1,3 +0,0 @@ -package lib1 - -interface A diff --git a/compiler/testData/klibABI/removeAbstractFunctionFromInterface/lib1/module.info b/compiler/testData/klibABI/removeAbstractFunctionFromInterface/lib1/module.info deleted file mode 100644 index 1b0feb46a14..00000000000 --- a/compiler/testData/klibABI/removeAbstractFunctionFromInterface/lib1/module.info +++ /dev/null @@ -1,12 +0,0 @@ -STEP 0: - dependencies: stdlib - modifications: - U : l1.kt.0 -> l1.kt -STEP 1: - dependencies: stdlib - modifications: - U : l1.kt.1 -> l1.kt -STEP 2: - dependencies: stdlib - modifications: - U : l1.kt.0 -> l1.kt diff --git a/compiler/testData/klibABI/removeAbstractFunctionFromInterface/lib2/l2.kt b/compiler/testData/klibABI/removeAbstractFunctionFromInterface/lib2/l2.kt deleted file mode 100644 index 96514a44eef..00000000000 --- a/compiler/testData/klibABI/removeAbstractFunctionFromInterface/lib2/l2.kt +++ /dev/null @@ -1,7 +0,0 @@ -package lib2 - -import lib1.A - -class B : A { - override fun foo() = 42 -} diff --git a/compiler/testData/klibABI/removeAbstractFunctionFromInterface/lib2/l2.kt.1 b/compiler/testData/klibABI/removeAbstractFunctionFromInterface/lib2/l2.kt.1 deleted file mode 100644 index bb27e5dfe0e..00000000000 --- a/compiler/testData/klibABI/removeAbstractFunctionFromInterface/lib2/l2.kt.1 +++ /dev/null @@ -1,5 +0,0 @@ -package lib2 - -import lib1.A - -class B : A diff --git a/compiler/testData/klibABI/removeAbstractFunctionFromInterface/lib2/module.info b/compiler/testData/klibABI/removeAbstractFunctionFromInterface/lib2/module.info deleted file mode 100644 index 52781d50089..00000000000 --- a/compiler/testData/klibABI/removeAbstractFunctionFromInterface/lib2/module.info +++ /dev/null @@ -1,6 +0,0 @@ -STEP 0: - dependencies: stdlib, lib1 -STEP 1: - dependencies: stdlib, lib1 - modifications: - U : l2.kt.1 -> l2.kt diff --git a/compiler/testData/klibABI/removeAbstractFunctionFromInterface/main/m.kt b/compiler/testData/klibABI/removeAbstractFunctionFromInterface/main/m.kt deleted file mode 100644 index f500a7be4d8..00000000000 --- a/compiler/testData/klibABI/removeAbstractFunctionFromInterface/main/m.kt +++ /dev/null @@ -1,8 +0,0 @@ -import abitestutils.abiTest -import lib1.A -import lib2.B - -fun box() = abiTest { - val a: A = B() - expectFailure(nonImplementedCallable("function foo", "class B")) { a.foo() } -} diff --git a/compiler/testData/klibABI/removeAbstractFunctionFromInterface/main/module.info b/compiler/testData/klibABI/removeAbstractFunctionFromInterface/main/module.info deleted file mode 100644 index c086bdb447b..00000000000 --- a/compiler/testData/klibABI/removeAbstractFunctionFromInterface/main/module.info +++ /dev/null @@ -1,2 +0,0 @@ -STEP 0: - dependencies: stdlib, lib1, lib2 diff --git a/compiler/testData/klibABI/removeAbstractPropertyFromAbstractClass/lib1/l1.kt.0 b/compiler/testData/klibABI/removeAbstractPropertyFromAbstractClass/lib1/l1.kt.0 deleted file mode 100644 index ff3abffa1cc..00000000000 --- a/compiler/testData/klibABI/removeAbstractPropertyFromAbstractClass/lib1/l1.kt.0 +++ /dev/null @@ -1,5 +0,0 @@ -package lib1 - -abstract class A { - abstract val foo: Int -} diff --git a/compiler/testData/klibABI/removeAbstractPropertyFromAbstractClass/lib1/l1.kt.1 b/compiler/testData/klibABI/removeAbstractPropertyFromAbstractClass/lib1/l1.kt.1 deleted file mode 100644 index 643e7128adb..00000000000 --- a/compiler/testData/klibABI/removeAbstractPropertyFromAbstractClass/lib1/l1.kt.1 +++ /dev/null @@ -1,3 +0,0 @@ -package lib1 - -open class A diff --git a/compiler/testData/klibABI/removeAbstractPropertyFromAbstractClass/lib1/module.info b/compiler/testData/klibABI/removeAbstractPropertyFromAbstractClass/lib1/module.info deleted file mode 100644 index 1b0feb46a14..00000000000 --- a/compiler/testData/klibABI/removeAbstractPropertyFromAbstractClass/lib1/module.info +++ /dev/null @@ -1,12 +0,0 @@ -STEP 0: - dependencies: stdlib - modifications: - U : l1.kt.0 -> l1.kt -STEP 1: - dependencies: stdlib - modifications: - U : l1.kt.1 -> l1.kt -STEP 2: - dependencies: stdlib - modifications: - U : l1.kt.0 -> l1.kt diff --git a/compiler/testData/klibABI/removeAbstractPropertyFromAbstractClass/lib2/l2.kt b/compiler/testData/klibABI/removeAbstractPropertyFromAbstractClass/lib2/l2.kt deleted file mode 100644 index 88215b3d21c..00000000000 --- a/compiler/testData/klibABI/removeAbstractPropertyFromAbstractClass/lib2/l2.kt +++ /dev/null @@ -1,7 +0,0 @@ -package lib2 - -import lib1.A - -class B : A() { - override val foo = 42 -} diff --git a/compiler/testData/klibABI/removeAbstractPropertyFromAbstractClass/lib2/l2.kt.1 b/compiler/testData/klibABI/removeAbstractPropertyFromAbstractClass/lib2/l2.kt.1 deleted file mode 100644 index 689b57a3e7e..00000000000 --- a/compiler/testData/klibABI/removeAbstractPropertyFromAbstractClass/lib2/l2.kt.1 +++ /dev/null @@ -1,5 +0,0 @@ -package lib2 - -import lib1.A - -class B : A() diff --git a/compiler/testData/klibABI/removeAbstractPropertyFromAbstractClass/lib2/module.info b/compiler/testData/klibABI/removeAbstractPropertyFromAbstractClass/lib2/module.info deleted file mode 100644 index 52781d50089..00000000000 --- a/compiler/testData/klibABI/removeAbstractPropertyFromAbstractClass/lib2/module.info +++ /dev/null @@ -1,6 +0,0 @@ -STEP 0: - dependencies: stdlib, lib1 -STEP 1: - dependencies: stdlib, lib1 - modifications: - U : l2.kt.1 -> l2.kt diff --git a/compiler/testData/klibABI/removeAbstractPropertyFromAbstractClass/main/m.kt b/compiler/testData/klibABI/removeAbstractPropertyFromAbstractClass/main/m.kt deleted file mode 100644 index 812710794ca..00000000000 --- a/compiler/testData/klibABI/removeAbstractPropertyFromAbstractClass/main/m.kt +++ /dev/null @@ -1,8 +0,0 @@ -import abitestutils.abiTest -import lib1.A -import lib2.B - -fun box() = abiTest { - val a: A = B() - expectFailure(nonImplementedCallable("property accessor foo.", "class B")) { a.foo } -} diff --git a/compiler/testData/klibABI/removeAbstractPropertyFromAbstractClass/main/module.info b/compiler/testData/klibABI/removeAbstractPropertyFromAbstractClass/main/module.info deleted file mode 100644 index c086bdb447b..00000000000 --- a/compiler/testData/klibABI/removeAbstractPropertyFromAbstractClass/main/module.info +++ /dev/null @@ -1,2 +0,0 @@ -STEP 0: - dependencies: stdlib, lib1, lib2 diff --git a/compiler/testData/klibABI/removeAbstractPropertyFromInterface/lib1/l1.kt.0 b/compiler/testData/klibABI/removeAbstractPropertyFromInterface/lib1/l1.kt.0 deleted file mode 100644 index 35d826f18e9..00000000000 --- a/compiler/testData/klibABI/removeAbstractPropertyFromInterface/lib1/l1.kt.0 +++ /dev/null @@ -1,5 +0,0 @@ -package lib1 - -interface A { - val foo: Int -} diff --git a/compiler/testData/klibABI/removeAbstractPropertyFromInterface/lib1/l1.kt.1 b/compiler/testData/klibABI/removeAbstractPropertyFromInterface/lib1/l1.kt.1 deleted file mode 100644 index 35f41d66f33..00000000000 --- a/compiler/testData/klibABI/removeAbstractPropertyFromInterface/lib1/l1.kt.1 +++ /dev/null @@ -1,3 +0,0 @@ -package lib1 - -interface A diff --git a/compiler/testData/klibABI/removeAbstractPropertyFromInterface/lib1/module.info b/compiler/testData/klibABI/removeAbstractPropertyFromInterface/lib1/module.info deleted file mode 100644 index 1b0feb46a14..00000000000 --- a/compiler/testData/klibABI/removeAbstractPropertyFromInterface/lib1/module.info +++ /dev/null @@ -1,12 +0,0 @@ -STEP 0: - dependencies: stdlib - modifications: - U : l1.kt.0 -> l1.kt -STEP 1: - dependencies: stdlib - modifications: - U : l1.kt.1 -> l1.kt -STEP 2: - dependencies: stdlib - modifications: - U : l1.kt.0 -> l1.kt diff --git a/compiler/testData/klibABI/removeAbstractPropertyFromInterface/lib2/l2.kt b/compiler/testData/klibABI/removeAbstractPropertyFromInterface/lib2/l2.kt deleted file mode 100644 index d57ed28e691..00000000000 --- a/compiler/testData/klibABI/removeAbstractPropertyFromInterface/lib2/l2.kt +++ /dev/null @@ -1,7 +0,0 @@ -package lib2 - -import lib1.A - -class B : A { - override val foo = 42 -} diff --git a/compiler/testData/klibABI/removeAbstractPropertyFromInterface/lib2/l2.kt.1 b/compiler/testData/klibABI/removeAbstractPropertyFromInterface/lib2/l2.kt.1 deleted file mode 100644 index bb27e5dfe0e..00000000000 --- a/compiler/testData/klibABI/removeAbstractPropertyFromInterface/lib2/l2.kt.1 +++ /dev/null @@ -1,5 +0,0 @@ -package lib2 - -import lib1.A - -class B : A diff --git a/compiler/testData/klibABI/removeAbstractPropertyFromInterface/lib2/module.info b/compiler/testData/klibABI/removeAbstractPropertyFromInterface/lib2/module.info deleted file mode 100644 index 52781d50089..00000000000 --- a/compiler/testData/klibABI/removeAbstractPropertyFromInterface/lib2/module.info +++ /dev/null @@ -1,6 +0,0 @@ -STEP 0: - dependencies: stdlib, lib1 -STEP 1: - dependencies: stdlib, lib1 - modifications: - U : l2.kt.1 -> l2.kt diff --git a/compiler/testData/klibABI/removeAbstractPropertyFromInterface/main/m.kt b/compiler/testData/klibABI/removeAbstractPropertyFromInterface/main/m.kt deleted file mode 100644 index 812710794ca..00000000000 --- a/compiler/testData/klibABI/removeAbstractPropertyFromInterface/main/m.kt +++ /dev/null @@ -1,8 +0,0 @@ -import abitestutils.abiTest -import lib1.A -import lib2.B - -fun box() = abiTest { - val a: A = B() - expectFailure(nonImplementedCallable("property accessor foo.", "class B")) { a.foo } -} diff --git a/compiler/testData/klibABI/removeAbstractPropertyFromInterface/main/module.info b/compiler/testData/klibABI/removeAbstractPropertyFromInterface/main/module.info deleted file mode 100644 index c086bdb447b..00000000000 --- a/compiler/testData/klibABI/removeAbstractPropertyFromInterface/main/module.info +++ /dev/null @@ -1,2 +0,0 @@ -STEP 0: - dependencies: stdlib, lib1, lib2 diff --git a/compiler/testData/klibABI/removeCallable/lib1/l1.kt b/compiler/testData/klibABI/removeCallable/lib1/l1.kt new file mode 100644 index 00000000000..efdddf41e3f --- /dev/null +++ b/compiler/testData/klibABI/removeCallable/lib1/l1.kt @@ -0,0 +1,23 @@ +fun function(): String = "FAIL: function" +fun removedFunction(): String = "FAIL: removedFunction" +val property: String get() = "FAIL: property" +val removedProperty: String get() = "FAIL: removedProperty" + +class A { + fun function(): String = "FAIL: A.function" + fun removedFunction(): String = "FAIL: A.removedFunction" + val property1: String get() = "FAIL: property1" + val removedProperty1: String get() = "FAIL: removedProperty1" + val property2: String = "FAIL: property2" + val removedProperty2: String = "FAIL: removedProperty2" +} + +open class C { + open fun removedOpenFunction(): String = "FAIL: C.removedOpenFunction" + open val removedOpenProperty: String get() = "FAIL: C.removedOpenProperty" +} + +interface I { + fun removedOpenFunction(): String = "FAIL: I.removedOpenFunction" + val removedOpenProperty: String get() = "FAIL: I.removedOpenProperty" +} diff --git a/compiler/testData/klibABI/removeCallable/lib1/l1.kt.1 b/compiler/testData/klibABI/removeCallable/lib1/l1.kt.1 new file mode 100644 index 00000000000..e17eb214fb1 --- /dev/null +++ b/compiler/testData/klibABI/removeCallable/lib1/l1.kt.1 @@ -0,0 +1,23 @@ +fun function(): String = "OK" +//fun removedFunction(): String = "FAIL: removedFunction" +val property: String get() = "OK" +//val removedProperty: String get() = "FAIL: removedProperty" + +class A { + fun function(): String = "OK" + //fun removedFunction(): String = "FAIL: A.removedFunction" + val property1: String get() = "OK" + //val removedProperty1: String get() = "FAIL: removedProperty1" + val property2: String = "OK" + //val removedProperty2: String = "FAIL: removedProperty2" +} + +open class C { + //open fun removedOpenFunction(): String = "FAIL: C.removedOpenFunction" + //open val removedOpenProperty: String get() = "FAIL: C.removedOpenProperty" +} + +interface I { + //fun removedOpenFunction(): String = "FAIL: I.removedOpenFunction" + //val removedOpenProperty: String get() = "FAIL: I.removedOpenProperty" +} diff --git a/compiler/testData/klibABI/removeInlinedProperty/lib1/module.info b/compiler/testData/klibABI/removeCallable/lib1/module.info similarity index 100% rename from compiler/testData/klibABI/removeInlinedProperty/lib1/module.info rename to compiler/testData/klibABI/removeCallable/lib1/module.info diff --git a/compiler/testData/klibABI/removeCallable/lib2/l2.kt b/compiler/testData/klibABI/removeCallable/lib2/l2.kt new file mode 100644 index 00000000000..3290e49b474 --- /dev/null +++ b/compiler/testData/klibABI/removeCallable/lib2/l2.kt @@ -0,0 +1,19 @@ +fun callRemovedOrNormalFunction(removed: Boolean): String = if (removed) removedFunction() else function() +fun callRemovedOrNormalFunctionOnObject(removed: Boolean): String = if (removed) A().removedFunction() else A().function() + +fun readRemovedOrNormalProperty(removed: Boolean): String = if (removed) removedProperty else property +fun readRemovedOrNormalPropertyOnObject1(removed: Boolean): String = if (removed) A().removedProperty1 else A().property1 +fun readRemovedOrNormalPropertyOnObject2(removed: Boolean): String = if (removed) A().removedProperty2 else A().property2 + +inline fun callInlinedRemovedFunction() = removedFunction() +inline fun readInlinedRemovedProperty() = removedProperty + +class C2 : C() { + override fun removedOpenFunction(): String = "O" // does not call super + override val removedOpenProperty: String get() = "O" // does not call super +} + +class I2 : I { + override fun removedOpenFunction(): String = "K" // does not call super + override val removedOpenProperty: String get() = "K" // does not call super +} diff --git a/compiler/testData/klibABI/removeFunction/lib2/module.info b/compiler/testData/klibABI/removeCallable/lib2/module.info similarity index 100% rename from compiler/testData/klibABI/removeFunction/lib2/module.info rename to compiler/testData/klibABI/removeCallable/lib2/module.info diff --git a/compiler/testData/klibABI/removeCallable/main/m.kt b/compiler/testData/klibABI/removeCallable/main/m.kt new file mode 100644 index 00000000000..59d2672287a --- /dev/null +++ b/compiler/testData/klibABI/removeCallable/main/m.kt @@ -0,0 +1,21 @@ +import abitestutils.abiTest + +fun box() = abiTest { + expectFailure(linkage("Function 'removedFunction' can not be called: No function found for symbol '/removedFunction'")) { callRemovedOrNormalFunction(removed = true) } + expectSuccess { callRemovedOrNormalFunction(removed = false) } + expectFailure(linkage("Function 'removedFunction' can not be called: No function found for symbol '/A.removedFunction'")) { callRemovedOrNormalFunctionOnObject(removed = true) } + expectSuccess { callRemovedOrNormalFunctionOnObject(removed = false) } + + expectFailure(linkage("Property accessor 'removedProperty.' can not be called: No property accessor found for symbol '/removedProperty.'")) { readRemovedOrNormalProperty(removed = true) } + expectSuccess { readRemovedOrNormalProperty(removed = false) } + expectFailure(linkage("Property accessor 'removedProperty1.' can not be called: No property accessor found for symbol '/A.removedProperty1.'")) { readRemovedOrNormalPropertyOnObject1(removed = true) } + expectSuccess { readRemovedOrNormalPropertyOnObject1(removed = false) } + expectFailure(linkage("Property accessor 'removedProperty2.' can not be called: No property accessor found for symbol '/A.removedProperty2.'")) { readRemovedOrNormalPropertyOnObject2(removed = true) } + expectSuccess { readRemovedOrNormalPropertyOnObject2(removed = false) } + + expectFailure(linkage("Function 'removedFunction' can not be called: No function found for symbol '/removedFunction'")) { callInlinedRemovedFunction() } + expectFailure(linkage("Property accessor 'removedProperty.' can not be called: No property accessor found for symbol '/removedProperty.'")) { readInlinedRemovedProperty() } + + expectSuccess { C2().removedOpenFunction() + I2().removedOpenFunction() } + expectSuccess { C2().removedOpenProperty + I2().removedOpenProperty } +} diff --git a/compiler/testData/klibABI/removeFunction/main/module.info b/compiler/testData/klibABI/removeCallable/main/module.info similarity index 100% rename from compiler/testData/klibABI/removeFunction/main/module.info rename to compiler/testData/klibABI/removeCallable/main/module.info diff --git a/compiler/testData/klibABI/removeClassAsSuperTypeArgument/project.info b/compiler/testData/klibABI/removeCallable/project.info similarity index 100% rename from compiler/testData/klibABI/removeClassAsSuperTypeArgument/project.info rename to compiler/testData/klibABI/removeCallable/project.info diff --git a/compiler/testData/klibABI/removeClass/lib1/l1.kt b/compiler/testData/klibABI/removeClass/lib1/l1.kt new file mode 100644 index 00000000000..49233a9f0f7 --- /dev/null +++ b/compiler/testData/klibABI/removeClass/lib1/l1.kt @@ -0,0 +1,15 @@ +class Class { + fun f() = "FAIL: Class.f" + val p get() = "FAIL: Class.p" + override fun toString() = "FAIL: Class.toString" +} + +class RemovedClass { + fun f() = "FAIL: RemovedClass.f" + val p get() = "FAIL: RemovedClass.p" +} + +abstract class RemovedAbstractClass +interface RemovedInterface + +open class RemovedOpenClass diff --git a/compiler/testData/klibABI/removeClass/lib1/l1.kt.1 b/compiler/testData/klibABI/removeClass/lib1/l1.kt.1 new file mode 100644 index 00000000000..f8ebcc59744 --- /dev/null +++ b/compiler/testData/klibABI/removeClass/lib1/l1.kt.1 @@ -0,0 +1,15 @@ +class Class { + fun f() = "Class.f" + val p get() = "Class.p" + override fun toString() = "Class" +} + +//class RemovedClass { +// fun f() = "FAIL: RemovedClass.f" +// val p get() = "FAIL: RemovedClass.p" +//} + +//abstract class RemovedAbstractClass +//interface RemovedInterface + +//open class RemovedOpenClass diff --git a/compiler/testData/klibABI/removeOpenFunction/lib1/module.info b/compiler/testData/klibABI/removeClass/lib1/module.info similarity index 100% rename from compiler/testData/klibABI/removeOpenFunction/lib1/module.info rename to compiler/testData/klibABI/removeClass/lib1/module.info diff --git a/compiler/testData/klibABI/removeClass/lib2/l2.kt b/compiler/testData/klibABI/removeClass/lib2/l2.kt new file mode 100644 index 00000000000..8cf3a59d096 --- /dev/null +++ b/compiler/testData/klibABI/removeClass/lib2/l2.kt @@ -0,0 +1,271 @@ +fun createRemovedClass() { + check(RemovedClass().toString() != "Yellow Submarine") +} + +interface Interface { + val value: T +} + +class InterfaceImplParameterizedByClass : Interface { + override val value: Class = Class() +} + +class InterfaceImplParameterizedByRemovedClass: Interface { + override val value: RemovedClass = TODO() +} + +class Checker { + fun useClassAsValueParameter(c: Class): String = "Checker.useClassAsValueParameter($c)" + fun createAndPassClassAsValueParameter(): String = useClassAsValueParameter(Class()) + + fun useRemovedClassAsValueParameter(e: RemovedClass?): String = "FAIL: useRemovedClassAsValueParameter" + fun createAndPassRemovedClassAsValueParameter(): String = useRemovedClassAsValueParameter(null) + + var removedClassProperty: RemovedClass? = null + protected set(value) { /* Do nothing */ } + + fun writeToRemovedClassProperty(): String { + removedClassProperty = null + return "FAIL: writeToRemovedClassProperty" + } + + fun createClass(): Class = Class() + fun createClassAndCallFunction(): String = createClass().f() + + val getClass1: Class get() = Class() + val getClassAndReadProperty1: String get() = getClass1.p + + val getClass2: Class = Class() + val getClassAndReadProperty2: String = getClass2.p + + fun createRemovedClass(): RemovedClass = TODO() + fun createRemovedClassAndCallFunction(): String = createRemovedClass().f() + + val getRemovedClass: RemovedClass get() = TODO() + val getRemovedClassAndReadProperty: String get() = getRemovedClass.p + + class CrashesOnCreation { + val getRemovedClass: RemovedClass = TODO() + val getRemovedClassAndReadBar: String = getRemovedClass.p + } + + fun createInterfaceImplParameterizedByClass(): Interface = InterfaceImplParameterizedByClass() + fun createInterfaceImplParameterizedByClassAndCallFunction(): String = createInterfaceImplParameterizedByClass().value.f() + + fun createInstanceImplParameterizedByRemovedClass(): Interface = InterfaceImplParameterizedByRemovedClass() + fun createInstanceImplParameterizedByRemovedClassAndCallFunction(): String = createInstanceImplParameterizedByRemovedClass().value.f() +} + +fun readVariableInFunction() { + var removed: RemovedClass? = null + check(removed == null) +} + +fun writeVariableInFunction() { + var removed: RemovedClass? + removed = null +} + +fun readVariableInLocalFunction() { + fun local() { + var removed: RemovedClass? = null + check(removed == null) + } + local() +} + +fun writeVariableInLocalFunction() { + fun local() { + var removed: RemovedClass? + removed = null + } + local() +} + +fun readVariableInLocalClass() { + class Local { + fun foo() { + var removed: RemovedClass? = null + check(removed == null) + } + } + Local().foo() +} + +fun writeVariableInLocalClass() { + class Local { + fun foo() { + var removed: RemovedClass? + removed = null + } + } + Local().foo() +} + +fun readVariableInAnonymousObject() { + object { + fun foo() { + var removed: RemovedClass? = null + check(removed == null) + } + }.foo() +} + +fun writeVariableInAnonymousObject() { + object { + fun foo() { + var removed: RemovedClass? + removed = null + } + }.foo() +} + +fun readVariableInAnonymousObjectThroughLocalVar() { + val obj = object { + fun foo() { + var removed: RemovedClass? = null + check(removed == null) + } + } + obj.foo() +} + +fun writeVariableInAnonymousObjectThroughLocalVar() { + val obj = object { + fun foo() { + var removed: RemovedClass? + removed = null + } + } + obj.foo() +} + +fun callLocalFunction() { + fun local(): RemovedClass = TODO() + local() +} + +fun callLocalFunctionInLocalFunction() { + fun local() { + fun local(): RemovedClass = TODO() + local() + } + local() +} + +fun callLocalFunctionInFunctionOfLocalClass() { + class Local { + fun foo() { + fun local(): RemovedClass = TODO() + local() + } + } + Local().foo() +} + +fun callLocalFunctionInFunctionOfAnonymousObject() { + object { + fun foo() { + fun local(): RemovedClass = TODO() + local() + } + }.foo() +} + +fun callLocalFunctionInFunctionOfAnonymousObjectThroughLocalVar() { + val obj = object { + fun foo() { + fun local(): RemovedClass = TODO() + local() + } + } + obj.foo() +} + +class TopLevelClassChildOfRemovedAbstractClass : RemovedAbstractClass() +object TopLevelObjectChildOfRemovedAbstractClass : RemovedAbstractClass() +interface TopLevelInterfaceChildOfRemovedInterface : RemovedInterface +class TopLevelClassChildOfRemovedInterface : RemovedInterface +object TopLevelObjectChildOfRemovedInterface : RemovedInterface +enum class TopLevelEnumClassChildOfRemovedInterface : RemovedInterface { ENTRY } + +class TopLevel { + class NestedClassChildOfRemovedAbstractClass : RemovedAbstractClass() + object NestedObjectChildOfRemovedAbstractClass : RemovedAbstractClass() + interface NestedInterfaceChildOfRemovedInterface : RemovedInterface + class NestedClassChildOfRemovedInterface : RemovedInterface + object NestedObjectChildOfRemovedInterface : RemovedInterface + enum class NestedEnumClassChildOfRemovedInterface : RemovedInterface { ENTRY } + + inner class InnerClassChildOfRemovedAbstractClass : RemovedAbstractClass() + inner class InnerClassChildOfRemovedInterface : RemovedInterface +} + +class TopLevelWithCompanionChildOfRemovedAbstractClass { + companion object : RemovedAbstractClass() +} + +class TopLevelWithCompanionChildOfRemovedInterface { + companion object : RemovedInterface +} + +val anonymousObjectChildOfRemovedAbstractClass = object : RemovedAbstractClass() {} +val anonymousObjectChildOfRemovedInterface = object : RemovedInterface {} + +fun topLevelFunctionWithLocalClassChildOfRemovedAbstractClass() { + class LocalClass : RemovedAbstractClass() + LocalClass().toString() +} + +fun topLevelFunctionWithLocalClassChildOfRemovedInterface() { + class LocalClass : RemovedInterface + LocalClass().toString() +} + +fun topLevelFunctionWithAnonymousObjectChildOfRemovedAbstractClass() { + val anonymousObject = object : RemovedAbstractClass() {} + anonymousObject.toString() +} + +fun topLevelFunctionWithAnonymousObjectChildOfRemovedInterface() { + val anonymousObject = object : RemovedInterface {} + anonymousObject.toString() +} + +open class OpenClassImpl : RemovedOpenClass() + +inline fun inlinedFunctionWithRemovedOpenClassVariableType() { + val foo: RemovedOpenClass? = null + check(foo == null) +} + +inline fun inlinedFunctionWithOpenClassImplVariableType() { + val foo: OpenClassImpl? = null + check(foo == null) +} + +inline fun inlinedFunctionWithCreationOfRemovedOpenClass() { + check(RemovedOpenClass().toString() != "Yellow Submarine") +} + +inline fun inlinedFunctionWithCreationOfOpenClassImpl() { + check(OpenClassImpl().toString() != "Yellow Submarine") +} + +inline fun inlinedFunctionWithCreationOfRemovedOpenClassThroughReference() { + check(run(::RemovedOpenClass).toString() != "Yellow Submarine") +} + +inline fun inlinedFunctionWithCreationOfOpenClassImplThroughReference() { + check(run(::OpenClassImpl).toString() != "Yellow Submarine") +} + +inline fun inlinedFunctionWithRemovedOpenClassAnonymousObject() { + val foo = object : RemovedOpenClass() {} + check(foo == null) +} + +inline fun inlinedFunctionWithOpenClassImplAnonymousObject() { + val foo = object : OpenClassImpl() {} + check(foo == null) +} diff --git a/compiler/testData/klibABI/removeInlinedClass/lib2/module.info b/compiler/testData/klibABI/removeClass/lib2/module.info similarity index 100% rename from compiler/testData/klibABI/removeInlinedClass/lib2/module.info rename to compiler/testData/klibABI/removeClass/lib2/module.info diff --git a/compiler/testData/klibABI/removeClass/main/m.kt b/compiler/testData/klibABI/removeClass/main/m.kt new file mode 100644 index 00000000000..b706e09a5fe --- /dev/null +++ b/compiler/testData/klibABI/removeClass/main/m.kt @@ -0,0 +1,70 @@ +import abitestutils.abiTest + +fun box() = abiTest { + val checker = Checker() + + expectFailure(linkage("Constructor 'RemovedClass.' can not be called: No constructor found for symbol '/RemovedClass.'")) { createRemovedClass() } + + expectFailure(linkage("Function 'useRemovedClassAsValueParameter' can not be called: Function uses unlinked class symbol '/RemovedClass'")) { checker.createAndPassRemovedClassAsValueParameter() } + expectFailure(linkage("Property accessor 'removedClassProperty.' can not be called: Property accessor uses unlinked class symbol '/RemovedClass'")) { checker.writeToRemovedClassProperty() } + expectSuccess("Checker.useClassAsValueParameter(Class)") { checker.createAndPassClassAsValueParameter() } + + expectFailure(linkage("Can not read value from variable 'removed': Variable uses unlinked class symbol '/RemovedClass'")) { readVariableInFunction() } + expectFailure(linkage("Can not write value to variable 'removed': Variable uses unlinked class symbol '/RemovedClass'")) { writeVariableInFunction() } + expectFailure(linkage("Can not read value from variable 'removed': Variable uses unlinked class symbol '/RemovedClass'")) { readVariableInLocalFunction() } + expectFailure(linkage("Can not write value to variable 'removed': Variable uses unlinked class symbol '/RemovedClass'")) { writeVariableInLocalFunction() } + expectFailure(linkage("Can not read value from variable 'removed': Variable uses unlinked class symbol '/RemovedClass'")) { readVariableInLocalClass() } + expectFailure(linkage("Can not write value to variable 'removed': Variable uses unlinked class symbol '/RemovedClass'")) { writeVariableInLocalClass() } + expectFailure(linkage("Can not read value from variable 'removed': Variable uses unlinked class symbol '/RemovedClass'")) { readVariableInAnonymousObject() } + expectFailure(linkage("Can not write value to variable 'removed': Variable uses unlinked class symbol '/RemovedClass'")) { writeVariableInAnonymousObject() } + expectFailure(linkage("Can not read value from variable 'removed': Variable uses unlinked class symbol '/RemovedClass'")) { readVariableInAnonymousObjectThroughLocalVar() } + expectFailure(linkage("Can not write value to variable 'removed': Variable uses unlinked class symbol '/RemovedClass'")) { writeVariableInAnonymousObjectThroughLocalVar() } + + expectFailure(linkage("Function 'createRemovedClass' can not be called: Function uses unlinked class symbol '/RemovedClass'")) { checker.createRemovedClassAndCallFunction() } + expectFailure(linkage("Property accessor 'getRemovedClass.' can not be called: Property accessor uses unlinked class symbol '/RemovedClass'")) { checker.getRemovedClassAndReadProperty } + expectSuccess("Class.f") { checker.createClassAndCallFunction() } + expectSuccess("Class.p") { checker.getClassAndReadProperty1 } + expectSuccess("Class.p") { checker.getClassAndReadProperty2 } + expectFailure(linkage("Property accessor 'getRemovedClass.' can not be called: Property accessor uses unlinked class symbol '/RemovedClass'")) { Checker.CrashesOnCreation() } + + expectFailure(linkage("Function 'local' can not be called: Function uses unlinked class symbol '/RemovedClass'")) { callLocalFunction() } + expectFailure(linkage("Function 'local' can not be called: Function uses unlinked class symbol '/RemovedClass'")) { callLocalFunctionInLocalFunction() } + expectFailure(linkage("Function 'local' can not be called: Function uses unlinked class symbol '/RemovedClass'")) { callLocalFunctionInFunctionOfLocalClass() } + expectFailure(linkage("Function 'local' can not be called: Function uses unlinked class symbol '/RemovedClass'")) { callLocalFunctionInFunctionOfAnonymousObject() } + expectFailure(linkage("Function 'local' can not be called: Function uses unlinked class symbol '/RemovedClass'")) { callLocalFunctionInFunctionOfAnonymousObjectThroughLocalVar() } + + expectFailure(linkage("Function 'createInstanceImplParameterizedByRemovedClass' can not be called: Function uses unlinked class symbol '/RemovedClass'")) { checker.createInstanceImplParameterizedByRemovedClassAndCallFunction() } + expectSuccess("Class.f") { checker.createInterfaceImplParameterizedByClassAndCallFunction() } + + expectFailure(linkage("Constructor 'TopLevelClassChildOfRemovedAbstractClass.' can not be called: Class 'TopLevelClassChildOfRemovedAbstractClass' uses unlinked class symbol '/RemovedAbstractClass'")) { TopLevelClassChildOfRemovedAbstractClass() } + expectFailure(linkage("Can not get instance of singleton 'TopLevelObjectChildOfRemovedAbstractClass': Expression uses unlinked class symbol '/RemovedAbstractClass'")) { TopLevelObjectChildOfRemovedAbstractClass } + expectFailure(linkage("Constructor '' can not be called: Anonymous object uses unlinked class symbol '/RemovedInterface'")) { object : TopLevelInterfaceChildOfRemovedInterface {} } + expectFailure(linkage("Constructor 'TopLevelClassChildOfRemovedInterface.' can not be called: Class 'TopLevelClassChildOfRemovedInterface' uses unlinked class symbol '/RemovedInterface'")) { TopLevelClassChildOfRemovedInterface() } + expectFailure(linkage("Can not get instance of singleton 'TopLevelObjectChildOfRemovedInterface': Expression uses unlinked class symbol '/RemovedInterface'")) { TopLevelObjectChildOfRemovedInterface } + expectFailure(linkage("Can not get instance of singleton 'TopLevelEnumClassChildOfRemovedInterface.ENTRY': Expression uses unlinked class symbol '/RemovedInterface'")) { TopLevelEnumClassChildOfRemovedInterface.ENTRY } + expectFailure(linkage("Constructor 'NestedClassChildOfRemovedAbstractClass.' can not be called: Class 'NestedClassChildOfRemovedAbstractClass' uses unlinked class symbol '/RemovedAbstractClass'")) { TopLevel.NestedClassChildOfRemovedAbstractClass() } + expectFailure(linkage("Can not get instance of singleton 'NestedObjectChildOfRemovedAbstractClass': Expression uses unlinked class symbol '/RemovedAbstractClass'")) { TopLevel.NestedObjectChildOfRemovedAbstractClass } + expectFailure(linkage("Constructor '' can not be called: Anonymous object uses unlinked class symbol '/RemovedInterface'")) { object : TopLevel.NestedInterfaceChildOfRemovedInterface {} } + expectFailure(linkage("Constructor 'NestedClassChildOfRemovedInterface.' can not be called: Class 'NestedClassChildOfRemovedInterface' uses unlinked class symbol '/RemovedInterface'")) { TopLevel.NestedClassChildOfRemovedInterface() } + expectFailure(linkage("Can not get instance of singleton 'NestedObjectChildOfRemovedInterface': Expression uses unlinked class symbol '/RemovedInterface'")) { TopLevel.NestedObjectChildOfRemovedInterface } + expectFailure(linkage("Can not get instance of singleton 'NestedEnumClassChildOfRemovedInterface.ENTRY': Expression uses unlinked class symbol '/RemovedInterface'")) { TopLevel.NestedEnumClassChildOfRemovedInterface.ENTRY } + expectFailure(linkage("Constructor 'InnerClassChildOfRemovedAbstractClass.' can not be called: Inner class 'InnerClassChildOfRemovedAbstractClass' uses unlinked class symbol '/RemovedAbstractClass'")) { TopLevel().InnerClassChildOfRemovedAbstractClass() } + expectFailure(linkage("Constructor 'InnerClassChildOfRemovedInterface.' can not be called: Inner class 'InnerClassChildOfRemovedInterface' uses unlinked class symbol '/RemovedInterface'")) { TopLevel().InnerClassChildOfRemovedInterface() } + expectFailure(linkage("Can not get instance of singleton 'TopLevelWithCompanionChildOfRemovedAbstractClass.Companion': Expression uses unlinked class symbol '/RemovedAbstractClass'")) { TopLevelWithCompanionChildOfRemovedAbstractClass.Companion } + expectFailure(linkage("Can not get instance of singleton 'TopLevelWithCompanionChildOfRemovedInterface.Companion': Expression uses unlinked class symbol '/RemovedInterface'")) { TopLevelWithCompanionChildOfRemovedInterface.Companion } + expectFailure(linkage("Property accessor 'anonymousObjectChildOfRemovedAbstractClass.' can not be called: Property accessor uses unlinked class symbol '/RemovedAbstractClass'")) { anonymousObjectChildOfRemovedAbstractClass } + expectFailure(linkage("Property accessor 'anonymousObjectChildOfRemovedInterface.' can not be called: Property accessor uses unlinked class symbol '/RemovedInterface'")) { anonymousObjectChildOfRemovedInterface } + expectFailure(linkage("Constructor 'LocalClass.' can not be called: Class 'LocalClass' uses unlinked class symbol '/RemovedAbstractClass'")) { topLevelFunctionWithLocalClassChildOfRemovedAbstractClass() } + expectFailure(linkage("Constructor 'LocalClass.' can not be called: Class 'LocalClass' uses unlinked class symbol '/RemovedInterface'")) { topLevelFunctionWithLocalClassChildOfRemovedInterface() } + expectFailure(linkage("Can not read value from variable 'anonymousObject': Variable uses unlinked class symbol '/RemovedAbstractClass' (via anonymous object)")) { topLevelFunctionWithAnonymousObjectChildOfRemovedAbstractClass() } + expectFailure(linkage("Can not read value from variable 'anonymousObject': Variable uses unlinked class symbol '/RemovedInterface' (via anonymous object)")) { topLevelFunctionWithAnonymousObjectChildOfRemovedInterface() } + + expectFailure(linkage("Can not read value from variable 'foo': Variable uses unlinked class symbol '/RemovedOpenClass'")) { inlinedFunctionWithRemovedOpenClassVariableType() } + expectFailure(linkage("Can not read value from variable 'foo': Variable uses unlinked class symbol '/RemovedOpenClass' (via class 'OpenClassImpl')")) { inlinedFunctionWithOpenClassImplVariableType() } + expectFailure(linkage("Constructor 'RemovedOpenClass.' can not be called: No constructor found for symbol '/RemovedOpenClass.'")) { inlinedFunctionWithCreationOfRemovedOpenClass() } + expectFailure(linkage("Constructor 'OpenClassImpl.' can not be called: Class 'OpenClassImpl' uses unlinked class symbol '/RemovedOpenClass'")) { inlinedFunctionWithCreationOfOpenClassImpl() } + expectFailure(linkage("Reference to constructor 'RemovedOpenClass.' can not be evaluated: No constructor found for symbol '/RemovedOpenClass.'")) { inlinedFunctionWithCreationOfRemovedOpenClassThroughReference() } + expectFailure(linkage("Reference to constructor 'OpenClassImpl.' can not be evaluated: Class 'OpenClassImpl' uses unlinked class symbol '/RemovedOpenClass'")) { inlinedFunctionWithCreationOfOpenClassImplThroughReference() } + expectFailure(linkage("Can not read value from variable 'foo': Variable uses unlinked class symbol '/RemovedOpenClass' (via anonymous object)")) { inlinedFunctionWithRemovedOpenClassAnonymousObject() } + expectFailure(linkage("Can not read value from variable 'foo': Variable uses unlinked class symbol '/RemovedOpenClass' (via anonymous object)")) { inlinedFunctionWithOpenClassImplAnonymousObject() } +} diff --git a/compiler/testData/klibABI/removeInlinedClass/main/module.info b/compiler/testData/klibABI/removeClass/main/module.info similarity index 100% rename from compiler/testData/klibABI/removeInlinedClass/main/module.info rename to compiler/testData/klibABI/removeClass/main/module.info diff --git a/compiler/testData/klibABI/removeClassAsTypeArgument/project.info b/compiler/testData/klibABI/removeClass/project.info similarity index 100% rename from compiler/testData/klibABI/removeClassAsTypeArgument/project.info rename to compiler/testData/klibABI/removeClass/project.info diff --git a/compiler/testData/klibABI/removeClassAsConstructorCall/lib1/l1.kt b/compiler/testData/klibABI/removeClassAsConstructorCall/lib1/l1.kt deleted file mode 100644 index c389887ee5a..00000000000 --- a/compiler/testData/klibABI/removeClassAsConstructorCall/lib1/l1.kt +++ /dev/null @@ -1 +0,0 @@ -class Foo diff --git a/compiler/testData/klibABI/removeClassAsConstructorCall/lib1/l1.kt.1 b/compiler/testData/klibABI/removeClassAsConstructorCall/lib1/l1.kt.1 deleted file mode 100644 index d0c7511327f..00000000000 --- a/compiler/testData/klibABI/removeClassAsConstructorCall/lib1/l1.kt.1 +++ /dev/null @@ -1 +0,0 @@ -//class Foo diff --git a/compiler/testData/klibABI/removeClassAsConstructorCall/lib2/l2.kt b/compiler/testData/klibABI/removeClassAsConstructorCall/lib2/l2.kt deleted file mode 100644 index 5f996387a4b..00000000000 --- a/compiler/testData/klibABI/removeClassAsConstructorCall/lib2/l2.kt +++ /dev/null @@ -1,3 +0,0 @@ -fun bar() { - check(Foo().toString() != "Bar") -} diff --git a/compiler/testData/klibABI/removeClassAsConstructorCall/main/m.kt b/compiler/testData/klibABI/removeClassAsConstructorCall/main/m.kt deleted file mode 100644 index a1248590c17..00000000000 --- a/compiler/testData/klibABI/removeClassAsConstructorCall/main/m.kt +++ /dev/null @@ -1,5 +0,0 @@ -import abitestutils.abiTest - -fun box() = abiTest { - expectFailure(prefixed("constructor Foo. can not be called")) { bar() } -} diff --git a/compiler/testData/klibABI/removeClassAsParameterType/lib1/l1.kt b/compiler/testData/klibABI/removeClassAsParameterType/lib1/l1.kt deleted file mode 100644 index c8e529060f6..00000000000 --- a/compiler/testData/klibABI/removeClassAsParameterType/lib1/l1.kt +++ /dev/null @@ -1,2 +0,0 @@ -class C -class E diff --git a/compiler/testData/klibABI/removeClassAsParameterType/lib1/l1.kt.1 b/compiler/testData/klibABI/removeClassAsParameterType/lib1/l1.kt.1 deleted file mode 100644 index 826a1a5bc2e..00000000000 --- a/compiler/testData/klibABI/removeClassAsParameterType/lib1/l1.kt.1 +++ /dev/null @@ -1 +0,0 @@ -class C diff --git a/compiler/testData/klibABI/removeClassAsParameterType/lib2/l2.kt b/compiler/testData/klibABI/removeClassAsParameterType/lib2/l2.kt deleted file mode 100644 index 48b67ee7de2..00000000000 --- a/compiler/testData/klibABI/removeClassAsParameterType/lib2/l2.kt +++ /dev/null @@ -1,7 +0,0 @@ -class D { - fun stable(c: C): String = "OK" - fun foo(): String = stable(C()) - - fun exp(e: E): String = "FAIL1" - fun bar(): String = exp(E()) -} diff --git a/compiler/testData/klibABI/removeClassAsParameterType/main/m.kt b/compiler/testData/klibABI/removeClassAsParameterType/main/m.kt deleted file mode 100644 index 6966870e118..00000000000 --- a/compiler/testData/klibABI/removeClassAsParameterType/main/m.kt +++ /dev/null @@ -1,7 +0,0 @@ -import abitestutils.abiTest - -fun box() = abiTest { - val d = D() - expectFailure(prefixed("constructor E. can not be called")) { d.bar() } - expectSuccess { d.foo() } -} diff --git a/compiler/testData/klibABI/removeClassAsReturnType/lib1/l1.kt b/compiler/testData/klibABI/removeClassAsReturnType/lib1/l1.kt deleted file mode 100644 index c8b5d4056f7..00000000000 --- a/compiler/testData/klibABI/removeClassAsReturnType/lib1/l1.kt +++ /dev/null @@ -1,9 +0,0 @@ -class C { - fun o(): String = "FAIL1" - val op: String get() = "FAIL2" -} - -class E { - fun e(): String = "FAIL3" - val ep: String get() = "FAIL4" -} diff --git a/compiler/testData/klibABI/removeClassAsReturnType/lib1/l1.kt.1 b/compiler/testData/klibABI/removeClassAsReturnType/lib1/l1.kt.1 deleted file mode 100644 index d18e746ba92..00000000000 --- a/compiler/testData/klibABI/removeClassAsReturnType/lib1/l1.kt.1 +++ /dev/null @@ -1,4 +0,0 @@ -class C { - fun o(): String = "OK" - val op: String get() = "OK" -} diff --git a/compiler/testData/klibABI/removeClassAsReturnType/lib2/l2.kt b/compiler/testData/klibABI/removeClassAsReturnType/lib2/l2.kt deleted file mode 100644 index eba918f360b..00000000000 --- a/compiler/testData/klibABI/removeClassAsReturnType/lib2/l2.kt +++ /dev/null @@ -1,63 +0,0 @@ -class D { - fun stableF(): C = C() - fun fooF(): String = stableF().o() - - val stableP1: C get() = C() - val fooP1: String get() = stableP1.op - - val stableP2: C = C() - val fooP2: String = stableP1.op - - fun expF(): E = E() - fun barF(): String = expF().e() - - val expP1: E get() = E() - val barP1: String get() = expP1.ep -} - -class D2 { - val expP2: E = E() - val barP2: String = expP2.ep -} - -fun bar() { - fun foo(): E = E() - foo() -} - -fun baz() { - fun qux() { - fun foo(): E = E() - foo() - } - qux() -} - -fun quux() { - class Local { - fun corge() { - fun foo(): E = E() - foo() - } - } - Local().corge() -} - -fun grault() { - object { - fun garply() { - fun foo(): E = E() - foo() - } - }.garply() -} - -fun waldo() { - val fred = object { - fun garply() { - fun foo(): E = E() - foo() - } - } - fred.garply() -} diff --git a/compiler/testData/klibABI/removeClassAsReturnType/main/m.kt b/compiler/testData/klibABI/removeClassAsReturnType/main/m.kt deleted file mode 100644 index cd080c3b30f..00000000000 --- a/compiler/testData/klibABI/removeClassAsReturnType/main/m.kt +++ /dev/null @@ -1,15 +0,0 @@ -import abitestutils.abiTest - -fun box() = abiTest { - val d = D() - expectFailure(prefixed("function expF can not be called")) { d.barF() } - expectSuccess { d.fooF() } - expectFailure(prefixed("property accessor expP1. can not be called")) { d.barP1 } - expectSuccess { d.fooP1 } - expectFailure(prefixed("property accessor expP2. can not be called")) { D2().barP2 } - expectFailure(prefixed("function foo can not be called")) { bar() } - expectFailure(prefixed("function foo can not be called")) { baz() } - expectFailure(prefixed("function foo can not be called")) { quux() } - expectFailure(prefixed("function foo can not be called")) { grault() } - expectFailure(prefixed("function foo can not be called")) { waldo() } -} diff --git a/compiler/testData/klibABI/removeClassAsSuperTypeArgument/lib1/l1.kt b/compiler/testData/klibABI/removeClassAsSuperTypeArgument/lib1/l1.kt deleted file mode 100644 index 9dcf06e955c..00000000000 --- a/compiler/testData/klibABI/removeClassAsSuperTypeArgument/lib1/l1.kt +++ /dev/null @@ -1,7 +0,0 @@ -class C { - fun o(): String = "FAIL1" -} - -class E { - fun e(): String = "FAIL2" -} diff --git a/compiler/testData/klibABI/removeClassAsSuperTypeArgument/lib1/l1.kt.1 b/compiler/testData/klibABI/removeClassAsSuperTypeArgument/lib1/l1.kt.1 deleted file mode 100644 index 22455f468f8..00000000000 --- a/compiler/testData/klibABI/removeClassAsSuperTypeArgument/lib1/l1.kt.1 +++ /dev/null @@ -1,3 +0,0 @@ -class C { - fun o(): String = "OK" -} diff --git a/compiler/testData/klibABI/removeClassAsSuperTypeArgument/lib2/l2.kt b/compiler/testData/klibABI/removeClassAsSuperTypeArgument/lib2/l2.kt deleted file mode 100644 index 16a30a95a19..00000000000 --- a/compiler/testData/klibABI/removeClassAsSuperTypeArgument/lib2/l2.kt +++ /dev/null @@ -1,19 +0,0 @@ -interface I { - val o: T -} - -class ST : I { - override val o: C = C() -} - -class EX: I { - override val o: E = E() -} - -class D { - fun stable(): ST = ST() - fun foo(): String = stable().o.o() - - fun exp(): EX = EX() - fun bar(): String = exp().o.e() -} diff --git a/compiler/testData/klibABI/removeClassAsSuperTypeArgument/main/m.kt b/compiler/testData/klibABI/removeClassAsSuperTypeArgument/main/m.kt deleted file mode 100644 index 1d76540b190..00000000000 --- a/compiler/testData/klibABI/removeClassAsSuperTypeArgument/main/m.kt +++ /dev/null @@ -1,7 +0,0 @@ -import abitestutils.abiTest - -fun box() = abiTest { - val d = D() - expectFailure(prefixed("function exp can not be called")) { d.bar() } - expectSuccess { d.foo() } -} diff --git a/compiler/testData/klibABI/removeClassAsTypeArgument/lib1/l1.kt b/compiler/testData/klibABI/removeClassAsTypeArgument/lib1/l1.kt deleted file mode 100644 index 9dcf06e955c..00000000000 --- a/compiler/testData/klibABI/removeClassAsTypeArgument/lib1/l1.kt +++ /dev/null @@ -1,7 +0,0 @@ -class C { - fun o(): String = "FAIL1" -} - -class E { - fun e(): String = "FAIL2" -} diff --git a/compiler/testData/klibABI/removeClassAsTypeArgument/lib1/l1.kt.1 b/compiler/testData/klibABI/removeClassAsTypeArgument/lib1/l1.kt.1 deleted file mode 100644 index 22455f468f8..00000000000 --- a/compiler/testData/klibABI/removeClassAsTypeArgument/lib1/l1.kt.1 +++ /dev/null @@ -1,3 +0,0 @@ -class C { - fun o(): String = "OK" -} diff --git a/compiler/testData/klibABI/removeClassAsTypeArgument/lib2/l2.kt b/compiler/testData/klibABI/removeClassAsTypeArgument/lib2/l2.kt deleted file mode 100644 index 4ec92ab3dc1..00000000000 --- a/compiler/testData/klibABI/removeClassAsTypeArgument/lib2/l2.kt +++ /dev/null @@ -1,15 +0,0 @@ -interface I { - val o: T -} - -class D { - fun stable(): I = object : I { - override val o: C = C() - } - fun foo(): String = stable().o.o() - - fun exp(): I = object : I { - override val o: E = E() - } - fun bar(): String = exp().o.e() -} diff --git a/compiler/testData/klibABI/removeClassAsTypeArgument/main/m.kt b/compiler/testData/klibABI/removeClassAsTypeArgument/main/m.kt deleted file mode 100644 index 1d76540b190..00000000000 --- a/compiler/testData/klibABI/removeClassAsTypeArgument/main/m.kt +++ /dev/null @@ -1,7 +0,0 @@ -import abitestutils.abiTest - -fun box() = abiTest { - val d = D() - expectFailure(prefixed("function exp can not be called")) { d.bar() } - expectSuccess { d.foo() } -} diff --git a/compiler/testData/klibABI/removeClassAsVariableType/lib1/l1.kt b/compiler/testData/klibABI/removeClassAsVariableType/lib1/l1.kt deleted file mode 100644 index c389887ee5a..00000000000 --- a/compiler/testData/klibABI/removeClassAsVariableType/lib1/l1.kt +++ /dev/null @@ -1 +0,0 @@ -class Foo diff --git a/compiler/testData/klibABI/removeClassAsVariableType/lib1/l1.kt.1 b/compiler/testData/klibABI/removeClassAsVariableType/lib1/l1.kt.1 deleted file mode 100644 index d0c7511327f..00000000000 --- a/compiler/testData/klibABI/removeClassAsVariableType/lib1/l1.kt.1 +++ /dev/null @@ -1 +0,0 @@ -//class Foo diff --git a/compiler/testData/klibABI/removeClassAsVariableType/lib2/l2.kt b/compiler/testData/klibABI/removeClassAsVariableType/lib2/l2.kt deleted file mode 100644 index 0c52bc76334..00000000000 --- a/compiler/testData/klibABI/removeClassAsVariableType/lib2/l2.kt +++ /dev/null @@ -1,41 +0,0 @@ -fun bar() { - var foo: Foo? = null - check(foo == null) -} - -fun baz() { - fun qux() { - var foo: Foo? = null - check(foo == null) - } - qux() -} - -fun quux() { - class Local { - fun corge() { - var foo: Foo? = null - check(foo == null) - } - } - Local().corge() -} - -fun grault() { - object { - fun garply() { - var foo: Foo? = null - check(foo == null) - } - }.garply() -} - -fun waldo() { - val fred = object { - fun garply() { - var foo: Foo? = null - check(foo == null) - } - } - fred.garply() -} diff --git a/compiler/testData/klibABI/removeClassAsVariableType/main/m.kt b/compiler/testData/klibABI/removeClassAsVariableType/main/m.kt deleted file mode 100644 index 2adee529beb..00000000000 --- a/compiler/testData/klibABI/removeClassAsVariableType/main/m.kt +++ /dev/null @@ -1,9 +0,0 @@ -import abitestutils.abiTest - -fun box() = abiTest { - expectFailure(prefixed("var foo can not be read")) { bar() } - expectFailure(prefixed("var foo can not be read")) { baz() } - expectFailure(prefixed("var foo can not be read")) { quux() } - expectFailure(prefixed("var foo can not be read")) { grault() } - expectFailure(prefixed("var foo can not be read")) { waldo() } -} diff --git a/compiler/testData/klibABI/removeEnumEntry/lib1/l1.kt b/compiler/testData/klibABI/removeEnumEntry/lib1/l1.kt new file mode 100644 index 00000000000..d9894c28ab6 --- /dev/null +++ b/compiler/testData/klibABI/removeEnumEntry/lib1/l1.kt @@ -0,0 +1,3 @@ +enum class E { + UNCHANGED1, REMOVED, UNCHANGED2 +} diff --git a/compiler/testData/klibABI/removeEnumEntry/lib1/l1.kt.1 b/compiler/testData/klibABI/removeEnumEntry/lib1/l1.kt.1 new file mode 100644 index 00000000000..246d919a0b8 --- /dev/null +++ b/compiler/testData/klibABI/removeEnumEntry/lib1/l1.kt.1 @@ -0,0 +1,3 @@ +enum class E { + UNCHANGED1, /*REMOVED,*/ UNCHANGED2 +} diff --git a/compiler/testData/klibABI/removeOpenProperty/lib1/module.info b/compiler/testData/klibABI/removeEnumEntry/lib1/module.info similarity index 100% rename from compiler/testData/klibABI/removeOpenProperty/lib1/module.info rename to compiler/testData/klibABI/removeEnumEntry/lib1/module.info diff --git a/compiler/testData/klibABI/removeEnumEntry/lib2/l2.kt b/compiler/testData/klibABI/removeEnumEntry/lib2/l2.kt new file mode 100644 index 00000000000..39f6b5006e9 --- /dev/null +++ b/compiler/testData/klibABI/removeEnumEntry/lib2/l2.kt @@ -0,0 +1,5 @@ +fun compute(e: E): String = when (e) { + E.UNCHANGED1 -> "OK" + E.REMOVED -> "FAIL1" + E.UNCHANGED2 -> "FAIL2" +} diff --git a/compiler/testData/klibABI/removeInlinedFunction/lib2/module.info b/compiler/testData/klibABI/removeEnumEntry/lib2/module.info similarity index 100% rename from compiler/testData/klibABI/removeInlinedFunction/lib2/module.info rename to compiler/testData/klibABI/removeEnumEntry/lib2/module.info diff --git a/compiler/testData/klibABI/removeEnumEntry/main/m.kt b/compiler/testData/klibABI/removeEnumEntry/main/m.kt new file mode 100644 index 00000000000..e0c11465344 --- /dev/null +++ b/compiler/testData/klibABI/removeEnumEntry/main/m.kt @@ -0,0 +1,7 @@ +import abitestutils.abiTest + +fun box() = abiTest { + expectFailure(linkage("Can not get instance of singleton 'E.REMOVED': No enum entry found for symbol '/E.REMOVED'")) { compute(E.UNCHANGED2) } + expectFailure(linkage("Can not get instance of singleton 'E.REMOVED': No enum entry found for symbol '/E.REMOVED'")) { compute(E.REMOVED) } + expectSuccess { compute(E.UNCHANGED1) } +} diff --git a/compiler/testData/klibABI/removeInlinedFunction/main/module.info b/compiler/testData/klibABI/removeEnumEntry/main/module.info similarity index 100% rename from compiler/testData/klibABI/removeInlinedFunction/main/module.info rename to compiler/testData/klibABI/removeEnumEntry/main/module.info diff --git a/compiler/testData/klibABI/removeClassAsVariableType/project.info b/compiler/testData/klibABI/removeEnumEntry/project.info similarity index 100% rename from compiler/testData/klibABI/removeClassAsVariableType/project.info rename to compiler/testData/klibABI/removeEnumEntry/project.info diff --git a/compiler/testData/klibABI/removeFunction/lib1/l1.kt b/compiler/testData/klibABI/removeFunction/lib1/l1.kt deleted file mode 100644 index f2041daa443..00000000000 --- a/compiler/testData/klibABI/removeFunction/lib1/l1.kt +++ /dev/null @@ -1,7 +0,0 @@ -fun foo(): String = "FAIL1" -fun exp_foo(): String = "FAIL2" - -class A { - fun foo(): String = "FAIL3" - fun exp_foo(): String = "FAIL4" -} diff --git a/compiler/testData/klibABI/removeFunction/lib1/l1.kt.1 b/compiler/testData/klibABI/removeFunction/lib1/l1.kt.1 deleted file mode 100644 index cd7a190788f..00000000000 --- a/compiler/testData/klibABI/removeFunction/lib1/l1.kt.1 +++ /dev/null @@ -1,5 +0,0 @@ -fun foo(): String = "OK" - -class A { - fun foo(): String = "OK" -} diff --git a/compiler/testData/klibABI/removeFunction/lib2/l2.kt b/compiler/testData/klibABI/removeFunction/lib2/l2.kt deleted file mode 100644 index 69665aac102..00000000000 --- a/compiler/testData/klibABI/removeFunction/lib2/l2.kt +++ /dev/null @@ -1,2 +0,0 @@ -fun qux(exp: Boolean): String = if (exp) exp_foo() else foo() -fun qux2(exp: Boolean): String = if (exp) A().exp_foo() else A().foo() diff --git a/compiler/testData/klibABI/removeFunction/main/m.kt b/compiler/testData/klibABI/removeFunction/main/m.kt deleted file mode 100644 index 389aaf93e52..00000000000 --- a/compiler/testData/klibABI/removeFunction/main/m.kt +++ /dev/null @@ -1,8 +0,0 @@ -import abitestutils.abiTest - -fun box() = abiTest { - expectFailure(prefixed("function exp_foo can not be called")) { qux(true) } - expectSuccess { qux(false) } - expectFailure(prefixed("function exp_foo can not be called")) { qux2(true) } - expectSuccess { qux2(false) } -} diff --git a/compiler/testData/klibABI/removeInlinedClass/lib1/l1.kt b/compiler/testData/klibABI/removeInlinedClass/lib1/l1.kt deleted file mode 100644 index af29f293af1..00000000000 --- a/compiler/testData/klibABI/removeInlinedClass/lib1/l1.kt +++ /dev/null @@ -1 +0,0 @@ -open class Foo diff --git a/compiler/testData/klibABI/removeInlinedClass/lib1/l1.kt.1 b/compiler/testData/klibABI/removeInlinedClass/lib1/l1.kt.1 deleted file mode 100644 index cff51601e31..00000000000 --- a/compiler/testData/klibABI/removeInlinedClass/lib1/l1.kt.1 +++ /dev/null @@ -1 +0,0 @@ -//open class Foo diff --git a/compiler/testData/klibABI/removeInlinedClass/lib2/l2.kt b/compiler/testData/klibABI/removeInlinedClass/lib2/l2.kt deleted file mode 100644 index 33c3d8ba4b4..00000000000 --- a/compiler/testData/klibABI/removeInlinedClass/lib2/l2.kt +++ /dev/null @@ -1,32 +0,0 @@ -class Bar : Foo() - -inline fun fooVariableType() { - val foo: Foo? = null - check(foo == null) -} - -inline fun barVariableType() { - val bar: Bar? = null - check(bar == null) -} - -inline fun fooInstance() { - check(Foo().toString() != "Qux") -} - -inline fun barInstance() { - check(Bar().toString() != "Qux") -} - -inline fun fooInstance2() { - check(run(::Foo).toString() != "Qux") -} - -inline fun barInstance2() { - check(run(::Bar).toString() != "Qux") -} - -inline fun fooAnonymousObject() { - val foo = object : Foo() {} - check(foo == null) -} diff --git a/compiler/testData/klibABI/removeInlinedClass/main/m.kt b/compiler/testData/klibABI/removeInlinedClass/main/m.kt deleted file mode 100644 index 3137e4bbb30..00000000000 --- a/compiler/testData/klibABI/removeInlinedClass/main/m.kt +++ /dev/null @@ -1,11 +0,0 @@ -import abitestutils.abiTest - -fun box() = abiTest { - expectFailure(prefixed("val foo can not be read")) { fooVariableType() } - expectFailure(prefixed("val bar can not be read")) { barVariableType() } - expectFailure(prefixed("constructor Foo. can not be called")) { fooInstance() } - expectFailure(prefixed("constructor Bar. can not be called")) { barInstance() } - expectFailure(prefixed("reference to constructor Foo. can not be evaluated")) { fooInstance2() } - expectFailure(prefixed("reference to constructor Bar. can not be evaluated")) { barInstance2() } - expectFailure(prefixed("val foo can not be read")) { fooAnonymousObject() } -} diff --git a/compiler/testData/klibABI/removeInlinedFunction/lib1/l1.kt b/compiler/testData/klibABI/removeInlinedFunction/lib1/l1.kt deleted file mode 100644 index d0ee7748528..00000000000 --- a/compiler/testData/klibABI/removeInlinedFunction/lib1/l1.kt +++ /dev/null @@ -1 +0,0 @@ -fun foo() = "FAIL" diff --git a/compiler/testData/klibABI/removeInlinedFunction/lib1/l1.kt.1 b/compiler/testData/klibABI/removeInlinedFunction/lib1/l1.kt.1 deleted file mode 100644 index 5316ec58c3a..00000000000 --- a/compiler/testData/klibABI/removeInlinedFunction/lib1/l1.kt.1 +++ /dev/null @@ -1 +0,0 @@ -// fun foo() = "FAIL" diff --git a/compiler/testData/klibABI/removeInlinedFunction/lib2/l2.kt b/compiler/testData/klibABI/removeInlinedFunction/lib2/l2.kt deleted file mode 100644 index 4947025b57c..00000000000 --- a/compiler/testData/klibABI/removeInlinedFunction/lib2/l2.kt +++ /dev/null @@ -1 +0,0 @@ -inline fun bar() = foo() diff --git a/compiler/testData/klibABI/removeInlinedFunction/main/m.kt b/compiler/testData/klibABI/removeInlinedFunction/main/m.kt deleted file mode 100644 index ae98e974808..00000000000 --- a/compiler/testData/klibABI/removeInlinedFunction/main/m.kt +++ /dev/null @@ -1,5 +0,0 @@ -import abitestutils.abiTest - -fun box() = abiTest { - expectFailure(prefixed("function foo can not be called")) { bar() } -} diff --git a/compiler/testData/klibABI/removeInlinedFunction/project.info b/compiler/testData/klibABI/removeInlinedFunction/project.info deleted file mode 100644 index 2147306d715..00000000000 --- a/compiler/testData/klibABI/removeInlinedFunction/project.info +++ /dev/null @@ -1,7 +0,0 @@ -MODULES: lib1, lib2, main - -STEP 0: - libs: lib1, lib2, main - -STEP 1: - libs: lib1 \ No newline at end of file diff --git a/compiler/testData/klibABI/removeInlinedProperty/lib1/l1.kt b/compiler/testData/klibABI/removeInlinedProperty/lib1/l1.kt deleted file mode 100644 index 41c2fd812f0..00000000000 --- a/compiler/testData/klibABI/removeInlinedProperty/lib1/l1.kt +++ /dev/null @@ -1 +0,0 @@ -val foo: String get() = "FAIL" diff --git a/compiler/testData/klibABI/removeInlinedProperty/lib1/l1.kt.1 b/compiler/testData/klibABI/removeInlinedProperty/lib1/l1.kt.1 deleted file mode 100644 index 52360d8e809..00000000000 --- a/compiler/testData/klibABI/removeInlinedProperty/lib1/l1.kt.1 +++ /dev/null @@ -1 +0,0 @@ -// val foo: String get() = "FAIL" diff --git a/compiler/testData/klibABI/removeInlinedProperty/lib2/l2.kt b/compiler/testData/klibABI/removeInlinedProperty/lib2/l2.kt deleted file mode 100644 index eb75fd4dfa9..00000000000 --- a/compiler/testData/klibABI/removeInlinedProperty/lib2/l2.kt +++ /dev/null @@ -1 +0,0 @@ -inline fun bar() = foo diff --git a/compiler/testData/klibABI/removeInlinedProperty/main/m.kt b/compiler/testData/klibABI/removeInlinedProperty/main/m.kt deleted file mode 100644 index 8f0b4b03e77..00000000000 --- a/compiler/testData/klibABI/removeInlinedProperty/main/m.kt +++ /dev/null @@ -1,5 +0,0 @@ -import abitestutils.abiTest - -fun box() = abiTest { - expectFailure(prefixed("property accessor foo. can not be called")) { bar() } -} diff --git a/compiler/testData/klibABI/removeInlinedProperty/project.info b/compiler/testData/klibABI/removeInlinedProperty/project.info deleted file mode 100644 index 2147306d715..00000000000 --- a/compiler/testData/klibABI/removeInlinedProperty/project.info +++ /dev/null @@ -1,7 +0,0 @@ -MODULES: lib1, lib2, main - -STEP 0: - libs: lib1, lib2, main - -STEP 1: - libs: lib1 \ No newline at end of file diff --git a/compiler/testData/klibABI/removeOpenFunction/lib1/l1.kt b/compiler/testData/klibABI/removeOpenFunction/lib1/l1.kt deleted file mode 100644 index 8eba45756c3..00000000000 --- a/compiler/testData/klibABI/removeOpenFunction/lib1/l1.kt +++ /dev/null @@ -1,7 +0,0 @@ -open class C { - open fun foo(): String = "FAIL1" -} - -interface I { - fun foo(): String = "FAIL2" -} diff --git a/compiler/testData/klibABI/removeOpenFunction/lib1/l1.kt.1 b/compiler/testData/klibABI/removeOpenFunction/lib1/l1.kt.1 deleted file mode 100644 index f292e039d67..00000000000 --- a/compiler/testData/klibABI/removeOpenFunction/lib1/l1.kt.1 +++ /dev/null @@ -1,2 +0,0 @@ -open class C -interface I diff --git a/compiler/testData/klibABI/removeOpenFunction/lib2/l2.kt b/compiler/testData/klibABI/removeOpenFunction/lib2/l2.kt deleted file mode 100644 index 1a12ecf83ed..00000000000 --- a/compiler/testData/klibABI/removeOpenFunction/lib2/l2.kt +++ /dev/null @@ -1,7 +0,0 @@ -class C2 : C() { - override fun foo(): String = "O" // does not call super -} - -class I2 : I { - override fun foo(): String = "K" // does not call super -} diff --git a/compiler/testData/klibABI/removeOpenFunction/main/m.kt b/compiler/testData/klibABI/removeOpenFunction/main/m.kt deleted file mode 100644 index 4471e1e6869..00000000000 --- a/compiler/testData/klibABI/removeOpenFunction/main/m.kt +++ /dev/null @@ -1,5 +0,0 @@ -import abitestutils.abiTest - -fun box() = abiTest { - expectSuccess { C2().foo() + I2().foo() } -} diff --git a/compiler/testData/klibABI/removeOpenFunction/project.info b/compiler/testData/klibABI/removeOpenFunction/project.info deleted file mode 100644 index 2147306d715..00000000000 --- a/compiler/testData/klibABI/removeOpenFunction/project.info +++ /dev/null @@ -1,7 +0,0 @@ -MODULES: lib1, lib2, main - -STEP 0: - libs: lib1, lib2, main - -STEP 1: - libs: lib1 \ No newline at end of file diff --git a/compiler/testData/klibABI/removeOpenProperty/lib1/l1.kt b/compiler/testData/klibABI/removeOpenProperty/lib1/l1.kt deleted file mode 100644 index 18576fefd70..00000000000 --- a/compiler/testData/klibABI/removeOpenProperty/lib1/l1.kt +++ /dev/null @@ -1,7 +0,0 @@ -open class C { - open val foo: String get() = "FAIL1" -} - -interface I { - val foo: String get() = "FAIL2" -} diff --git a/compiler/testData/klibABI/removeOpenProperty/lib1/l1.kt.1 b/compiler/testData/klibABI/removeOpenProperty/lib1/l1.kt.1 deleted file mode 100644 index f292e039d67..00000000000 --- a/compiler/testData/klibABI/removeOpenProperty/lib1/l1.kt.1 +++ /dev/null @@ -1,2 +0,0 @@ -open class C -interface I diff --git a/compiler/testData/klibABI/removeOpenProperty/lib2/l2.kt b/compiler/testData/klibABI/removeOpenProperty/lib2/l2.kt deleted file mode 100644 index 11b243fc8dd..00000000000 --- a/compiler/testData/klibABI/removeOpenProperty/lib2/l2.kt +++ /dev/null @@ -1,7 +0,0 @@ -class C2 : C() { - override val foo: String get() = "O" // does not call super -} - -class I2 : I { - override val foo: String get() = "K" // does not call super -} diff --git a/compiler/testData/klibABI/removeOpenProperty/lib2/module.info b/compiler/testData/klibABI/removeOpenProperty/lib2/module.info deleted file mode 100644 index 391aab979a6..00000000000 --- a/compiler/testData/klibABI/removeOpenProperty/lib2/module.info +++ /dev/null @@ -1,2 +0,0 @@ -STEP 0: - dependencies: stdlib, lib1 \ No newline at end of file diff --git a/compiler/testData/klibABI/removeOpenProperty/main/m.kt b/compiler/testData/klibABI/removeOpenProperty/main/m.kt deleted file mode 100644 index 4f5bd8cbb4b..00000000000 --- a/compiler/testData/klibABI/removeOpenProperty/main/m.kt +++ /dev/null @@ -1,5 +0,0 @@ -import abitestutils.abiTest - -fun box() = abiTest { - expectSuccess { C2().foo + I2().foo } -} diff --git a/compiler/testData/klibABI/removeOpenProperty/project.info b/compiler/testData/klibABI/removeOpenProperty/project.info deleted file mode 100644 index 2147306d715..00000000000 --- a/compiler/testData/klibABI/removeOpenProperty/project.info +++ /dev/null @@ -1,7 +0,0 @@ -MODULES: lib1, lib2, main - -STEP 0: - libs: lib1, lib2, main - -STEP 1: - libs: lib1 \ No newline at end of file diff --git a/compiler/testData/klibABI/removeProperty/lib1/l1.kt b/compiler/testData/klibABI/removeProperty/lib1/l1.kt deleted file mode 100644 index 0e1a52aecba..00000000000 --- a/compiler/testData/klibABI/removeProperty/lib1/l1.kt +++ /dev/null @@ -1,12 +0,0 @@ -val foo: String get() = "FAIL1" -val exp_foo: String get() = "FAIL2" - -class A { - val foo: String get() = "FAIL3" - val exp_foo: String get() = "FAIL4" -} - -class B { - val foo: String = "FAIL5" - val exp_foo: String = "FAIL6" -} diff --git a/compiler/testData/klibABI/removeProperty/lib1/l1.kt.1 b/compiler/testData/klibABI/removeProperty/lib1/l1.kt.1 deleted file mode 100644 index 6b214150792..00000000000 --- a/compiler/testData/klibABI/removeProperty/lib1/l1.kt.1 +++ /dev/null @@ -1,9 +0,0 @@ -val foo: String get() = "OK" - -class A { - val foo: String get() = "OK" -} - -class B { - val foo: String = "OK" -} diff --git a/compiler/testData/klibABI/removeProperty/lib2/l2.kt b/compiler/testData/klibABI/removeProperty/lib2/l2.kt deleted file mode 100644 index da7692d7298..00000000000 --- a/compiler/testData/klibABI/removeProperty/lib2/l2.kt +++ /dev/null @@ -1,3 +0,0 @@ -fun qux(exp: Boolean): String = if (exp) exp_foo else foo -fun qux2(exp: Boolean): String = if (exp) A().exp_foo else A().foo -fun qux3(exp: Boolean): String = if (exp) B().exp_foo else B().foo diff --git a/compiler/testData/klibABI/removeProperty/lib2/module.info b/compiler/testData/klibABI/removeProperty/lib2/module.info deleted file mode 100644 index 391aab979a6..00000000000 --- a/compiler/testData/klibABI/removeProperty/lib2/module.info +++ /dev/null @@ -1,2 +0,0 @@ -STEP 0: - dependencies: stdlib, lib1 \ No newline at end of file diff --git a/compiler/testData/klibABI/removeProperty/main/m.kt b/compiler/testData/klibABI/removeProperty/main/m.kt deleted file mode 100644 index 357a498f53f..00000000000 --- a/compiler/testData/klibABI/removeProperty/main/m.kt +++ /dev/null @@ -1,10 +0,0 @@ -import abitestutils.abiTest - -fun box() = abiTest { - expectFailure(prefixed("property accessor exp_foo. can not be called")) { qux(true) } - expectSuccess { qux(false) } - expectFailure(prefixed("property accessor exp_foo. can not be called")) { qux2(true) } - expectSuccess { qux2(false) } - expectFailure(prefixed("property accessor exp_foo. can not be called")) { qux3(true) } - expectSuccess { qux3(false) } -} diff --git a/compiler/testData/klibABI/removeProperty/project.info b/compiler/testData/klibABI/removeProperty/project.info deleted file mode 100644 index 2147306d715..00000000000 --- a/compiler/testData/klibABI/removeProperty/project.info +++ /dev/null @@ -1,7 +0,0 @@ -MODULES: lib1, lib2, main - -STEP 0: - libs: lib1, lib2, main - -STEP 1: - libs: lib1 \ No newline at end of file diff --git a/compiler/testData/klibABI/removeSealedSubclass/lib1/l1.kt b/compiler/testData/klibABI/removeSealedSubclass/lib1/l1.kt new file mode 100644 index 00000000000..475ff29cf10 --- /dev/null +++ b/compiler/testData/klibABI/removeSealedSubclass/lib1/l1.kt @@ -0,0 +1,45 @@ +sealed class SC1 { + class C1 : SC1() + object O1 : SC1() + class Removed : SC1() + class C2 : SC1() + object O2 : SC1() +} + +sealed class SC2 { + class C1 : SC2() + object O1 : SC2() + object Removed : SC2() + class C2 : SC2() + object O2 : SC2() +} + +sealed interface SI1 { + class C1 : SI1 + object O1 : SI1 + interface I1 : SI1 + class Removed : SI1 + class C2 : SI1 + object O2 : SI1 + interface I2 : SI1 +} + +sealed interface SI2 { + class C1 : SI2 + object O1 : SI2 + interface I1 : SI2 + object Removed : SI2 + class C2 : SI2 + object O2 : SI2 + interface I2 : SI2 +} + +sealed interface SI3 { + class C1 : SI3 + object O1 : SI3 + interface I1 : SI3 + interface Removed : SI3 + class C2 : SI3 + object O2 : SI3 + interface I2 : SI3 +} diff --git a/compiler/testData/klibABI/removeSealedSubclass/lib1/l1.kt.1 b/compiler/testData/klibABI/removeSealedSubclass/lib1/l1.kt.1 new file mode 100644 index 00000000000..06a03a5047d --- /dev/null +++ b/compiler/testData/klibABI/removeSealedSubclass/lib1/l1.kt.1 @@ -0,0 +1,45 @@ +sealed class SC1 { + class C1 : SC1() + object O1 : SC1() +// class Removed : SC1() + class C2 : SC1() + object O2 : SC1() +} + +sealed class SC2 { + class C1 : SC2() + object O1 : SC2() +// object Removed : SC2() + class C2 : SC2() + object O2 : SC2() +} + +sealed interface SI1 { + class C1 : SI1 + object O1 : SI1 + interface I1 : SI1 +// class Removed : SI1 + class C2 : SI1 + object O2 : SI1 + interface I2 : SI1 +} + +sealed interface SI2 { + class C1 : SI2 + object O1 : SI2 + interface I1 : SI2 +// object Removed : SI2 + class C2 : SI2 + object O2 : SI2 + interface I2 : SI2 +} + +sealed interface SI3 { + class C1 : SI3 + object O1 : SI3 + interface I1 : SI3 +// interface Removed : SI3 + class C2 : SI3 + object O2 : SI3 + interface I2 : SI3 +} diff --git a/compiler/testData/klibABI/removeProperty/lib1/module.info b/compiler/testData/klibABI/removeSealedSubclass/lib1/module.info similarity index 100% rename from compiler/testData/klibABI/removeProperty/lib1/module.info rename to compiler/testData/klibABI/removeSealedSubclass/lib1/module.info diff --git a/compiler/testData/klibABI/removeSealedSubclass/lib2/l2.kt b/compiler/testData/klibABI/removeSealedSubclass/lib2/l2.kt new file mode 100644 index 00000000000..7c9c59b527f --- /dev/null +++ b/compiler/testData/klibABI/removeSealedSubclass/lib2/l2.kt @@ -0,0 +1,45 @@ +fun compute(sealedClass: SC1): String = when (sealedClass) { + is SC1.C1 -> "OK" + SC1.O1 -> "OK" + is SC1.Removed -> "FAIL1" + is SC1.C2 -> "FAIL2" + SC1.O2 -> "FAIL3" +} + +fun compute(sealedClass: SC2): String = when (sealedClass) { + is SC2.C1 -> "OK" + SC2.O1 -> "OK" + SC2.Removed -> "FAIL4" + is SC2.C2 -> "FAIL5" + SC2.O2 -> "FAIL6" +} + +fun compute(sealedInterface: SI1): String = when (sealedInterface) { + is SI1.C1 -> "OK" + SI1.O1 -> "OK" + is SI1.I1 -> "OK" + is SI1.Removed -> "FAIL7" + is SI1.C2 -> "FAIL8" + SI1.O2 -> "FAIL9" + is SI1.I2 -> "FAIL10" +} + +fun compute(sealedInterface: SI2): String = when (sealedInterface) { + is SI2.C1 -> "OK" + SI2.O1 -> "OK" + is SI2.I1 -> "OK" + SI2.Removed -> "FAIL11" + is SI2.C2 -> "FAIL12" + SI2.O2 -> "FAIL13" + is SI2.I2 -> "FAIL14" +} + +fun compute(sealedInterface: SI3): String = when (sealedInterface) { + is SI3.C1 -> "OK" + SI3.O1 -> "OK" + is SI3.I1 -> "OK" + is SI3.Removed -> "FAIL15" + is SI3.C2 -> "FAIL16" + SI3.O2 -> "FAIL17" + is SI3.I2 -> "FAIL18" +} diff --git a/compiler/testData/klibABI/removeInlinedProperty/lib2/module.info b/compiler/testData/klibABI/removeSealedSubclass/lib2/module.info similarity index 100% rename from compiler/testData/klibABI/removeInlinedProperty/lib2/module.info rename to compiler/testData/klibABI/removeSealedSubclass/lib2/module.info diff --git a/compiler/testData/klibABI/removeSealedSubclass/main/m.kt b/compiler/testData/klibABI/removeSealedSubclass/main/m.kt new file mode 100644 index 00000000000..77532d2ed31 --- /dev/null +++ b/compiler/testData/klibABI/removeSealedSubclass/main/m.kt @@ -0,0 +1,39 @@ +import abitestutils.abiTest + +fun box() = abiTest { + expectFailure(linkage("Type operator expression can not be evaluated: Expression uses unlinked class symbol '/SC1.Removed'")) { compute(SC1.O2) } + expectFailure(linkage("Type operator expression can not be evaluated: Expression uses unlinked class symbol '/SC1.Removed'")) { compute(SC1.C2()) } + expectFailure(linkage("Constructor 'Removed.' can not be called: No constructor found for symbol '/SC1.Removed.'")) { compute(SC1.Removed()) } + expectSuccess { compute(SC1.O1) } + expectSuccess { compute(SC1.C1()) } + + expectFailure(linkage("Can not get instance of singleton 'Removed': No class found for symbol '/SC2.Removed'")) { compute(SC2.O2) } + expectFailure(linkage("Can not get instance of singleton 'Removed': No class found for symbol '/SC2.Removed'")) { compute(SC2.C2()) } + expectFailure(linkage("Can not get instance of singleton 'Removed': No class found for symbol '/SC2.Removed'")) { compute(SC2.Removed) } + expectSuccess { compute(SC2.O1) } + expectSuccess { compute(SC2.C1()) } + + expectFailure(linkage("Type operator expression can not be evaluated: Expression uses unlinked class symbol '/SI1.Removed'")) { compute(object : SI1.I2 {}) } + expectFailure(linkage("Type operator expression can not be evaluated: Expression uses unlinked class symbol '/SI1.Removed'")) { compute(SI1.O2) } + expectFailure(linkage("Type operator expression can not be evaluated: Expression uses unlinked class symbol '/SI1.Removed'")) { compute(SI1.C2()) } + expectFailure(linkage("Constructor 'Removed.' can not be called: No constructor found for symbol '/SI1.Removed.'")) { compute(SI1.Removed()) } + expectSuccess { compute(object : SI1.I1 {}) } + expectSuccess { compute(SI1.O1) } + expectSuccess { compute(SI1.C1()) } + + expectFailure(linkage("Can not get instance of singleton 'Removed': No class found for symbol '/SI2.Removed'")) { compute(object : SI2.I2 {}) } + expectFailure(linkage("Can not get instance of singleton 'Removed': No class found for symbol '/SI2.Removed'")) { compute(SI2.O2) } + expectFailure(linkage("Can not get instance of singleton 'Removed': No class found for symbol '/SI2.Removed'")) { compute(SI2.C2()) } + expectFailure(linkage("Can not get instance of singleton 'Removed': No class found for symbol '/SI2.Removed'")) { compute(SI2.Removed) } + expectSuccess { compute(object : SI2.I1 {}) } + expectSuccess { compute(SI2.O1) } + expectSuccess { compute(SI2.C1()) } + + expectFailure(linkage("Type operator expression can not be evaluated: Expression uses unlinked class symbol '/SI3.Removed'")) { compute(object : SI3.I2 {}) } + expectFailure(linkage("Type operator expression can not be evaluated: Expression uses unlinked class symbol '/SI3.Removed'")) { compute(SI3.O2) } + expectFailure(linkage("Type operator expression can not be evaluated: Expression uses unlinked class symbol '/SI3.Removed'")) { compute(SI3.C2()) } + expectFailure(linkage("Constructor '' can not be called: Anonymous object uses unlinked class symbol '/SI3.Removed'")) { compute(object : SI3.Removed {}) } + expectSuccess { compute(object : SI3.I1 {}) } + expectSuccess { compute(SI3.O1) } + expectSuccess { compute(SI3.C1()) } +} diff --git a/compiler/testData/klibABI/removeInlinedProperty/main/module.info b/compiler/testData/klibABI/removeSealedSubclass/main/module.info similarity index 100% rename from compiler/testData/klibABI/removeInlinedProperty/main/module.info rename to compiler/testData/klibABI/removeSealedSubclass/main/module.info diff --git a/compiler/testData/klibABI/removeFunction/project.info b/compiler/testData/klibABI/removeSealedSubclass/project.info similarity index 100% rename from compiler/testData/klibABI/removeFunction/project.info rename to compiler/testData/klibABI/removeSealedSubclass/project.info diff --git a/compiler/testData/klibABI/typeAliasChanges/lib1/l1.kt b/compiler/testData/klibABI/typeAliasChanges/lib1/l1.kt new file mode 100644 index 00000000000..6936f66eb11 --- /dev/null +++ b/compiler/testData/klibABI/typeAliasChanges/lib1/l1.kt @@ -0,0 +1,9 @@ +open class OpenClass1(private val x: Int) { + final override fun toString() = "${this::class.simpleName}(x=$x)" +} +open class OpenClass2(private val x: String) { + final override fun toString() = "${this::class.simpleName}(x=$x)" +} +typealias OpenClassRemovedTA = OpenClass1 +typealias OpenClassChangedTA = OpenClass1 +public typealias OpenClassNarrowedVisibilityTA = OpenClass1 diff --git a/compiler/testData/klibABI/typeAliasChanges/lib1/l1.kt.1 b/compiler/testData/klibABI/typeAliasChanges/lib1/l1.kt.1 new file mode 100644 index 00000000000..3151e7185e6 --- /dev/null +++ b/compiler/testData/klibABI/typeAliasChanges/lib1/l1.kt.1 @@ -0,0 +1,9 @@ +open class OpenClass1(private val x: Int) { + final override fun toString() = "${this::class.simpleName}(x=$x)" +} +open class OpenClass2(private val x: String) { + final override fun toString() = "${this::class.simpleName}(x=$x)" +} +//typealias OpenClassRemovedTA = OpenClass1 +typealias OpenClassChangedTA = /*OpenClass1*/ OpenClass2 +/*public*/ private typealias OpenClassNarrowedVisibilityTA = OpenClass1 diff --git a/compiler/testData/klibABI/typeAliasRHSTypeChange/lib1/module.info b/compiler/testData/klibABI/typeAliasChanges/lib1/module.info similarity index 100% rename from compiler/testData/klibABI/typeAliasRHSTypeChange/lib1/module.info rename to compiler/testData/klibABI/typeAliasChanges/lib1/module.info diff --git a/compiler/testData/klibABI/typeAliasChanges/lib2/l2.kt b/compiler/testData/klibABI/typeAliasChanges/lib2/l2.kt new file mode 100644 index 00000000000..09c6011513e --- /dev/null +++ b/compiler/testData/klibABI/typeAliasChanges/lib2/l2.kt @@ -0,0 +1,50 @@ +open class OpenClassRemovedTAImpl(x: Int) : OpenClassRemovedTA(-x) +data class OpenClassRemovedTATypeParameterHolder(val t: T) +data class OpenClassRemovedTAImplTypeParameterHolder(val t: T) + +fun getOpenClassRemovedTA(x: Int): OpenClassRemovedTA = OpenClassRemovedTA(x) +fun setOpenClassRemovedTA(value: OpenClassRemovedTA?): String = value?.toString() ?: "setOpenClassRemovedTA" +fun getOpenClassRemovedTAImpl(x: Int): OpenClassRemovedTA = OpenClassRemovedTAImpl(x) +fun setOpenClassRemovedTAImpl(value: OpenClassRemovedTAImpl?): String = value?.toString() ?: "setOpenClassRemovedTAImpl" + +fun getOpenClassRemovedTATypeParameterHolder1(x: Int): OpenClassRemovedTATypeParameterHolder = OpenClassRemovedTATypeParameterHolder(OpenClassRemovedTA(x)) +fun getOpenClassRemovedTATypeParameterHolder2(x: Int): OpenClassRemovedTATypeParameterHolder = OpenClassRemovedTATypeParameterHolder(OpenClassRemovedTAImpl(x)) +fun setOpenClassRemovedTATypeParameterHolder1(value: OpenClassRemovedTATypeParameterHolder?): String = value?.toString() ?: "setOpenClassRemovedTATypeParameterHolder1" +fun setOpenClassRemovedTATypeParameterHolder2(value: OpenClassRemovedTATypeParameterHolder?): String = value?.toString() ?: "setOpenClassRemovedTATypeParameterHolder2" + +fun getOpenClassRemovedTAImplTypeParameterHolder(x: Int): OpenClassRemovedTAImplTypeParameterHolder = OpenClassRemovedTAImplTypeParameterHolder(OpenClassRemovedTAImpl(x)) +fun setOpenClassRemovedTAImplTypeParameterHolder(value: OpenClassRemovedTAImplTypeParameterHolder?): String = value?.toString() ?: "setOpenClassRemovedTAImplTypeParameterHolder" + +open class OpenClassChangedTAImpl(x: Int) : OpenClassChangedTA(-x) +data class OpenClassChangedTATypeParameterHolder(val t: T) +data class OpenClassChangedTAImplTypeParameterHolder(val t: T) + +fun getOpenClassChangedTA(x: Int): OpenClassChangedTA = OpenClassChangedTA(x) +fun setOpenClassChangedTA(value: OpenClassChangedTA?): String = value?.toString() ?: "setOpenClassChangedTA" +fun getOpenClassChangedTAImpl(x: Int): OpenClassChangedTA = OpenClassChangedTAImpl(x) +fun setOpenClassChangedTAImpl(value: OpenClassChangedTAImpl?): String = value?.toString() ?: "setOpenClassChangedTAImpl" + +fun getOpenClassChangedTATypeParameterHolder1(x: Int): OpenClassChangedTATypeParameterHolder = OpenClassChangedTATypeParameterHolder(OpenClassChangedTA(x)) +fun getOpenClassChangedTATypeParameterHolder2(x: Int): OpenClassChangedTATypeParameterHolder = OpenClassChangedTATypeParameterHolder(OpenClassChangedTAImpl(x)) +fun setOpenClassChangedTATypeParameterHolder1(value: OpenClassChangedTATypeParameterHolder?): String = value?.toString() ?: "setOpenClassChangedTATypeParameterHolder1" +fun setOpenClassChangedTATypeParameterHolder2(value: OpenClassChangedTATypeParameterHolder?): String = value?.toString() ?: "setOpenClassChangedTATypeParameterHolder2" + +fun getOpenClassChangedTAImplTypeParameterHolder(x: Int): OpenClassChangedTAImplTypeParameterHolder = OpenClassChangedTAImplTypeParameterHolder(OpenClassChangedTAImpl(x)) +fun setOpenClassChangedTAImplTypeParameterHolder(value: OpenClassChangedTAImplTypeParameterHolder?): String = value?.toString() ?: "setOpenClassChangedTAImplTypeParameterHolder" + +open class OpenClassNarrowedVisibilityTAImpl(x: Int) : OpenClassNarrowedVisibilityTA(-x) +data class OpenClassNarrowedVisibilityTATypeParameterHolder(val t: T) +data class OpenClassNarrowedVisibilityTAImplTypeParameterHolder(val t: T) + +fun getOpenClassNarrowedVisibilityTA(x: Int): OpenClassNarrowedVisibilityTA = OpenClassNarrowedVisibilityTA(x) +fun setOpenClassNarrowedVisibilityTA(value: OpenClassNarrowedVisibilityTA?): String = value?.toString() ?: "setOpenClassNarrowedVisibilityTA" +fun getOpenClassNarrowedVisibilityTAImpl(x: Int): OpenClassNarrowedVisibilityTA = OpenClassNarrowedVisibilityTAImpl(x) +fun setOpenClassNarrowedVisibilityTAImpl(value: OpenClassNarrowedVisibilityTAImpl?): String = value?.toString() ?: "setOpenClassNarrowedVisibilityTAImpl" + +fun getOpenClassNarrowedVisibilityTATypeParameterHolder1(x: Int): OpenClassNarrowedVisibilityTATypeParameterHolder = OpenClassNarrowedVisibilityTATypeParameterHolder(OpenClassNarrowedVisibilityTA(x)) +fun getOpenClassNarrowedVisibilityTATypeParameterHolder2(x: Int): OpenClassNarrowedVisibilityTATypeParameterHolder = OpenClassNarrowedVisibilityTATypeParameterHolder(OpenClassNarrowedVisibilityTAImpl(x)) +fun setOpenClassNarrowedVisibilityTATypeParameterHolder1(value: OpenClassNarrowedVisibilityTATypeParameterHolder?): String = value?.toString() ?: "setOpenClassNarrowedVisibilityTATypeParameterHolder1" +fun setOpenClassNarrowedVisibilityTATypeParameterHolder2(value: OpenClassNarrowedVisibilityTATypeParameterHolder?): String = value?.toString() ?: "setOpenClassNarrowedVisibilityTATypeParameterHolder2" + +fun getOpenClassNarrowedVisibilityTAImplTypeParameterHolder(x: Int): OpenClassNarrowedVisibilityTAImplTypeParameterHolder = OpenClassNarrowedVisibilityTAImplTypeParameterHolder(OpenClassNarrowedVisibilityTAImpl(x)) +fun setOpenClassNarrowedVisibilityTAImplTypeParameterHolder(value: OpenClassNarrowedVisibilityTAImplTypeParameterHolder?): String = value?.toString() ?: "setOpenClassNarrowedVisibilityTAImplTypeParameterHolder" diff --git a/compiler/testData/klibABI/removeOpenFunction/lib2/module.info b/compiler/testData/klibABI/typeAliasChanges/lib2/module.info similarity index 100% rename from compiler/testData/klibABI/removeOpenFunction/lib2/module.info rename to compiler/testData/klibABI/typeAliasChanges/lib2/module.info diff --git a/compiler/testData/klibABI/typeAliasChanges/main/m.kt b/compiler/testData/klibABI/typeAliasChanges/main/m.kt new file mode 100644 index 00000000000..3fd46e53953 --- /dev/null +++ b/compiler/testData/klibABI/typeAliasChanges/main/m.kt @@ -0,0 +1,36 @@ +import abitestutils.abiTest + +fun box() = abiTest { + expectSuccess("OpenClass1(x=1)") { getOpenClassRemovedTA(1).toString() } + expectSuccess("setOpenClassRemovedTA") { setOpenClassRemovedTA(null) } + expectSuccess("OpenClassRemovedTAImpl(x=-2)") { getOpenClassRemovedTAImpl(2).toString() } + expectSuccess("setOpenClassRemovedTAImpl") { setOpenClassRemovedTAImpl(null) } + expectSuccess("OpenClassRemovedTATypeParameterHolder(t=OpenClass1(x=3))") { getOpenClassRemovedTATypeParameterHolder1(3).toString() } + expectSuccess("OpenClassRemovedTATypeParameterHolder(t=OpenClassRemovedTAImpl(x=-4))") { getOpenClassRemovedTATypeParameterHolder2(4).toString() } + expectSuccess("setOpenClassRemovedTATypeParameterHolder1") { setOpenClassRemovedTATypeParameterHolder1(null) } + expectSuccess("setOpenClassRemovedTATypeParameterHolder2") { setOpenClassRemovedTATypeParameterHolder2(null) } + expectSuccess("OpenClassRemovedTAImplTypeParameterHolder(t=OpenClassRemovedTAImpl(x=-5))") { getOpenClassRemovedTAImplTypeParameterHolder(5).toString() } + expectSuccess("setOpenClassRemovedTAImplTypeParameterHolder") { setOpenClassRemovedTAImplTypeParameterHolder(null) } + + expectSuccess("OpenClass1(x=1)") { getOpenClassChangedTA(1).toString() } + expectSuccess("setOpenClassChangedTA") { setOpenClassChangedTA(null) } + expectSuccess("OpenClassChangedTAImpl(x=-2)") { getOpenClassChangedTAImpl(2).toString() } + expectSuccess("setOpenClassChangedTAImpl") { setOpenClassChangedTAImpl(null) } + expectSuccess("OpenClassChangedTATypeParameterHolder(t=OpenClass1(x=3))") { getOpenClassChangedTATypeParameterHolder1(3).toString() } + expectSuccess("OpenClassChangedTATypeParameterHolder(t=OpenClassChangedTAImpl(x=-4))") { getOpenClassChangedTATypeParameterHolder2(4).toString() } + expectSuccess("setOpenClassChangedTATypeParameterHolder1") { setOpenClassChangedTATypeParameterHolder1(null) } + expectSuccess("setOpenClassChangedTATypeParameterHolder2") { setOpenClassChangedTATypeParameterHolder2(null) } + expectSuccess("OpenClassChangedTAImplTypeParameterHolder(t=OpenClassChangedTAImpl(x=-5))") { getOpenClassChangedTAImplTypeParameterHolder(5).toString() } + expectSuccess("setOpenClassChangedTAImplTypeParameterHolder") { setOpenClassChangedTAImplTypeParameterHolder(null) } + + expectSuccess("OpenClass1(x=1)") { getOpenClassNarrowedVisibilityTA(1).toString() } + expectSuccess("setOpenClassNarrowedVisibilityTA") { setOpenClassNarrowedVisibilityTA(null) } + expectSuccess("OpenClassNarrowedVisibilityTAImpl(x=-2)") { getOpenClassNarrowedVisibilityTAImpl(2).toString() } + expectSuccess("setOpenClassNarrowedVisibilityTAImpl") { setOpenClassNarrowedVisibilityTAImpl(null) } + expectSuccess("OpenClassNarrowedVisibilityTATypeParameterHolder(t=OpenClass1(x=3))") { getOpenClassNarrowedVisibilityTATypeParameterHolder1(3).toString() } + expectSuccess("OpenClassNarrowedVisibilityTATypeParameterHolder(t=OpenClassNarrowedVisibilityTAImpl(x=-4))") { getOpenClassNarrowedVisibilityTATypeParameterHolder2(4).toString() } + expectSuccess("setOpenClassNarrowedVisibilityTATypeParameterHolder1") { setOpenClassNarrowedVisibilityTATypeParameterHolder1(null) } + expectSuccess("setOpenClassNarrowedVisibilityTATypeParameterHolder2") { setOpenClassNarrowedVisibilityTATypeParameterHolder2(null) } + expectSuccess("OpenClassNarrowedVisibilityTAImplTypeParameterHolder(t=OpenClassNarrowedVisibilityTAImpl(x=-5))") { getOpenClassNarrowedVisibilityTAImplTypeParameterHolder(5).toString() } + expectSuccess("setOpenClassNarrowedVisibilityTAImplTypeParameterHolder") { setOpenClassNarrowedVisibilityTAImplTypeParameterHolder(null) } +} diff --git a/compiler/testData/klibABI/removeOpenFunction/main/module.info b/compiler/testData/klibABI/typeAliasChanges/main/module.info similarity index 100% rename from compiler/testData/klibABI/removeOpenFunction/main/module.info rename to compiler/testData/klibABI/typeAliasChanges/main/module.info diff --git a/compiler/testData/klibABI/removeInlinedClass/project.info b/compiler/testData/klibABI/typeAliasChanges/project.info similarity index 100% rename from compiler/testData/klibABI/removeInlinedClass/project.info rename to compiler/testData/klibABI/typeAliasChanges/project.info diff --git a/compiler/testData/klibABI/typeAliasRHSTypeChange/lib1/l1.kt b/compiler/testData/klibABI/typeAliasRHSTypeChange/lib1/l1.kt deleted file mode 100644 index a7224d9a2c1..00000000000 --- a/compiler/testData/klibABI/typeAliasRHSTypeChange/lib1/l1.kt +++ /dev/null @@ -1,3 +0,0 @@ -typealias S = String - -fun foo(s : S) = s diff --git a/compiler/testData/klibABI/typeAliasRHSTypeChange/lib1/l1.kt.1 b/compiler/testData/klibABI/typeAliasRHSTypeChange/lib1/l1.kt.1 deleted file mode 100644 index 851a0def208..00000000000 --- a/compiler/testData/klibABI/typeAliasRHSTypeChange/lib1/l1.kt.1 +++ /dev/null @@ -1,3 +0,0 @@ -typealias S = Int - -fun foo(s : S) = s.toString() diff --git a/compiler/testData/klibABI/typeAliasRHSTypeChange/lib2/l2.kt b/compiler/testData/klibABI/typeAliasRHSTypeChange/lib2/l2.kt deleted file mode 100644 index a0d9841fe73..00000000000 --- a/compiler/testData/klibABI/typeAliasRHSTypeChange/lib2/l2.kt +++ /dev/null @@ -1,8 +0,0 @@ -fun bar(): String { - val s: S = "OK" - return s -} - -fun callFoo() { - foo("Hello") -} diff --git a/compiler/testData/klibABI/typeAliasRHSTypeChange/lib2/module.info b/compiler/testData/klibABI/typeAliasRHSTypeChange/lib2/module.info deleted file mode 100644 index 391aab979a6..00000000000 --- a/compiler/testData/klibABI/typeAliasRHSTypeChange/lib2/module.info +++ /dev/null @@ -1,2 +0,0 @@ -STEP 0: - dependencies: stdlib, lib1 \ No newline at end of file diff --git a/compiler/testData/klibABI/typeAliasRHSTypeChange/main/m.kt b/compiler/testData/klibABI/typeAliasRHSTypeChange/main/m.kt deleted file mode 100644 index aaeb19b5e3d..00000000000 --- a/compiler/testData/klibABI/typeAliasRHSTypeChange/main/m.kt +++ /dev/null @@ -1,6 +0,0 @@ -import abitestutils.abiTest - -fun box() = abiTest { - expectFailure(prefixed("function foo can not be called")) { callFoo() } - expectSuccess { bar() } -} diff --git a/compiler/testData/klibABI/typeAliasRHSTypeChange/project.info b/compiler/testData/klibABI/typeAliasRHSTypeChange/project.info deleted file mode 100644 index 2147306d715..00000000000 --- a/compiler/testData/klibABI/typeAliasRHSTypeChange/project.info +++ /dev/null @@ -1,7 +0,0 @@ -MODULES: lib1, lib2, main - -STEP 0: - libs: lib1, lib2, main - -STEP 1: - libs: lib1 \ No newline at end of file diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/klib/KlibABITestUtils.kt b/compiler/tests-common/tests/org/jetbrains/kotlin/klib/KlibABITestUtils.kt index 9e940573822..82707ec1b43 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/klib/KlibABITestUtils.kt +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/klib/KlibABITestUtils.kt @@ -17,6 +17,7 @@ object KlibABITestUtils { val testDir: File val buildDir: File val stdlibFile: File + val testModeName: String fun buildKlib(moduleName: String, moduleSourceDir: File, dependencies: Dependencies, klibFile: File) fun buildBinaryAndRun(mainModuleKlibFile: File, dependencies: Dependencies) @@ -64,7 +65,9 @@ object KlibABITestUtils { val utilsDir = testDir.parentFile.resolve(ABI_UTILS_DIR) KtUsefulTestCase.assertExists(utilsDir) - copySources(from = utilsDir, to = moduleBuildDirs.sourceDir) + copySources(from = utilsDir, to = moduleBuildDirs.sourceDir) { contents -> + contents.replace(TEST_MODE_PLACEHOLDER, testModeName) + } } val moduleOutputDir = moduleBuildDirs.outputDir.apply { mkdirs() } @@ -123,12 +126,25 @@ object KlibABITestUtils { buildBinaryAndRun(mainModuleKlibFile, binaryDependencies) } - private fun copySources(from: File, to: File) { + private fun copySources(from: File, to: File, patchSourceFile: ((String) -> String)? = null) { + var anyFilePatched = false + from.walk().filter { it.isFile && it.extension == "kt" }.forEach { sourceFile -> val destFile = to.resolve(sourceFile.relativeTo(from)) destFile.parentFile.mkdirs() sourceFile.copyTo(destFile) + + if (patchSourceFile != null) { + val originalContents = destFile.readText() + val patchedContents = patchSourceFile(originalContents) + if (originalContents != patchedContents) { + anyFilePatched = true + destFile.writeText(patchedContents) + } + } } + + check(patchSourceFile == null || anyFilePatched) { "No source files have been patched" } } fun createModuleDirs(buildDir: File, moduleName: String): ModuleBuildDirs { @@ -156,4 +172,5 @@ object KlibABITestUtils { const val MAIN_MODULE_NAME = "main" private const val ABI_UTILS_DIR = "__utils__" + private const val TEST_MODE_PLACEHOLDER = "TestMode.__UNKNOWN__" } diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/AbstractJsKLibABITestCase.kt b/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/AbstractJsKLibABITestCase.kt index 968d72ec5c3..d39f7911d30 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/AbstractJsKLibABITestCase.kt +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/AbstractJsKLibABITestCase.kt @@ -91,6 +91,7 @@ abstract class AbstractJsKLibABITestCase : KtUsefulTestCase() { override val testDir: File = File(testPath).absoluteFile override val buildDir: File get() = this@AbstractJsKLibABITestCase.buildDir override val stdlibFile: File get() = File("libraries/stdlib/js-ir/build/classes/kotlin/js/main").absoluteFile + override val testModeName = if (this@AbstractJsKLibABITestCase.useIncrementalCompiler) "JS_WITH_IC" else "JS_NO_IC" override fun buildKlib(moduleName: String, moduleSourceDir: File, dependencies: KlibABITestUtils.Dependencies, klibFile: File) = this@AbstractJsKLibABITestCase.buildKlib(moduleName, moduleSourceDir, dependencies, klibFile) @@ -103,20 +104,6 @@ abstract class AbstractJsKLibABITestCase : KtUsefulTestCase() { directory.listFiles()?.forEach(File::deleteRecursively) } - // TODO: Suppress the tests failing with ISE "Symbol for is unbound" until KT-54491 is fixed. - // Such failures are caused by references to unbound symbols still preserved in CacheUpdater in JS IR IC. - override fun isIgnoredTest(projectInfo: ProjectInfo) = when { - super.isIgnoredTest(projectInfo) -> true - !useIncrementalCompiler -> false - else -> projectInfo.name in setOf( - "removeFunction", - "removeProperty", - "removeOpenFunction", - "removeOpenProperty", - "removeInlinedClass" - ) - } - override fun onIgnoredTest() { /* Do nothing specific. JUnit 3 does not support programmatic tests muting. */ } diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/JsKLibABINoICTestCaseGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/JsKLibABINoICTestCaseGenerated.java index 8a73ada4447..c6cf5139576 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/JsKLibABINoICTestCaseGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/JsKLibABINoICTestCaseGenerated.java @@ -26,10 +26,25 @@ public class JsKLibABINoICTestCaseGenerated extends AbstractJsKLibABINoICTestCas KotlinTestUtils.runTest(this::doTest, TargetBackend.JS_IR, testDataFilePath); } + @TestMetadata("addEnumEntry") + public void testAddEnumEntry() throws Exception { + runTest("compiler/testData/klibABI/addEnumEntry/"); + } + + @TestMetadata("addSealedSubclass") + public void testAddSealedSubclass() throws Exception { + runTest("compiler/testData/klibABI/addSealedSubclass/"); + } + public void testAllFilesPresentInKlibABI() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/klibABI"), Pattern.compile("^([^_](.+))$"), null, TargetBackend.JS_IR, false); } + @TestMetadata("changeClassVisibility") + public void testChangeClassVisibility() throws Exception { + runTest("compiler/testData/klibABI/changeClassVisibility/"); + } + @TestMetadata("changeFunctionVisibility") public void testChangeFunctionVisibility() throws Exception { runTest("compiler/testData/klibABI/changeFunctionVisibility/"); @@ -40,114 +55,69 @@ public class JsKLibABINoICTestCaseGenerated extends AbstractJsKLibABINoICTestCas runTest("compiler/testData/klibABI/changePropertyVisibility/"); } + @TestMetadata("classTransformations") + public void testClassTransformations() throws Exception { + runTest("compiler/testData/klibABI/classTransformations/"); + } + + @TestMetadata("functionTransformations") + public void testFunctionTransformations() throws Exception { + runTest("compiler/testData/klibABI/functionTransformations/"); + } + + @TestMetadata("inheritanceIssues") + public void testInheritanceIssues() throws Exception { + runTest("compiler/testData/klibABI/inheritanceIssues/"); + } + @TestMetadata("noNonImplementedCallableFalsePositives") public void testNoNonImplementedCallableFalsePositives() throws Exception { runTest("compiler/testData/klibABI/noNonImplementedCallableFalsePositives/"); } - @TestMetadata("nonAbstractFunctionInAbstractClassBecomesAbstract") - public void testNonAbstractFunctionInAbstractClassBecomesAbstract() throws Exception { - runTest("compiler/testData/klibABI/nonAbstractFunctionInAbstractClassBecomesAbstract/"); + @TestMetadata("nonAbstractCallableBecomesAbstract") + public void testNonAbstractCallableBecomesAbstract() throws Exception { + runTest("compiler/testData/klibABI/nonAbstractCallableBecomesAbstract/"); } - @TestMetadata("nonAbstractFunctionInInterfaceBecomesAbstract") - public void testNonAbstractFunctionInInterfaceBecomesAbstract() throws Exception { - runTest("compiler/testData/klibABI/nonAbstractFunctionInInterfaceBecomesAbstract/"); + @TestMetadata("nonExhaustivenessOfWhenClause") + public void testNonExhaustivenessOfWhenClause() throws Exception { + runTest("compiler/testData/klibABI/nonExhaustivenessOfWhenClause/"); } - @TestMetadata("nonAbstractPropertyInAbstractClassBecomesAbstract") - public void testNonAbstractPropertyInAbstractClassBecomesAbstract() throws Exception { - runTest("compiler/testData/klibABI/nonAbstractPropertyInAbstractClassBecomesAbstract/"); + @TestMetadata("propertyTransformations") + public void testPropertyTransformations() throws Exception { + runTest("compiler/testData/klibABI/propertyTransformations/"); } - @TestMetadata("nonAbstractPropertyInInterfaceBecomesAbstract") - public void testNonAbstractPropertyInInterfaceBecomesAbstract() throws Exception { - runTest("compiler/testData/klibABI/nonAbstractPropertyInInterfaceBecomesAbstract/"); + @TestMetadata("referencingUnusableDeclarations") + public void testReferencingUnusableDeclarations() throws Exception { + runTest("compiler/testData/klibABI/referencingUnusableDeclarations/"); } - @TestMetadata("removeAbstractFunctionFromAbstractClass") - public void testRemoveAbstractFunctionFromAbstractClass() throws Exception { - runTest("compiler/testData/klibABI/removeAbstractFunctionFromAbstractClass/"); + @TestMetadata("removeAbstractCallableFromAbstractClassOrInterface") + public void testRemoveAbstractCallableFromAbstractClassOrInterface() throws Exception { + runTest("compiler/testData/klibABI/removeAbstractCallableFromAbstractClassOrInterface/"); } - @TestMetadata("removeAbstractFunctionFromInterface") - public void testRemoveAbstractFunctionFromInterface() throws Exception { - runTest("compiler/testData/klibABI/removeAbstractFunctionFromInterface/"); + @TestMetadata("removeCallable") + public void testRemoveCallable() throws Exception { + runTest("compiler/testData/klibABI/removeCallable/"); } - @TestMetadata("removeAbstractPropertyFromAbstractClass") - public void testRemoveAbstractPropertyFromAbstractClass() throws Exception { - runTest("compiler/testData/klibABI/removeAbstractPropertyFromAbstractClass/"); + @TestMetadata("removeClass") + public void testRemoveClass() throws Exception { + runTest("compiler/testData/klibABI/removeClass/"); } - @TestMetadata("removeAbstractPropertyFromInterface") - public void testRemoveAbstractPropertyFromInterface() throws Exception { - runTest("compiler/testData/klibABI/removeAbstractPropertyFromInterface/"); + @TestMetadata("removeEnumEntry") + public void testRemoveEnumEntry() throws Exception { + runTest("compiler/testData/klibABI/removeEnumEntry/"); } - @TestMetadata("removeClassAsConstructorCall") - public void testRemoveClassAsConstructorCall() throws Exception { - runTest("compiler/testData/klibABI/removeClassAsConstructorCall/"); - } - - @TestMetadata("removeClassAsParameterType") - public void testRemoveClassAsParameterType() throws Exception { - runTest("compiler/testData/klibABI/removeClassAsParameterType/"); - } - - @TestMetadata("removeClassAsReturnType") - public void testRemoveClassAsReturnType() throws Exception { - runTest("compiler/testData/klibABI/removeClassAsReturnType/"); - } - - @TestMetadata("removeClassAsSuperTypeArgument") - public void testRemoveClassAsSuperTypeArgument() throws Exception { - runTest("compiler/testData/klibABI/removeClassAsSuperTypeArgument/"); - } - - @TestMetadata("removeClassAsTypeArgument") - public void testRemoveClassAsTypeArgument() throws Exception { - runTest("compiler/testData/klibABI/removeClassAsTypeArgument/"); - } - - @TestMetadata("removeClassAsVariableType") - public void testRemoveClassAsVariableType() throws Exception { - runTest("compiler/testData/klibABI/removeClassAsVariableType/"); - } - - @TestMetadata("removeFunction") - public void testRemoveFunction() throws Exception { - runTest("compiler/testData/klibABI/removeFunction/"); - } - - @TestMetadata("removeInlinedClass") - public void testRemoveInlinedClass() throws Exception { - runTest("compiler/testData/klibABI/removeInlinedClass/"); - } - - @TestMetadata("removeInlinedFunction") - public void testRemoveInlinedFunction() throws Exception { - runTest("compiler/testData/klibABI/removeInlinedFunction/"); - } - - @TestMetadata("removeInlinedProperty") - public void testRemoveInlinedProperty() throws Exception { - runTest("compiler/testData/klibABI/removeInlinedProperty/"); - } - - @TestMetadata("removeOpenFunction") - public void testRemoveOpenFunction() throws Exception { - runTest("compiler/testData/klibABI/removeOpenFunction/"); - } - - @TestMetadata("removeOpenProperty") - public void testRemoveOpenProperty() throws Exception { - runTest("compiler/testData/klibABI/removeOpenProperty/"); - } - - @TestMetadata("removeProperty") - public void testRemoveProperty() throws Exception { - runTest("compiler/testData/klibABI/removeProperty/"); + @TestMetadata("removeSealedSubclass") + public void testRemoveSealedSubclass() throws Exception { + runTest("compiler/testData/klibABI/removeSealedSubclass/"); } @TestMetadata("replaceCallableReturnType") @@ -155,8 +125,8 @@ public class JsKLibABINoICTestCaseGenerated extends AbstractJsKLibABINoICTestCas runTest("compiler/testData/klibABI/replaceCallableReturnType/"); } - @TestMetadata("typeAliasRHSTypeChange") - public void testTypeAliasRHSTypeChange() throws Exception { - runTest("compiler/testData/klibABI/typeAliasRHSTypeChange/"); + @TestMetadata("typeAliasChanges") + public void testTypeAliasChanges() throws Exception { + runTest("compiler/testData/klibABI/typeAliasChanges/"); } } diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/JsKLibABIWithICTestCaseGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/JsKLibABIWithICTestCaseGenerated.java index 164d796556c..736dec62362 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/JsKLibABIWithICTestCaseGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/JsKLibABIWithICTestCaseGenerated.java @@ -26,10 +26,25 @@ public class JsKLibABIWithICTestCaseGenerated extends AbstractJsKLibABIWithICTes KotlinTestUtils.runTest(this::doTest, TargetBackend.JS_IR, testDataFilePath); } + @TestMetadata("addEnumEntry") + public void testAddEnumEntry() throws Exception { + runTest("compiler/testData/klibABI/addEnumEntry/"); + } + + @TestMetadata("addSealedSubclass") + public void testAddSealedSubclass() throws Exception { + runTest("compiler/testData/klibABI/addSealedSubclass/"); + } + public void testAllFilesPresentInKlibABI() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/klibABI"), Pattern.compile("^([^_](.+))$"), null, TargetBackend.JS_IR, false); } + @TestMetadata("changeClassVisibility") + public void testChangeClassVisibility() throws Exception { + runTest("compiler/testData/klibABI/changeClassVisibility/"); + } + @TestMetadata("changeFunctionVisibility") public void testChangeFunctionVisibility() throws Exception { runTest("compiler/testData/klibABI/changeFunctionVisibility/"); @@ -40,114 +55,69 @@ public class JsKLibABIWithICTestCaseGenerated extends AbstractJsKLibABIWithICTes runTest("compiler/testData/klibABI/changePropertyVisibility/"); } + @TestMetadata("classTransformations") + public void testClassTransformations() throws Exception { + runTest("compiler/testData/klibABI/classTransformations/"); + } + + @TestMetadata("functionTransformations") + public void testFunctionTransformations() throws Exception { + runTest("compiler/testData/klibABI/functionTransformations/"); + } + + @TestMetadata("inheritanceIssues") + public void testInheritanceIssues() throws Exception { + runTest("compiler/testData/klibABI/inheritanceIssues/"); + } + @TestMetadata("noNonImplementedCallableFalsePositives") public void testNoNonImplementedCallableFalsePositives() throws Exception { runTest("compiler/testData/klibABI/noNonImplementedCallableFalsePositives/"); } - @TestMetadata("nonAbstractFunctionInAbstractClassBecomesAbstract") - public void testNonAbstractFunctionInAbstractClassBecomesAbstract() throws Exception { - runTest("compiler/testData/klibABI/nonAbstractFunctionInAbstractClassBecomesAbstract/"); + @TestMetadata("nonAbstractCallableBecomesAbstract") + public void testNonAbstractCallableBecomesAbstract() throws Exception { + runTest("compiler/testData/klibABI/nonAbstractCallableBecomesAbstract/"); } - @TestMetadata("nonAbstractFunctionInInterfaceBecomesAbstract") - public void testNonAbstractFunctionInInterfaceBecomesAbstract() throws Exception { - runTest("compiler/testData/klibABI/nonAbstractFunctionInInterfaceBecomesAbstract/"); + @TestMetadata("nonExhaustivenessOfWhenClause") + public void testNonExhaustivenessOfWhenClause() throws Exception { + runTest("compiler/testData/klibABI/nonExhaustivenessOfWhenClause/"); } - @TestMetadata("nonAbstractPropertyInAbstractClassBecomesAbstract") - public void testNonAbstractPropertyInAbstractClassBecomesAbstract() throws Exception { - runTest("compiler/testData/klibABI/nonAbstractPropertyInAbstractClassBecomesAbstract/"); + @TestMetadata("propertyTransformations") + public void testPropertyTransformations() throws Exception { + runTest("compiler/testData/klibABI/propertyTransformations/"); } - @TestMetadata("nonAbstractPropertyInInterfaceBecomesAbstract") - public void testNonAbstractPropertyInInterfaceBecomesAbstract() throws Exception { - runTest("compiler/testData/klibABI/nonAbstractPropertyInInterfaceBecomesAbstract/"); + @TestMetadata("referencingUnusableDeclarations") + public void testReferencingUnusableDeclarations() throws Exception { + runTest("compiler/testData/klibABI/referencingUnusableDeclarations/"); } - @TestMetadata("removeAbstractFunctionFromAbstractClass") - public void testRemoveAbstractFunctionFromAbstractClass() throws Exception { - runTest("compiler/testData/klibABI/removeAbstractFunctionFromAbstractClass/"); + @TestMetadata("removeAbstractCallableFromAbstractClassOrInterface") + public void testRemoveAbstractCallableFromAbstractClassOrInterface() throws Exception { + runTest("compiler/testData/klibABI/removeAbstractCallableFromAbstractClassOrInterface/"); } - @TestMetadata("removeAbstractFunctionFromInterface") - public void testRemoveAbstractFunctionFromInterface() throws Exception { - runTest("compiler/testData/klibABI/removeAbstractFunctionFromInterface/"); + @TestMetadata("removeCallable") + public void testRemoveCallable() throws Exception { + runTest("compiler/testData/klibABI/removeCallable/"); } - @TestMetadata("removeAbstractPropertyFromAbstractClass") - public void testRemoveAbstractPropertyFromAbstractClass() throws Exception { - runTest("compiler/testData/klibABI/removeAbstractPropertyFromAbstractClass/"); + @TestMetadata("removeClass") + public void testRemoveClass() throws Exception { + runTest("compiler/testData/klibABI/removeClass/"); } - @TestMetadata("removeAbstractPropertyFromInterface") - public void testRemoveAbstractPropertyFromInterface() throws Exception { - runTest("compiler/testData/klibABI/removeAbstractPropertyFromInterface/"); + @TestMetadata("removeEnumEntry") + public void testRemoveEnumEntry() throws Exception { + runTest("compiler/testData/klibABI/removeEnumEntry/"); } - @TestMetadata("removeClassAsConstructorCall") - public void testRemoveClassAsConstructorCall() throws Exception { - runTest("compiler/testData/klibABI/removeClassAsConstructorCall/"); - } - - @TestMetadata("removeClassAsParameterType") - public void testRemoveClassAsParameterType() throws Exception { - runTest("compiler/testData/klibABI/removeClassAsParameterType/"); - } - - @TestMetadata("removeClassAsReturnType") - public void testRemoveClassAsReturnType() throws Exception { - runTest("compiler/testData/klibABI/removeClassAsReturnType/"); - } - - @TestMetadata("removeClassAsSuperTypeArgument") - public void testRemoveClassAsSuperTypeArgument() throws Exception { - runTest("compiler/testData/klibABI/removeClassAsSuperTypeArgument/"); - } - - @TestMetadata("removeClassAsTypeArgument") - public void testRemoveClassAsTypeArgument() throws Exception { - runTest("compiler/testData/klibABI/removeClassAsTypeArgument/"); - } - - @TestMetadata("removeClassAsVariableType") - public void testRemoveClassAsVariableType() throws Exception { - runTest("compiler/testData/klibABI/removeClassAsVariableType/"); - } - - @TestMetadata("removeFunction") - public void testRemoveFunction() throws Exception { - runTest("compiler/testData/klibABI/removeFunction/"); - } - - @TestMetadata("removeInlinedClass") - public void testRemoveInlinedClass() throws Exception { - runTest("compiler/testData/klibABI/removeInlinedClass/"); - } - - @TestMetadata("removeInlinedFunction") - public void testRemoveInlinedFunction() throws Exception { - runTest("compiler/testData/klibABI/removeInlinedFunction/"); - } - - @TestMetadata("removeInlinedProperty") - public void testRemoveInlinedProperty() throws Exception { - runTest("compiler/testData/klibABI/removeInlinedProperty/"); - } - - @TestMetadata("removeOpenFunction") - public void testRemoveOpenFunction() throws Exception { - runTest("compiler/testData/klibABI/removeOpenFunction/"); - } - - @TestMetadata("removeOpenProperty") - public void testRemoveOpenProperty() throws Exception { - runTest("compiler/testData/klibABI/removeOpenProperty/"); - } - - @TestMetadata("removeProperty") - public void testRemoveProperty() throws Exception { - runTest("compiler/testData/klibABI/removeProperty/"); + @TestMetadata("removeSealedSubclass") + public void testRemoveSealedSubclass() throws Exception { + runTest("compiler/testData/klibABI/removeSealedSubclass/"); } @TestMetadata("replaceCallableReturnType") @@ -155,8 +125,8 @@ public class JsKLibABIWithICTestCaseGenerated extends AbstractJsKLibABIWithICTes runTest("compiler/testData/klibABI/replaceCallableReturnType/"); } - @TestMetadata("typeAliasRHSTypeChange") - public void testTypeAliasRHSTypeChange() throws Exception { - runTest("compiler/testData/klibABI/typeAliasRHSTypeChange/"); + @TestMetadata("typeAliasChanges") + public void testTypeAliasChanges() throws Exception { + runTest("compiler/testData/klibABI/typeAliasChanges/"); } } diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/KlibABITestGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/KlibABITestGenerated.java index 6ce6f375dee..7441cf69cc0 100644 --- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/KlibABITestGenerated.java +++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/KlibABITestGenerated.java @@ -19,11 +19,29 @@ import java.util.regex.Pattern; @TestMetadata("compiler/testData/klibABI") @TestDataPath("$PROJECT_ROOT") public class KlibABITestGenerated extends AbstractNativeKlibABITest { + @Test + @TestMetadata("addEnumEntry") + public void testAddEnumEntry() throws Exception { + runTest("compiler/testData/klibABI/addEnumEntry/"); + } + + @Test + @TestMetadata("addSealedSubclass") + public void testAddSealedSubclass() throws Exception { + runTest("compiler/testData/klibABI/addSealedSubclass/"); + } + @Test public void testAllFilesPresentInKlibABI() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/klibABI"), Pattern.compile("^([^_](.+))$"), null, false); } + @Test + @TestMetadata("changeClassVisibility") + public void testChangeClassVisibility() throws Exception { + runTest("compiler/testData/klibABI/changeClassVisibility/"); + } + @Test @TestMetadata("changeFunctionVisibility") public void testChangeFunctionVisibility() throws Exception { @@ -36,6 +54,24 @@ public class KlibABITestGenerated extends AbstractNativeKlibABITest { runTest("compiler/testData/klibABI/changePropertyVisibility/"); } + @Test + @TestMetadata("classTransformations") + public void testClassTransformations() throws Exception { + runTest("compiler/testData/klibABI/classTransformations/"); + } + + @Test + @TestMetadata("functionTransformations") + public void testFunctionTransformations() throws Exception { + runTest("compiler/testData/klibABI/functionTransformations/"); + } + + @Test + @TestMetadata("inheritanceIssues") + public void testInheritanceIssues() throws Exception { + runTest("compiler/testData/klibABI/inheritanceIssues/"); + } + @Test @TestMetadata("noNonImplementedCallableFalsePositives") public void testNoNonImplementedCallableFalsePositives() throws Exception { @@ -43,129 +79,57 @@ public class KlibABITestGenerated extends AbstractNativeKlibABITest { } @Test - @TestMetadata("nonAbstractFunctionInAbstractClassBecomesAbstract") - public void testNonAbstractFunctionInAbstractClassBecomesAbstract() throws Exception { - runTest("compiler/testData/klibABI/nonAbstractFunctionInAbstractClassBecomesAbstract/"); + @TestMetadata("nonAbstractCallableBecomesAbstract") + public void testNonAbstractCallableBecomesAbstract() throws Exception { + runTest("compiler/testData/klibABI/nonAbstractCallableBecomesAbstract/"); } @Test - @TestMetadata("nonAbstractFunctionInInterfaceBecomesAbstract") - public void testNonAbstractFunctionInInterfaceBecomesAbstract() throws Exception { - runTest("compiler/testData/klibABI/nonAbstractFunctionInInterfaceBecomesAbstract/"); + @TestMetadata("nonExhaustivenessOfWhenClause") + public void testNonExhaustivenessOfWhenClause() throws Exception { + runTest("compiler/testData/klibABI/nonExhaustivenessOfWhenClause/"); } @Test - @TestMetadata("nonAbstractPropertyInAbstractClassBecomesAbstract") - public void testNonAbstractPropertyInAbstractClassBecomesAbstract() throws Exception { - runTest("compiler/testData/klibABI/nonAbstractPropertyInAbstractClassBecomesAbstract/"); + @TestMetadata("propertyTransformations") + public void testPropertyTransformations() throws Exception { + runTest("compiler/testData/klibABI/propertyTransformations/"); } @Test - @TestMetadata("nonAbstractPropertyInInterfaceBecomesAbstract") - public void testNonAbstractPropertyInInterfaceBecomesAbstract() throws Exception { - runTest("compiler/testData/klibABI/nonAbstractPropertyInInterfaceBecomesAbstract/"); + @TestMetadata("referencingUnusableDeclarations") + public void testReferencingUnusableDeclarations() throws Exception { + runTest("compiler/testData/klibABI/referencingUnusableDeclarations/"); } @Test - @TestMetadata("removeAbstractFunctionFromAbstractClass") - public void testRemoveAbstractFunctionFromAbstractClass() throws Exception { - runTest("compiler/testData/klibABI/removeAbstractFunctionFromAbstractClass/"); + @TestMetadata("removeAbstractCallableFromAbstractClassOrInterface") + public void testRemoveAbstractCallableFromAbstractClassOrInterface() throws Exception { + runTest("compiler/testData/klibABI/removeAbstractCallableFromAbstractClassOrInterface/"); } @Test - @TestMetadata("removeAbstractFunctionFromInterface") - public void testRemoveAbstractFunctionFromInterface() throws Exception { - runTest("compiler/testData/klibABI/removeAbstractFunctionFromInterface/"); + @TestMetadata("removeCallable") + public void testRemoveCallable() throws Exception { + runTest("compiler/testData/klibABI/removeCallable/"); } @Test - @TestMetadata("removeAbstractPropertyFromAbstractClass") - public void testRemoveAbstractPropertyFromAbstractClass() throws Exception { - runTest("compiler/testData/klibABI/removeAbstractPropertyFromAbstractClass/"); + @TestMetadata("removeClass") + public void testRemoveClass() throws Exception { + runTest("compiler/testData/klibABI/removeClass/"); } @Test - @TestMetadata("removeAbstractPropertyFromInterface") - public void testRemoveAbstractPropertyFromInterface() throws Exception { - runTest("compiler/testData/klibABI/removeAbstractPropertyFromInterface/"); + @TestMetadata("removeEnumEntry") + public void testRemoveEnumEntry() throws Exception { + runTest("compiler/testData/klibABI/removeEnumEntry/"); } @Test - @TestMetadata("removeClassAsConstructorCall") - public void testRemoveClassAsConstructorCall() throws Exception { - runTest("compiler/testData/klibABI/removeClassAsConstructorCall/"); - } - - @Test - @TestMetadata("removeClassAsParameterType") - public void testRemoveClassAsParameterType() throws Exception { - runTest("compiler/testData/klibABI/removeClassAsParameterType/"); - } - - @Test - @TestMetadata("removeClassAsReturnType") - public void testRemoveClassAsReturnType() throws Exception { - runTest("compiler/testData/klibABI/removeClassAsReturnType/"); - } - - @Test - @TestMetadata("removeClassAsSuperTypeArgument") - public void testRemoveClassAsSuperTypeArgument() throws Exception { - runTest("compiler/testData/klibABI/removeClassAsSuperTypeArgument/"); - } - - @Test - @TestMetadata("removeClassAsTypeArgument") - public void testRemoveClassAsTypeArgument() throws Exception { - runTest("compiler/testData/klibABI/removeClassAsTypeArgument/"); - } - - @Test - @TestMetadata("removeClassAsVariableType") - public void testRemoveClassAsVariableType() throws Exception { - runTest("compiler/testData/klibABI/removeClassAsVariableType/"); - } - - @Test - @TestMetadata("removeFunction") - public void testRemoveFunction() throws Exception { - runTest("compiler/testData/klibABI/removeFunction/"); - } - - @Test - @TestMetadata("removeInlinedClass") - public void testRemoveInlinedClass() throws Exception { - runTest("compiler/testData/klibABI/removeInlinedClass/"); - } - - @Test - @TestMetadata("removeInlinedFunction") - public void testRemoveInlinedFunction() throws Exception { - runTest("compiler/testData/klibABI/removeInlinedFunction/"); - } - - @Test - @TestMetadata("removeInlinedProperty") - public void testRemoveInlinedProperty() throws Exception { - runTest("compiler/testData/klibABI/removeInlinedProperty/"); - } - - @Test - @TestMetadata("removeOpenFunction") - public void testRemoveOpenFunction() throws Exception { - runTest("compiler/testData/klibABI/removeOpenFunction/"); - } - - @Test - @TestMetadata("removeOpenProperty") - public void testRemoveOpenProperty() throws Exception { - runTest("compiler/testData/klibABI/removeOpenProperty/"); - } - - @Test - @TestMetadata("removeProperty") - public void testRemoveProperty() throws Exception { - runTest("compiler/testData/klibABI/removeProperty/"); + @TestMetadata("removeSealedSubclass") + public void testRemoveSealedSubclass() throws Exception { + runTest("compiler/testData/klibABI/removeSealedSubclass/"); } @Test @@ -175,8 +139,8 @@ public class KlibABITestGenerated extends AbstractNativeKlibABITest { } @Test - @TestMetadata("typeAliasRHSTypeChange") - public void testTypeAliasRHSTypeChange() throws Exception { - runTest("compiler/testData/klibABI/typeAliasRHSTypeChange/"); + @TestMetadata("typeAliasChanges") + public void testTypeAliasChanges() throws Exception { + runTest("compiler/testData/klibABI/typeAliasChanges/"); } } diff --git a/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/AbstractNativeKlibABITest.kt b/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/AbstractNativeKlibABITest.kt index 248022b9c43..30240274e38 100644 --- a/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/AbstractNativeKlibABITest.kt +++ b/native/native.tests/tests/org/jetbrains/kotlin/konan/blackboxtest/AbstractNativeKlibABITest.kt @@ -30,6 +30,16 @@ abstract class AbstractNativeKlibABITest : AbstractNativeSimpleTest() { override val buildDir get() = this@AbstractNativeKlibABITest.buildDir override val stdlibFile get() = this@AbstractNativeKlibABITest.stdlibFile + override val testModeName = with(testRunSettings.get()) { + val cacheModeAlias = when { + staticCacheRootDir == null -> CacheMode.Alias.NO + !staticCacheRequiredForEveryLibrary -> CacheMode.Alias.STATIC_ONLY_DIST + else -> CacheMode.Alias.STATIC_EVERYWHERE + } + + "NATIVE_CACHE_${cacheModeAlias}" + } + override fun buildKlib(moduleName: String, moduleSourceDir: File, dependencies: KlibABITestUtils.Dependencies, klibFile: File) = this@AbstractNativeKlibABITest.buildKlib(moduleName, moduleSourceDir, dependencies, klibFile)