Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

3
  • Yeah this one also makes complete sense, I tried implementing a more verbose version of the same exact method like this: def testImpl[T, U >: T : ClassTag, L <: T : ClassTag]: T = { println(classTag[L]); println(classTag[U]; null.asInstanceOf[T] }, and then delegating the implementation is test[T] method to testImpl[T, T, T]. And what I saw is that both upper bound and lower bounds of T are Nothing, so it makes sense that T is also Nothing! Commented Dec 23, 2022 at 17:09
  • I guess at least in Scala2, this problem cannot be solved, it should be handled with alternatives such as Either or something. @KamilKloch Commented Dec 23, 2022 at 17:12
  • @AminMal Well, I solved it eventually but with macros. Commented Dec 23, 2022 at 20:21