E213: Pointless Applied Constructor Type
This warning is emitted when using an applied constructor type that has no effect because the resulting type is the same as the base class type.
Applied constructor types are an experimental feature that allows you to express more precise types by including constructor arguments in the type itself. However, the feature only provides benefit when the tracked parameter's type can be refined to a more specific singleton or dependent type.
If the tracked parameter's type is a regular type like List[T] or String, applying constructor arguments won't produce a more precise type than the class itself.
Example
import scala.language.experimental.modularity
class Container[T](tracked val items: List[T])
def example =
val c: Container[Int](List(1,2,3)) = Container[Int](List(1,2,3))
c
Error
-- [E213] Type Warning: example.scala:6:9 --------------------------------------
6 | val c: Container[Int](List(1,2,3)) = Container[Int](List(1,2,3))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|Applied constructor type Container[Int](List(1, 2, 3)) has no effect.
|The resulting type of Container[Int](List(1, 2, 3)) is the same as its base type, namely: Container[Int]
|-----------------------------------------------------------------------------
| Explanation (enabled by `-explain`)
|- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| Applied constructor types are used to ascribe specialized types of constructor applications.
| To benefit from this feature, the constructor in question has to have a more specific type than the class itself.
|
| If you want to track a precise type of any of the class parameters, make sure to mark the parameter as `tracked`.
| Otherwise, you can safely remove the argument list from the type.
-----------------------------------------------------------------------------
Solution
Remove the applied constructor type syntax since it provides no benefit:
import scala.language.experimental.modularity
class Container[T](tracked val items: List[T])
def example =
val c: Container[Int] = Container[Int](List(1,2,3))
c
Alternatively, if you need precise type tracking, use a parameter type that can be refined (like singleton types):
import scala.language.experimental.modularity
class Box(tracked val value: Int)
def example =
val box: Box(42) = Box(42)
box