Random-order variable sets are no more in use in CFG #KT-13990 Fixed
(cherry picked from commit fc89385)
This commit is contained in:
committed by
Mikhail Glukhikh
parent
b3803d6fe7
commit
68f0953b02
@@ -17,7 +17,6 @@
|
||||
package org.jetbrains.kotlin.cfg
|
||||
|
||||
import com.google.common.collect.Maps
|
||||
import com.google.common.collect.Sets
|
||||
import org.jetbrains.kotlin.cfg.pseudocode.Pseudocode
|
||||
import org.jetbrains.kotlin.cfg.pseudocode.PseudocodeUtil
|
||||
import org.jetbrains.kotlin.cfg.pseudocode.instructions.Instruction
|
||||
@@ -25,15 +24,10 @@ import org.jetbrains.kotlin.cfg.pseudocode.instructions.eval.*
|
||||
import org.jetbrains.kotlin.cfg.pseudocode.instructions.special.VariableDeclarationInstruction
|
||||
import org.jetbrains.kotlin.cfg.pseudocodeTraverser.Edges
|
||||
import org.jetbrains.kotlin.cfg.pseudocodeTraverser.TraversalOrder
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ClassKind
|
||||
import org.jetbrains.kotlin.descriptors.VariableDescriptor
|
||||
import org.jetbrains.kotlin.psi.KtProperty
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.BindingContextUtils
|
||||
import org.jetbrains.kotlin.resolve.BindingContextUtils.variableDescriptorForDeclaration
|
||||
import org.jetbrains.kotlin.resolve.calls.tower.getFakeDescriptorForObject
|
||||
import org.jetbrains.kotlin.resolve.calls.util.FakeCallableDescriptorForObject
|
||||
import java.util.Collections
|
||||
|
||||
class PseudocodeVariablesData(val pseudocode: Pseudocode, private val bindingContext: BindingContext) {
|
||||
@@ -56,7 +50,7 @@ class PseudocodeVariablesData(val pseudocode: Pseudocode, private val bindingCon
|
||||
if (!includeInsideLocalDeclarations) {
|
||||
return getUpperLevelDeclaredVariables(pseudocode)
|
||||
}
|
||||
val declaredVariables = Sets.newHashSet<VariableDescriptor>()
|
||||
val declaredVariables = linkedSetOf<VariableDescriptor>()
|
||||
declaredVariables.addAll(getUpperLevelDeclaredVariables(pseudocode))
|
||||
|
||||
for (localFunctionDeclarationInstruction in pseudocode.localDeclarations) {
|
||||
@@ -76,7 +70,7 @@ class PseudocodeVariablesData(val pseudocode: Pseudocode, private val bindingCon
|
||||
}
|
||||
|
||||
private fun computeDeclaredVariablesForPseudocode(pseudocode: Pseudocode): Set<VariableDescriptor> {
|
||||
val declaredVariables = Sets.newHashSet<VariableDescriptor>()
|
||||
val declaredVariables = linkedSetOf<VariableDescriptor>()
|
||||
for (instruction in pseudocode.instructions) {
|
||||
if (instruction is VariableDeclarationInstruction) {
|
||||
val variableDeclarationElement = instruction.variableDeclarationElement
|
||||
@@ -217,7 +211,7 @@ class PseudocodeVariablesData(val pseudocode: Pseudocode, private val bindingCon
|
||||
incomingEdgesData: Collection<InitControlFlowInfo>
|
||||
): InitControlFlowInfo {
|
||||
if (incomingEdgesData.size == 1) return incomingEdgesData.single()
|
||||
val variablesInScope = Sets.newHashSet<VariableDescriptor>()
|
||||
val variablesInScope = linkedSetOf<VariableDescriptor>()
|
||||
for (edgeData in incomingEdgesData) {
|
||||
variablesInScope.addAll(edgeData.keys)
|
||||
}
|
||||
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
interface Context
|
||||
class Point
|
||||
|
||||
class Example {
|
||||
constructor(context: Context?)
|
||||
constructor(context: Context?, arg1: Int)
|
||||
constructor(context: Context?, arg1: Int, arg2: Int)
|
||||
constructor(context: Context?, arg1: Int, arg2: Int, arg3: Int)
|
||||
|
||||
var condition: Boolean = false
|
||||
private var index = <!DEBUG_INFO_LEAKING_THIS!>newIndex<!>(condition)
|
||||
private fun newIndex(zero: Boolean) = if (zero) 0 else 1
|
||||
|
||||
private lateinit var latePoint1: Point
|
||||
private lateinit var latePoint2: Point
|
||||
|
||||
private val point1 = Point()
|
||||
private val point2 = Point()
|
||||
private val point3 = Point()
|
||||
private val point4 = Point()
|
||||
private var nullPoint: Point? = null
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
package
|
||||
|
||||
public interface Context {
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class Example {
|
||||
public constructor Example(/*0*/ context: Context?)
|
||||
public constructor Example(/*0*/ context: Context?, /*1*/ arg1: kotlin.Int)
|
||||
public constructor Example(/*0*/ context: Context?, /*1*/ arg1: kotlin.Int, /*2*/ arg2: kotlin.Int)
|
||||
public constructor Example(/*0*/ context: Context?, /*1*/ arg1: kotlin.Int, /*2*/ arg2: kotlin.Int, /*3*/ arg3: kotlin.Int)
|
||||
public final var condition: kotlin.Boolean
|
||||
private final var index: kotlin.Int
|
||||
private final lateinit var latePoint1: Point
|
||||
private final lateinit var latePoint2: Point
|
||||
private final var nullPoint: Point?
|
||||
private final val point1: Point
|
||||
private final val point2: Point
|
||||
private final val point3: Point
|
||||
private final val point4: Point
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
private final fun newIndex(/*0*/ zero: kotlin.Boolean): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class Point {
|
||||
public constructor Point()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
@@ -3213,6 +3213,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("multipleAreNull.kt")
|
||||
public void testMultipleAreNull() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/constructorConsistency/multipleAreNull.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("nobacking.kt")
|
||||
public void testNobacking() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/constructorConsistency/nobacking.kt");
|
||||
|
||||
Reference in New Issue
Block a user