@@ -194,18 +194,22 @@ internal class CgCallableAccessManagerImpl(val context: CgContext) : CgCallableA
194
194
// method of the current test class can be called on its 'this' instance
195
195
currentTestClass == executable.classId && this isThisInstanceOf currentTestClass -> true
196
196
197
- // method of a class can be called on an object of this class or any of its subtypes
197
+ // method of the current test class can be called on an object of this class or any of its subtypes
198
198
this .type isSubtypeOf executable.classId -> true
199
199
200
- // We allow callers with [stubberClassId] classId to call any executable.
201
- // Example to see why: doNothing().when(entityManagerMock).persist(any()).
202
- // Here [persist()] cannot be called on [doNothing().when(entityManagerMock)],
203
- // because it requires [EntityManager] classId caller.
204
- this .type == stubberClassId -> true
200
+ // method of the current test class can be called on builtin type
201
+ this .type in builtinCallersWithoutReflection -> true
205
202
206
203
else -> false
207
204
}
208
205
206
+ // Fore some builtin types do not having [ClassId] we need to clarify
207
+ // that it is allowed to call their methods without reflection.
208
+ //
209
+ // This approach is used, for example, to render the constructions with stubs
210
+ // like `doNothing().when(entityManagerMock).persist(any())`.
211
+ private val builtinCallersWithoutReflection = setOf<ClassId >(stubberClassId)
212
+
209
213
/* *
210
214
* For Kotlin extension functions, real caller is one of the arguments in JVM method (and declaration class is omitted),
211
215
* thus we should move it from arguments to caller
0 commit comments