显然,这不完全是我的用例,但这是 MCVE,演示了问题:
def bad = {
val in: ZLayer[Any, Any, String] = null
val layer: ZLayer[String with Int with Double, Any, Double] = null
val out: ZLayer[Any & Int, Any, Double] = in >>> layer
}
这应该有效,对吧?Intellij 同意,并说一切都是正确的......直到你点击编译。编译器说:
found : zio.ZLayer[String with Int with Double,Any,Double]
required: zio.ZLayer[String with Any with Int,Any,Double]
什么???为什么?
有趣的是,如果您将第一个更改Double
为 a String
(或者如果您调整类型则更改为其他任何内容out
),它可以正常工作:
def good = {
val in: ZLayer[Any, Any, String] = null
val layer: ZLayer[String with Int with String, Any, Double] = null
val out: ZLayer[Any & Int, Any, Double] = in >>> layer
}
有任何想法吗?我开始想,这是一个编译器错误吗?