E043: Unreducible Application

This error is emitted when an abstract type constructor (higher-kinded type) is applied to wildcard type arguments.

Such applications are equivalent to existential types, which are not supported in Scala 3. An abstract type constructor cannot be applied to wildcard arguments because the compiler cannot determine what concrete type would result.


Example

trait Container[F[_]]:
  def create: F[?]

Error

-- [E043] Type Error: example.scala:2:14 ---------------------------------------
2 |  def create: F[?]
  |              ^^^^
  |     unreducible application of higher-kinded type F to wildcard arguments
  |-----------------------------------------------------------------------------
  | Explanation (enabled by `-explain`)
  |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  | An abstract type constructor cannot be applied to wildcard arguments.
  | Such applications are equivalent to existential types, which are not
  | supported in Scala 3.
   -----------------------------------------------------------------------------

Solution

// Use a concrete type argument
trait Container[F[_]]:
  def create[A]: F[A]
// Or use a type member
trait Container[F[_]]:
  type Element
  def create: F[Element]
// Or make the type concrete in implementations
trait Container[F[_]]:
  def create: F[Int]