scalacontext-bound

Scala nested implicit type parameters


Can you please explain the type T in this method definition? This is from gatling. I know that colon is for context bound values. here I see them nested. What is # for?

implicit def stringToExpression[T: TypeCaster: Types[NonValidable]#DoesNotContain: ClassTag](string: String): Expression[T] = string.el

Solution

  • The following method signature is translated to:

    implicit def stringToExpression(string: String)(implicit t: TyperCaster[T], nv: Types[NonValidable]#DoesNotContain[T], ct: ClassTag[T]) = string.el
    

    # in this context is a Type Projection used to refer to the inner DoesNotContain[T] class.