File tree Expand file tree Collapse file tree 3 files changed +6
-18
lines changed
utbot-framework/src/main/kotlin/org/utbot Expand file tree Collapse file tree 3 files changed +6
-18
lines changed Original file line number Diff line number Diff line change @@ -2336,12 +2336,8 @@ class Traverser(
2336
2336
* See more detailed documentation in [ApplicationContext] mentioned methods.
2337
2337
*/
2338
2338
private fun checkAndMarkLibraryFieldSpeculativelyNotNull (field : SootField , createdField : SymbolicValue ) {
2339
- if (applicationContext.avoidSpeculativeNotNullChecks(field) ||
2340
- ! applicationContext.speculativelyCannotProduceNullPointerException(field, methodUnderTest.classId)) {
2341
- return
2342
- }
2343
-
2344
- markAsSpeculativelyNotNull(createdField.addr)
2339
+ if (applicationContext.speculativelyCannotProduceNullPointerException(field, methodUnderTest.classId))
2340
+ markAsSpeculativelyNotNull(createdField.addr)
2345
2341
}
2346
2342
2347
2343
private fun createArray (pName : String , type : ArrayType ): ArrayValue {
Original file line number Diff line number Diff line change @@ -49,15 +49,6 @@ open class ApplicationContext(
49
49
*/
50
50
open fun replaceTypeIfNeeded (type : RefType ): ClassId ? = null
51
51
52
- /* *
53
- * Sets the restrictions on speculative not null
54
- * constraints in current application context.
55
- *
56
- * @see docs/SpeculativeFieldNonNullability.md for more information.
57
- */
58
- open fun avoidSpeculativeNotNullChecks (field : SootField ): Boolean =
59
- UtSettings .maximizeCoverageUsingReflection || ! field.declaringClass.isFromTrustedLibrary()
60
-
61
52
/* *
62
53
* Checks whether accessing [field] (with a method invocation or field access) speculatively
63
54
* cannot produce [NullPointerException] (according to its finality or accessibility).
@@ -67,7 +58,10 @@ open class ApplicationContext(
67
58
open fun speculativelyCannotProduceNullPointerException (
68
59
field : SootField ,
69
60
classUnderTest : ClassId ,
70
- ): Boolean = field.isFinal || ! field.isPublic
61
+ ): Boolean =
62
+ ! UtSettings .maximizeCoverageUsingReflection &&
63
+ field.declaringClass.isFromTrustedLibrary() &&
64
+ (field.isFinal || ! field.isPublic)
71
65
72
66
open fun preventsFurtherTestGeneration (): Boolean = false
73
67
Original file line number Diff line number Diff line change @@ -123,8 +123,6 @@ class SpringApplicationContext(
123
123
null
124
124
}
125
125
126
- override fun avoidSpeculativeNotNullChecks (field : SootField ): Boolean = false
127
-
128
126
/* *
129
127
* In Spring applications we can mark as speculatively not null
130
128
* fields if they are mocked and injecting into class under test so on.
You can’t perform that action at this time.
0 commit comments