@SuppressWarnings("unchecked")
  private IAnnotationDrivenExtension getOrCreateExtension(Class<? extends IAnnotationDrivenExtension> clazz) {
    if (IStatelessAnnotationDrivenExtension.class.isAssignableFrom(clazz)) {
      // we need to add the extension to the local extensions map to ensure that `visitSpec` is called for it at the end
      return localExtensions.computeIfAbsent(clazz, c -> extensionRegistry.getStatelessAnnotationDrivenExtension((Class<? extends IStatelessAnnotationDrivenExtension<?>>) c));
    }
    return localExtensions.computeIfAbsent(clazz, configurationRegistry::instantiateExtension);
  }
Runs global and local extensions for a spec.
spock-core/src/main/java/org/spockframework/runtime/ExtensionRunner.java