All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.nhaarman.mockito_kotlin.createinstance.NullCaster.kt Maven / Gradle / Ivy

The newest version!
package com.nhaarman.mockito_kotlin.createinstance

import kotlin.reflect.KClass

/**
 * Uses a quirk in the bytecode generated by Kotlin
 * to cast [null] to a non-null type.
 *
 * See https://youtrack.jetbrains.com/issue/KT-8135.
 */
internal class NullCaster : NonNullProvider {

    override fun  createInstance(kClass: KClass): T {
        return castNull()
    }

    private fun  castNull(): T = null as T
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy