84669 person learning
152542 person learning
20005 person learning
5487 person learning
7821 person learning
359900 person learning
3350 person learning
180660 person learning
48569 person learning
18603 person learning
40936 person learning
1549 person learning
1183 person learning
32909 person learning
人生最曼妙的风景,竟是内心的淡定与从容!
I happened to encounter the same problem. I don’t know how you can use methods 1 and 2 correctly, the simplest method is also required
asInstanceOf[ManagedChannelBuilder[_]]
Actually
public static ManagedChannelBuilder<?> forTarget(String target) { return ManagedChannelProvider.provider().builderForTarget(target); }
What is returned is ManagedChannelBuilder[Any]. In fact, it shouldn't be Any here. But a
T extends ManagedChannelBuilder<T>
Then nameResolverFactory returns this T as Any. Then it becomes calling the build method of Any, which obviously cannot pass compilation.
I hope there is a better way~
==================================================== ==Update
Simplify the problem:
class A[T <: A[T]] { def retA: A[_] = ??? def retT: T = ??? } class B extends A[B] (new B).retA.retT
This is the original definition. If you change it to this def retA: A[_ <: A[_]] = ??? it should be fine.
def retA: A[_ <: A[_]] = ???
So, it can be like this
(new B).retA.asInstanceOf[A[_ <: A[_]]].retT.retT....
Similarly, when returning ManagedChannelBuilder<?>, ManagedChannelBuilder<?>的时候就.asInstanceOf[ManagedChannelBuilder[_ <: ManagedChannelBuilder[_]]].asInstanceOf[ManagedChannelBuilder[_ <: ManagedChannelBuilder[_]]]
ManagedChannelBuilder<?>
.asInstanceOf[ManagedChannelBuilder[_ <: ManagedChannelBuilder[_]]]
I happened to encounter the same problem.
I don’t know how you can use methods 1 and 2 correctly, the simplest method is also required
Actually
What is returned is ManagedChannelBuilder[Any]. In fact, it shouldn't be Any here. But a
Then nameResolverFactory returns this T as Any.
Then it becomes calling the build method of Any, which obviously cannot pass compilation.
I hope there is a better way~
==================================================== ==
Update
Simplify the problem:
This is the original definition. If you change it to this
def retA: A[_ <: A[_]] = ???
it should be fine.
So, it can be like this
Similarly, when returning
ManagedChannelBuilder<?>
,ManagedChannelBuilder<?>
的时候就.asInstanceOf[ManagedChannelBuilder[_ <: ManagedChannelBuilder[_]]]
.asInstanceOf[ManagedChannelBuilder[_ <: ManagedChannelBuilder[_]]]