Skip to content

Commit 30adfe0

Browse files
committed
Simplify some util methods checks
1 parent 5acd73d commit 30adfe0

File tree

2 files changed

+2
-11
lines changed

2 files changed

+2
-11
lines changed

utbot-framework/src/main/kotlin/org/utbot/framework/codegen/model/constructor/tree/CgCallableAccessManager.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import org.utbot.framework.codegen.model.constructor.util.CgComponents
1818
import org.utbot.framework.codegen.model.constructor.util.classCgClassId
1919
import org.utbot.framework.codegen.model.constructor.util.getAmbiguousOverloadsOf
2020
import org.utbot.framework.codegen.model.constructor.util.importIfNeeded
21-
import org.utbot.framework.codegen.model.constructor.util.isTestClassUtil
2221
import org.utbot.framework.codegen.model.constructor.util.isUtil
2322
import org.utbot.framework.codegen.model.constructor.util.typeCast
2423
import org.utbot.framework.codegen.model.tree.CgAllocateArray
@@ -107,7 +106,7 @@ internal class CgCallableAccessManagerImpl(val context: CgContext) : CgCallableA
107106
}
108107

109108
private fun newMethodCall(methodId: MethodId) {
110-
if (isTestClassUtil(methodId)) requiredUtilMethods += methodId
109+
if (isUtil(methodId)) requiredUtilMethods += methodId
111110
importIfNeeded(methodId)
112111

113112
//Builtin methods does not have jClass, so [methodId.method] will crash on it,
@@ -226,7 +225,7 @@ internal class CgCallableAccessManagerImpl(val context: CgContext) : CgCallableA
226225
* @return true if a method can be called with the given arguments without reflection
227226
*/
228227
private fun MethodId.canBeCalledWith(caller: CgExpression?, args: List<CgExpression>): Boolean =
229-
(isTestClassUtil(this) || isAccessibleFrom(testClassPackageName))
228+
(isUtil(this) || isAccessibleFrom(testClassPackageName))
230229
&& caller canBeReceiverOf this
231230
&& args canBeArgsOf this
232231

utbot-framework/src/main/kotlin/org/utbot/framework/codegen/model/constructor/util/ConstructorUtils.kt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ import org.utbot.framework.plugin.api.UtNullModel
4545
import org.utbot.framework.plugin.api.UtPrimitiveModel
4646
import org.utbot.framework.plugin.api.WildcardTypeParameter
4747
import org.utbot.framework.plugin.api.util.arrayLikeName
48-
import org.utbot.framework.codegen.model.constructor.builtin.TestClassUtilMethodProvider
4948

5049
internal data class EnvironmentFieldStateCache(
5150
val thisInstance: FieldStateCache,
@@ -130,13 +129,6 @@ internal fun CgContextOwner.isUtil(method: MethodId): Boolean {
130129
return method in utilMethodProvider.utilMethodIds
131130
}
132131

133-
/**
134-
* Check if a method is an util method that is declared in the test class (not taken from the codegen utils library)
135-
*/
136-
internal fun CgContextOwner.isTestClassUtil(method: MethodId): Boolean {
137-
return utilMethodProvider is TestClassUtilMethodProvider && isUtil(method)
138-
}
139-
140132
val classCgClassId = CgClassId(Class::class.id, typeParameters = WildcardTypeParameter(), isNullable = false)
141133

142134
internal fun getStaticFieldVariableName(owner: ClassId, path: FieldPath): String {

0 commit comments

Comments
 (0)