[Wasm] Fix unit issues

- Materialize unit when its value is actually needed.
- Special-case Unit_getInstance return type at codegen. It should be a
  proper Unit object instead of a "void"
This commit is contained in:
Svyatoslav Kuzmich
2021-05-24 18:06:26 +03:00
committed by TeamCityServer
parent 20ddaa9ebf
commit b79719d6f5
45 changed files with 289 additions and 141 deletions
@@ -458,6 +458,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
runTest("compiler/testData/codegen/box/arrays/kt4357.kt");
}
@TestMetadata("kt594.kt")
public void testKt594() throws Exception {
runTest("compiler/testData/codegen/box/arrays/kt594.kt");
}
@TestMetadata("kt7009.kt")
public void testKt7009() throws Exception {
runTest("compiler/testData/codegen/box/arrays/kt7009.kt");
@@ -1971,6 +1976,21 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
runTest("compiler/testData/codegen/box/casts/objectToPrimitiveWithAssertion.kt");
}
@TestMetadata("unitAsAny.kt")
public void testUnitAsAny() throws Exception {
runTest("compiler/testData/codegen/box/casts/unitAsAny.kt");
}
@TestMetadata("unitAsSafeAny.kt")
public void testUnitAsSafeAny() throws Exception {
runTest("compiler/testData/codegen/box/casts/unitAsSafeAny.kt");
}
@TestMetadata("unitNullableCast.kt")
public void testUnitNullableCast() throws Exception {
runTest("compiler/testData/codegen/box/casts/unitNullableCast.kt");
}
@TestMetadata("compiler/testData/codegen/box/casts/functions")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
@@ -2284,6 +2304,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
runTest("compiler/testData/codegen/box/classes/kt1891.kt");
}
@TestMetadata("kt1918.kt")
public void testKt1918() throws Exception {
runTest("compiler/testData/codegen/box/classes/kt1918.kt");
}
@TestMetadata("kt1976.kt")
public void testKt1976() throws Exception {
runTest("compiler/testData/codegen/box/classes/kt1976.kt");
@@ -3436,6 +3461,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
runTest("compiler/testData/codegen/box/controlStructures/kt2416.kt");
}
@TestMetadata("kt2597.kt")
public void testKt2597() throws Exception {
runTest("compiler/testData/codegen/box/controlStructures/kt2597.kt");
}
@TestMetadata("kt299.kt")
public void testKt299() throws Exception {
runTest("compiler/testData/codegen/box/controlStructures/kt299.kt");
@@ -3840,6 +3870,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
runTest("compiler/testData/codegen/box/dataClasses/twoVarParams.kt");
}
@TestMetadata("unitComponent.kt")
public void testUnitComponent() throws Exception {
runTest("compiler/testData/codegen/box/dataClasses/unitComponent.kt");
}
@TestMetadata("compiler/testData/codegen/box/dataClasses/copy")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
@@ -4035,6 +4070,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
public void testMixedParams() throws Exception {
runTest("compiler/testData/codegen/box/dataClasses/toString/mixedParams.kt");
}
@TestMetadata("unitComponent.kt")
public void testUnitComponent() throws Exception {
runTest("compiler/testData/codegen/box/dataClasses/toString/unitComponent.kt");
}
}
}
@@ -4780,6 +4820,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
runTest("compiler/testData/codegen/box/diagnostics/functions/tailRecursion/sum.kt");
}
@TestMetadata("tailCallInBlockInParentheses.kt")
public void testTailCallInBlockInParentheses() throws Exception {
runTest("compiler/testData/codegen/box/diagnostics/functions/tailRecursion/tailCallInBlockInParentheses.kt");
}
@TestMetadata("tailCallInParentheses.kt")
public void testTailCallInParentheses() throws Exception {
runTest("compiler/testData/codegen/box/diagnostics/functions/tailRecursion/tailCallInParentheses.kt");
@@ -5809,6 +5854,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
runTest("compiler/testData/codegen/box/functions/kt1649_1.kt");
}
@TestMetadata("kt1649_2.kt")
public void testKt1649_2() throws Exception {
runTest("compiler/testData/codegen/box/functions/kt1649_2.kt");
}
@TestMetadata("kt2270.kt")
public void testKt2270() throws Exception {
runTest("compiler/testData/codegen/box/functions/kt2270.kt");
@@ -5844,6 +5894,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
runTest("compiler/testData/codegen/box/functions/kt2929.kt");
}
@TestMetadata("kt3214.kt")
public void testKt3214() throws Exception {
runTest("compiler/testData/codegen/box/functions/kt3214.kt");
}
@TestMetadata("kt3313.kt")
public void testKt3313() throws Exception {
runTest("compiler/testData/codegen/box/functions/kt3313.kt");
@@ -6155,6 +6210,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
runTest("compiler/testData/codegen/box/functions/localFunctions/kt4989.kt");
}
@TestMetadata("localExtensionOnNullableParameter.kt")
public void testLocalExtensionOnNullableParameter() throws Exception {
runTest("compiler/testData/codegen/box/functions/localFunctions/localExtensionOnNullableParameter.kt");
}
@TestMetadata("localFunctionInConstructor.kt")
public void testLocalFunctionInConstructor() throws Exception {
runTest("compiler/testData/codegen/box/functions/localFunctions/localFunctionInConstructor.kt");
@@ -6578,6 +6638,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
runTest("compiler/testData/codegen/box/inference/capturedTypesSubstitutionIntoAbbreviation.kt");
}
@TestMetadata("coercionToUnitWithLastLambdaExpression.kt")
public void testCoercionToUnitWithLastLambdaExpression() throws Exception {
runTest("compiler/testData/codegen/box/inference/coercionToUnitWithLastLambdaExpression.kt");
}
@TestMetadata("earlyReturnInsideCrossinlineLambda.kt")
public void testEarlyReturnInsideCrossinlineLambda() throws Exception {
runTest("compiler/testData/codegen/box/inference/earlyReturnInsideCrossinlineLambda.kt");
@@ -6633,6 +6698,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
runTest("compiler/testData/codegen/box/inference/noCoercionToUniForNullableLambdaReturnType.kt");
}
@TestMetadata("noCoercionToUnitWithEqualityConstraintForNullableReturnType.kt")
public void testNoCoercionToUnitWithEqualityConstraintForNullableReturnType() throws Exception {
runTest("compiler/testData/codegen/box/inference/noCoercionToUnitWithEqualityConstraintForNullableReturnType.kt");
}
@TestMetadata("recursiveConstraintInsideTypeArgumentWithStarProjection.kt")
public void testRecursiveConstraintInsideTypeArgumentWithStarProjection() throws Exception {
runTest("compiler/testData/codegen/box/inference/recursiveConstraintInsideTypeArgumentWithStarProjection.kt");
@@ -6792,6 +6862,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
runTest("compiler/testData/codegen/box/inlineClasses/boxResultInlineClassOfConstructorCall.kt");
}
@TestMetadata("boxUnboxOfInlineClassForCapturedVars.kt")
public void testBoxUnboxOfInlineClassForCapturedVars() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/boxUnboxOfInlineClassForCapturedVars.kt");
}
@TestMetadata("bridgeForFunctionReturningInlineClass.kt")
public void testBridgeForFunctionReturningInlineClass() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/bridgeForFunctionReturningInlineClass.kt");
@@ -9076,6 +9151,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
runTest("compiler/testData/codegen/box/ir/hashCodeOnGenericSubstitutedWithPrimitive.kt");
}
@TestMetadata("kt25405.kt")
public void testKt25405() throws Exception {
runTest("compiler/testData/codegen/box/ir/kt25405.kt");
}
@TestMetadata("kt40083.kt")
public void testKt40083() throws Exception {
runTest("compiler/testData/codegen/box/ir/kt40083.kt");
@@ -14626,6 +14706,21 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
runTest("compiler/testData/codegen/box/secondaryConstructors/varargs.kt");
}
@TestMetadata("withNonLocalReturn.kt")
public void testWithNonLocalReturn() throws Exception {
runTest("compiler/testData/codegen/box/secondaryConstructors/withNonLocalReturn.kt");
}
@TestMetadata("withReturn.kt")
public void testWithReturn() throws Exception {
runTest("compiler/testData/codegen/box/secondaryConstructors/withReturn.kt");
}
@TestMetadata("withReturnUnit.kt")
public void testWithReturnUnit() throws Exception {
runTest("compiler/testData/codegen/box/secondaryConstructors/withReturnUnit.kt");
}
@TestMetadata("withoutPrimarySimple.kt")
public void testWithoutPrimarySimple() throws Exception {
runTest("compiler/testData/codegen/box/secondaryConstructors/withoutPrimarySimple.kt");
@@ -15955,11 +16050,36 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/unit"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true);
}
@TestMetadata("closureReturnsNullableUnit.kt")
public void testClosureReturnsNullableUnit() throws Exception {
runTest("compiler/testData/codegen/box/unit/closureReturnsNullableUnit.kt");
}
@TestMetadata("ifElse.kt")
public void testIfElse() throws Exception {
runTest("compiler/testData/codegen/box/unit/ifElse.kt");
}
@TestMetadata("kt3634.kt")
public void testKt3634() throws Exception {
runTest("compiler/testData/codegen/box/unit/kt3634.kt");
}
@TestMetadata("kt4212.kt")
public void testKt4212() throws Exception {
runTest("compiler/testData/codegen/box/unit/kt4212.kt");
}
@TestMetadata("kt4265.kt")
public void testKt4265() throws Exception {
runTest("compiler/testData/codegen/box/unit/kt4265.kt");
}
@TestMetadata("nullableUnit.kt")
public void testNullableUnit() throws Exception {
runTest("compiler/testData/codegen/box/unit/nullableUnit.kt");
}
@TestMetadata("nullableUnitInWhen1.kt")
public void testNullableUnitInWhen1() throws Exception {
runTest("compiler/testData/codegen/box/unit/nullableUnitInWhen1.kt");
@@ -15969,6 +16089,21 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
public void testNullableUnitInWhen2() throws Exception {
runTest("compiler/testData/codegen/box/unit/nullableUnitInWhen2.kt");
}
@TestMetadata("nullableUnitInWhen3.kt")
public void testNullableUnitInWhen3() throws Exception {
runTest("compiler/testData/codegen/box/unit/nullableUnitInWhen3.kt");
}
@TestMetadata("unitClassObject.kt")
public void testUnitClassObject() throws Exception {
runTest("compiler/testData/codegen/box/unit/unitClassObject.kt");
}
@TestMetadata("UnitValue.kt")
public void testUnitValue() throws Exception {
runTest("compiler/testData/codegen/box/unit/UnitValue.kt");
}
}
@TestMetadata("compiler/testData/codegen/box/unsignedTypes")
@@ -16330,6 +16465,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
runTest("compiler/testData/codegen/box/when/noElseExhaustiveStatement.kt");
}
@TestMetadata("noElseExhaustiveUnitExpected.kt")
public void testNoElseExhaustiveUnitExpected() throws Exception {
runTest("compiler/testData/codegen/box/when/noElseExhaustiveUnitExpected.kt");
}
@TestMetadata("noElseInStatement.kt")
public void testNoElseInStatement() throws Exception {
runTest("compiler/testData/codegen/box/when/noElseInStatement.kt");