Ignore sources which are not LOADs in refinedIntTypeAnalysis
#KT-33414 Fixed
This commit is contained in:
+8
-17
@@ -1,17 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2016 JetBrains s.r.o.
|
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
*
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jetbrains.kotlin.codegen.coroutines
|
package org.jetbrains.kotlin.codegen.coroutines
|
||||||
@@ -47,14 +36,16 @@ internal fun performRefinedTypeAnalysis(methodNode: MethodNode, thisName: String
|
|||||||
if (value == null) return
|
if (value == null) return
|
||||||
if (expectedType.sort !in REFINED_INT_SORTS) return
|
if (expectedType.sort !in REFINED_INT_SORTS) return
|
||||||
|
|
||||||
value.insns.forEach {
|
for (insn in value.insns) {
|
||||||
val index = insnList.indexOf(it)
|
// If source is something like ICONST_0, ignore it
|
||||||
|
if (!insn.isIntLoad()) continue
|
||||||
|
val index = insnList.indexOf(insn)
|
||||||
|
|
||||||
checkUpdatedExpectedType(expectedTypeAndSourcesByInsnIndex[index]?.first, expectedType)
|
checkUpdatedExpectedType(expectedTypeAndSourcesByInsnIndex[index]?.first, expectedType)
|
||||||
|
|
||||||
expectedTypeAndSourcesByInsnIndex[index] =
|
expectedTypeAndSourcesByInsnIndex[index] =
|
||||||
Pair(expectedType,
|
Pair(expectedType,
|
||||||
expectedTypeAndSourcesByInsnIndex[index]?.second.orEmpty() + value)
|
expectedTypeAndSourcesByInsnIndex[index]?.second.orEmpty() + value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+34
@@ -0,0 +1,34 @@
|
|||||||
|
// IGNORE_BACKEND: JVM_IR
|
||||||
|
// WITH_RUNTIME
|
||||||
|
// FULL_JDK
|
||||||
|
|
||||||
|
import java.nio.ByteBuffer
|
||||||
|
|
||||||
|
class Test {
|
||||||
|
suspend fun discardSuspend(discarded0: Long, max: Long) {
|
||||||
|
while (isClosedForRead) {
|
||||||
|
// this assignment is required
|
||||||
|
val rc = reading {
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!readSuspend(1)) break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private inline fun reading(block: () -> Boolean): Boolean {
|
||||||
|
setupStateForRead() ?: return false
|
||||||
|
try {
|
||||||
|
return block()
|
||||||
|
} finally {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val isClosedForRead = false
|
||||||
|
|
||||||
|
private suspend fun readSuspend(size: Int): Boolean = true
|
||||||
|
private fun setupStateForRead(): Any? = null
|
||||||
|
}
|
||||||
|
|
||||||
|
fun box() = "OK"
|
||||||
+5
@@ -8524,6 +8524,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
public void testNullSpilling_1_3() throws Exception {
|
public void testNullSpilling_1_3() throws Exception {
|
||||||
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/varSpilling/nullSpilling.kt", "kotlin.coroutines");
|
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/varSpilling/nullSpilling.kt", "kotlin.coroutines");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("refinedIntTypesAnalysis.kt")
|
||||||
|
public void testRefinedIntTypesAnalysis() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/coroutines/varSpilling/refinedIntTypesAnalysis.kt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
@@ -8524,6 +8524,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
|||||||
public void testNullSpilling_1_3() throws Exception {
|
public void testNullSpilling_1_3() throws Exception {
|
||||||
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/varSpilling/nullSpilling.kt", "kotlin.coroutines");
|
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/varSpilling/nullSpilling.kt", "kotlin.coroutines");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("refinedIntTypesAnalysis.kt")
|
||||||
|
public void testRefinedIntTypesAnalysis() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/coroutines/varSpilling/refinedIntTypesAnalysis.kt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
@@ -7409,6 +7409,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
|||||||
public void testNullSpilling_1_3() throws Exception {
|
public void testNullSpilling_1_3() throws Exception {
|
||||||
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/varSpilling/nullSpilling.kt", "kotlin.coroutines");
|
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/varSpilling/nullSpilling.kt", "kotlin.coroutines");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("refinedIntTypesAnalysis.kt")
|
||||||
|
public void testRefinedIntTypesAnalysis() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/coroutines/varSpilling/refinedIntTypesAnalysis.kt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Generated
+5
@@ -6309,6 +6309,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
|||||||
public void testNullSpilling_1_3() throws Exception {
|
public void testNullSpilling_1_3() throws Exception {
|
||||||
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/varSpilling/nullSpilling.kt", "kotlin.coroutines");
|
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/varSpilling/nullSpilling.kt", "kotlin.coroutines");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("refinedIntTypesAnalysis.kt")
|
||||||
|
public void testRefinedIntTypesAnalysis() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/coroutines/varSpilling/refinedIntTypesAnalysis.kt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
@@ -7394,6 +7394,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
|||||||
public void testNullSpilling_1_3() throws Exception {
|
public void testNullSpilling_1_3() throws Exception {
|
||||||
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/varSpilling/nullSpilling.kt", "kotlin.coroutines");
|
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/varSpilling/nullSpilling.kt", "kotlin.coroutines");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("refinedIntTypesAnalysis.kt")
|
||||||
|
public void testRefinedIntTypesAnalysis() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/coroutines/varSpilling/refinedIntTypesAnalysis.kt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user