I would like to do something like this (actually doesn't work):
class A[T <: B | C]
... and expect this to be valid:
new A[B] new A[C]
... and this will result in a compiler error:
new A[D]
Is this possible?
You can use implicits:
trait AArg[T] class A[T](implicit e: AArg[T]) implicit val argB = new AArg[B] { } implicit val argC = new AArg[C] { }
although this does not prevent anyone from creating an implicit val of type AArg[D] .
AArg[D]
Source: https://habr.com/ru/post/1204473/More articles:How to change ListView elements for animation? - androidCalling an actor on a spray track and waiting for an Actor's response - scalaPerlin Swift Noise Generator - iosHTML5 CSS3 JavaScript Project Template in Visual Studio 2013 - javascriptHow to avoid (or reduce the risk of) suo file corruption? - visual-studio-2010Why is the destructor called twice? - c ++Decide (in Haskell) if the number is or is not a palindrome without using lists - listPycharm remote debugging is combining local and remote paths - pythonWhy is the variable not defined? - javascriptError creating angular image - angularjsAll Articles