@Beta
  public <U> void with(
    Object target,
    @DelegatesTo.Target
      Class<U> type,
    @DelegatesTo(genericTypeIndex = 0, strategy = Closure.DELEGATE_FIRST)
    @ClosureParams(SecondParam.FirstGenericType.class)
      Closure closure) {
    if (target != null && !type.isInstance(target)) {
      throw new SpockAssertionError(String.format("Expected target of 'with' block to have type '%s', but got '%s'",
          type, target.getClass().getName()));
    }
    with(target, closure);
  }
Same as {@link #with(Object, groovy.lang.Closure)}, except that it also states that
the specified target has the specified type, throwing a {@code SpockAssertionError}
otherwise. As a side effect, this may give better code completion in IDEs.

<p>Example:

<pre>
def fred = new Employee(name: "Fred", age: 42, employer: "MarsTravelUnited")
def spaceship = new Spaceship(pilot: fred)

expect:
with(spaceship.pilot, Employee) {
  name == "Fred" // shorthand for: spaceship.pilot.name == "Fred"
  age == 42
  employer == "MarsTravelUnited"
}
</pre>

@param target an implicit target for conditions and/or interactions
@param type the expected type of the target
@param closure a code block containing top-level conditions and/or interactions
@param <U> type of target
spock-core/src/main/java/spock/lang/Specification.java