private StackTraceElement prettyPrintClosureInvocation(StackTraceElement elem, Matcher matcher) {
    String classContainingClosureDef = matcher.group(1);
    String methodContainingClosureDef = matcher.group(2);
    String consecutiveNumberOfClosureDef = matcher.group(3);

    // Compensate for Groovy 2.4+'s mangling of closure class names, which turns `$spock_` into `_spock_`
    String unmangledName = "$" + methodContainingClosureDef.substring(1);
    if (InternalIdentifiers.isInternalName(unmangledName)) {
      methodContainingClosureDef = unmangledName;
    }

    String prettyClassName = classContainingClosureDef;
    String prettyMethodName =
        mapper.toFeatureName(methodContainingClosureDef) + "_closure" + consecutiveNumberOfClosureDef;

    return new StackTraceElement(prettyClassName, prettyMethodName, elem.getFileName(), elem.getLineNumber());
  }
Filters an exception's stack trace. Removes internal Groovy and Spock methods, and
restores the original names of feature methods (as specified in source code).
Stack trace elements below a feature/fixture method invocation are truncated.

@author Peter Niederwieser
spock-core/src/main/java/org/spockframework/runtime/StackTraceFilter.java