Ignore sources which are not LOADs in refinedIntTypeAnalysis

#KT-33414 Fixed
This commit is contained in:
Ilmir Usmanov
2019-08-21 19:39:01 +03:00
parent 4697822b5a
commit f9506db20a
7 changed files with 67 additions and 17 deletions
@@ -1,17 +1,6 @@
/*
* Copyright 2010-2016 JetBrains s.r.o.
*
* 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.
* 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.
*/
package org.jetbrains.kotlin.codegen.coroutines
@@ -47,14 +36,16 @@ internal fun performRefinedTypeAnalysis(methodNode: MethodNode, thisName: String
if (value == null) return
if (expectedType.sort !in REFINED_INT_SORTS) return
value.insns.forEach {
val index = insnList.indexOf(it)
for (insn in value.insns) {
// If source is something like ICONST_0, ignore it
if (!insn.isIntLoad()) continue
val index = insnList.indexOf(insn)
checkUpdatedExpectedType(expectedTypeAndSourcesByInsnIndex[index]?.first, expectedType)
expectedTypeAndSourcesByInsnIndex[index] =
Pair(expectedType,
expectedTypeAndSourcesByInsnIndex[index]?.second.orEmpty() + value)
Pair(expectedType,
expectedTypeAndSourcesByInsnIndex[index]?.second.orEmpty() + value)
}
}
@@ -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"
@@ -8524,6 +8524,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
public void testNullSpilling_1_3() throws Exception {
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");
}
}
}
@@ -8524,6 +8524,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
public void testNullSpilling_1_3() throws Exception {
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");
}
}
}
@@ -7409,6 +7409,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
public void testNullSpilling_1_3() throws Exception {
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");
}
}
}
@@ -6309,6 +6309,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
public void testNullSpilling_1_3() throws Exception {
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");
}
}
}
@@ -7394,6 +7394,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
public void testNullSpilling_1_3() throws Exception {
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");
}
}
}