反应堆和kotlin的零安全

反应堆和kotlin的零安全,kotlin,project-reactor,kotlin-null-safety,Kotlin,Project Reactor,Kotlin Null Safety,根据本部分文件,反应堆应支持零安全: 然而,使用map我可以轻松跳过空检查: internal class NullabilityTest { @Test fun nullability() { val userWithMap: Mono<String> = UserRepo.findUser(5) .map { it?.getName() }//this returns String?, it should not comp

根据本部分文件,反应堆应支持零安全:

然而,使用
map
我可以轻松跳过空检查:

internal class NullabilityTest {
    @Test
    fun nullability() {
        val userWithMap: Mono<String> = UserRepo.findUser(5)
            .map { it?.getName() }//this returns String?, it should not compile 
    }
}

class User {
    fun getName() = "Mike"
}

class UserRepo {
    companion object {
        fun findUser(id: Int): Mono<User?> {
            return Mono.empty()
        }
    }
}
内部类NullabilityTest{
@试验
有趣的可空性(){
val userWithMap:Mono=UserRepo.findUser(5)
.map{it?.getName()}//此返回字符串?,不应编译
}
}
类用户{
fun getName()=“Mike”
}
类UserRepo{
伴星{
有趣的findUser(id:Int):单声道{
返回Mono.empty()
}
}
}
如本例所示,
String?
被分配给
Mono
。在这种情况下,如果编译器出现故障,那就太好了。 这是反应堆中的一个bug,或者更确切地说是一些从未实现过的东西

我正在使用:
reactor 3.2.12

问题在于
map
上没有注释,而且由于它是用Java编写的,
R
是代码中的一种平台类型,因此Kotlin编译器不会抱怨:

    /**
     * Transform the item emitted by this {@link Mono} by applying a synchronous function to it.
     *
     * <p>
     * <img class="marble" src="doc-files/marbles/mapForMono.svg" alt="">
     *
     * @param mapper the synchronous transforming {@link Function}
     * @param <R> the transformed type
     *
     * @return a new {@link Mono}
     */
    public final <R> Mono<R> map(Function<? super T, ? extends R> mapper) {
        if (this instanceof Fuseable) {
            return onAssembly(new MonoMapFuseable<>(this, mapper));
        }
        return onAssembly(new MonoMap<>(this, mapper));
    }
/**
*通过对该{@link Mono}发出的项应用同步函数来转换该项。
*
*
* 
*
*@param映射器同步转换{@link函数}
*@param转换后的类型
*
*@返回一个新的{@link Mono}
*/

公共最终单声道映射(函数)所以基本上它的意思是,可空性还没有处理。Thx的信息