diff --git a/compiler/tests/org/jetbrains/jet/resolve/constraintSystem/AbstractConstraintSystemTest.kt b/compiler/tests/org/jetbrains/jet/resolve/constraintSystem/AbstractConstraintSystemTest.kt index a1e9a57f47d..442edbb78f4 100644 --- a/compiler/tests/org/jetbrains/jet/resolve/constraintSystem/AbstractConstraintSystemTest.kt +++ b/compiler/tests/org/jetbrains/jet/resolve/constraintSystem/AbstractConstraintSystemTest.kt @@ -44,9 +44,9 @@ abstract public class AbstractConstraintSystemTest() : JetLiteFixture() { private val typeResolver: TypeResolver get() = _typeResolver!! - private var _myDeclarations: MyDeclarations? = null - private val myDeclarations: MyDeclarations - get() = _myDeclarations!! + private var _testDeclarations: ConstraintSystemTestData? = null + private val testDeclarations: ConstraintSystemTestData + get() = _testDeclarations!! override fun createEnvironment(): JetCoreEnvironment { return createEnvironmentWithMockJdk(ConfigurationKind.ALL) @@ -57,12 +57,12 @@ abstract public class AbstractConstraintSystemTest() : JetLiteFixture() { val injector = InjectorForTests(getProject(), JetTestUtils.createEmptyModule()) _typeResolver = injector.getTypeResolver()!! - _myDeclarations = analyzeDeclarations() + _testDeclarations = analyzeDeclarations() } override fun tearDown() { _typeResolver = null - _myDeclarations = null + _testDeclarations = null super.tearDown() } @@ -70,12 +70,12 @@ abstract public class AbstractConstraintSystemTest() : JetLiteFixture() { return super.getTestDataPath() + "/constraintSystem/" } - private fun analyzeDeclarations(): MyDeclarations { + private fun analyzeDeclarations(): ConstraintSystemTestData { val fileName = "declarations/declarations.kt" val psiFile = createPsiFile(null, fileName, loadFile(fileName))!! val bindingContext = JvmResolveUtil.analyzeOneFileWithJavaIntegrationAndCheckForErrors(psiFile).bindingContext - return MyDeclarations(bindingContext, getProject(), typeResolver) + return ConstraintSystemTestData(bindingContext, getProject(), typeResolver) } public fun doTest(filePath: String) { @@ -87,14 +87,14 @@ abstract public class AbstractConstraintSystemTest() : JetLiteFixture() { val typeParameterDescriptors = LinkedHashMap() val variables = parseVariables(fileText) for (variable in variables) { - typeParameterDescriptors.put(myDeclarations.getParameterDescriptor(variable), Variance.INVARIANT) + typeParameterDescriptors.put(testDeclarations.getParameterDescriptor(variable), Variance.INVARIANT) } constraintSystem.registerTypeVariables(typeParameterDescriptors) val constraints = parseConstraints(fileText) for (constraint in constraints) { - val firstType = myDeclarations.getType(constraint.firstType) - val secondType = myDeclarations.getType(constraint.secondType) + val firstType = testDeclarations.getType(constraint.firstType) + val secondType = testDeclarations.getType(constraint.secondType) val position = if (constraint.isWeak) TYPE_BOUND_POSITION.position(0) else SPECIAL.position() when (constraint.kind) { MyConstraintKind.SUBTYPE -> constraintSystem.addSubtypeConstraint(firstType, secondType, position) @@ -108,7 +108,7 @@ abstract public class AbstractConstraintSystemTest() : JetLiteFixture() { val resultingSubstitutor = constraintSystem.getResultingSubstitutor() val result = StringBuilder() append "result:\n" for ((typeParameter, variance) in typeParameterDescriptors) { - val parameterType = myDeclarations.getType(typeParameter.getName().asString()) + val parameterType = testDeclarations.getType(typeParameter.getName().asString()) val resultType = resultingSubstitutor.substitute(parameterType, variance) result append "${typeParameter.getName()}=${resultType?.let{ Renderers.RENDER_TYPE.render(it) }}\n" } diff --git a/compiler/tests/org/jetbrains/jet/resolve/constraintSystem/MyDeclarations.kt b/compiler/tests/org/jetbrains/jet/resolve/constraintSystem/ConstraintSystemTestData.kt similarity index 83% rename from compiler/tests/org/jetbrains/jet/resolve/constraintSystem/MyDeclarations.kt rename to compiler/tests/org/jetbrains/jet/resolve/constraintSystem/ConstraintSystemTestData.kt index 46f090246d8..f9dcbc4304b 100644 --- a/compiler/tests/org/jetbrains/jet/resolve/constraintSystem/MyDeclarations.kt +++ b/compiler/tests/org/jetbrains/jet/resolve/constraintSystem/ConstraintSystemTestData.kt @@ -29,7 +29,7 @@ import org.jetbrains.jet.lang.resolve.constants.IntegerValueTypeConstructor import org.jetbrains.jet.lang.types.JetTypeImpl import org.jetbrains.jet.lang.descriptors.annotations.Annotations -public class MyDeclarations( +public class ConstraintSystemTestData( context: BindingContext, private val project: Project, private val typeResolver: TypeResolver @@ -46,21 +46,13 @@ public class MyDeclarations( } private fun findFunctionByName(functions: Collection, name: String): FunctionDescriptor { - for (function in functions) { - if (function.getName().asString() == name) { - return function - } - } - throw AssertionError("Function ${name} is not declared") + return functions.firstOrNull { it.getName().asString() == name } ?: + throw AssertionError("Function ${name} is not declared") } fun getParameterDescriptor(name: String): TypeParameterDescriptor { - for (typeParameter in functionFoo.getTypeParameters()) { - if (typeParameter.getName().asString() == name) { - return typeParameter; - } - } - throw AssertionError("Unsupported type parameter name: " + name + ".") + return functionFoo.getTypeParameters().firstOrNull { it.getName().asString() == name } ?: + throw AssertionError("Unsupported type parameter name: " + name + ".") } fun getType(name: String): JetType {