KT-25907: Use proper loop parameter type in for-in-CharSequence
This commit is contained in:
+2
-2
@@ -81,8 +81,8 @@ class ForInCharSequenceLoopGenerator(
|
||||
v.load(charSequenceVar, charSequenceType)
|
||||
v.load(indexVar, Type.INT_TYPE)
|
||||
v.invokeCharSequenceMethod("charAt", "(I)C")
|
||||
StackValue.onStack(Type.CHAR_TYPE).put(asmElementType, elementType, codegen.v)
|
||||
v.store(loopParameterVar, asmElementType)
|
||||
StackValue.onStack(Type.CHAR_TYPE).put(loopParameterType, loopParameterKotlinType, codegen.v)
|
||||
v.store(loopParameterVar, loopParameterType)
|
||||
}
|
||||
|
||||
override fun checkPostConditionAndIncrement(loopExit: Label) {
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
fun box(): String {
|
||||
val str = "abcd"
|
||||
var r = ""
|
||||
for (c: Char? in str) {
|
||||
r = r + c ?: "?"
|
||||
}
|
||||
if (r != "abcd") throw AssertionError()
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+5
@@ -4605,6 +4605,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
runTest("compiler/testData/codegen/box/controlStructures/forLoopMemberExtensionNext.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("forNullableCharInString.kt")
|
||||
public void testForNullableCharInString() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/controlStructures/forNullableCharInString.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("forUserType.kt")
|
||||
public void testForUserType() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/controlStructures/forUserType.kt");
|
||||
|
||||
+5
@@ -4605,6 +4605,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/controlStructures/forLoopMemberExtensionNext.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("forNullableCharInString.kt")
|
||||
public void testForNullableCharInString() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/controlStructures/forNullableCharInString.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("forUserType.kt")
|
||||
public void testForUserType() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/controlStructures/forUserType.kt");
|
||||
|
||||
+5
@@ -4605,6 +4605,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/controlStructures/forLoopMemberExtensionNext.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("forNullableCharInString.kt")
|
||||
public void testForNullableCharInString() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/controlStructures/forNullableCharInString.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("forUserType.kt")
|
||||
public void testForUserType() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/controlStructures/forUserType.kt");
|
||||
|
||||
+5
@@ -4275,6 +4275,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/controlStructures/forLoopMemberExtensionNext.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("forNullableCharInString.kt")
|
||||
public void testForNullableCharInString() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/controlStructures/forNullableCharInString.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("forUserType.kt")
|
||||
public void testForUserType() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/controlStructures/forUserType.kt");
|
||||
|
||||
+5
@@ -4305,6 +4305,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/controlStructures/forLoopMemberExtensionNext.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("forNullableCharInString.kt")
|
||||
public void testForNullableCharInString() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/controlStructures/forNullableCharInString.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("forUserType.kt")
|
||||
public void testForUserType() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/controlStructures/forUserType.kt");
|
||||
|
||||
Reference in New Issue
Block a user