private static void doCreateSuperForwarder(ClassNode targetNode, MethodNode forwarderMethod, ClassNode[] interfacesToGenerateForwarderFor, Map<String,ClassNode> genericsSpec) {
        Parameter[] parameters = forwarderMethod.getParameters();
        Parameter[] superForwarderParams = new Parameter[parameters.length];
        for (int i = 0; i < parameters.length; i++) {
            Parameter parameter = parameters[i];
            ClassNode originType = parameter.getOriginType();
            superForwarderParams[i] = new Parameter(correctToGenericsSpecRecurse(genericsSpec, originType), parameter.getName());
        }
        for (int i = 0; i < interfacesToGenerateForwarderFor.length; i++) {
            final ClassNode current = interfacesToGenerateForwarderFor[i];
            final ClassNode next = i < interfacesToGenerateForwarderFor.length - 1 ? interfacesToGenerateForwarderFor[i + 1] : null;
            String forwarderName = Traits.getSuperTraitMethodName(current, forwarderMethod.getName());
            if (targetNode.getDeclaredMethod(forwarderName, superForwarderParams) == null) {
                ClassNode returnType = correctToGenericsSpecRecurse(genericsSpec, forwarderMethod.getReturnType());
                Statement delegate = next == null ? createSuperFallback(forwarderMethod, returnType) : createDelegatingForwarder(forwarderMethod, next);
                MethodNode methodNode = targetNode.addMethod(forwarderName, Opcodes.ACC_PUBLIC | Opcodes.ACC_SYNTHETIC, returnType, superForwarderParams, ClassNode.EMPTY_ARRAY, delegate);
                methodNode.setGenericsTypes(forwarderMethod.getGenericsTypes());
            }
        }
    }
private static void doCreateSuperForwarder ( ClassNode targetNode , MethodNode forwarderMethod , ClassNode [ ] interfacesToGenerateForwarderFor , Map < String , ClassNode > genericsSpec ) { Parameter [ ] parameters = forwarderMethod . getParameters ( ) ; Parameter [ ] superForwarderParams = new Parameter [ parameters . length ] ; for ( int i = 0 ; i < parameters . length ; i ++ ) { Parameter parameter = parameters [ i ] ; ClassNode originType = parameter . getOriginType ( ) ; superForwarderParams [ i ] = new Parameter ( correctToGenericsSpecRecurse ( genericsSpec , originType ) , parameter . getName ( ) ) ; } for ( int i = 0 ; i < interfacesToGenerateForwarderFor . length ; i ++ ) { final ClassNode current = interfacesToGenerateForwarderFor [ i ] ; final ClassNode next = i < interfacesToGenerateForwarderFor . length - 1 ? interfacesToGenerateForwarderFor [ i + 1 ] : null ; String forwarderName = Traits . getSuperTraitMethodName ( current , forwarderMethod . getName ( ) ) ; if ( targetNode . getDeclaredMethod ( forwarderName , superForwarderParams ) == null ) { ClassNode returnType = correctToGenericsSpecRecurse ( genericsSpec , forwarderMethod . getReturnType ( ) ) ; Statement delegate = next == null ? createSuperFallback ( forwarderMethod , returnType ) : createDelegatingForwarder ( forwarderMethod , next ) ; MethodNode methodNode = targetNode . addMethod ( forwarderName , Opcodes . ACC_PUBLIC | Opcodes . ACC_SYNTHETIC , returnType , superForwarderParams , ClassNode . EMPTY_ARRAY , delegate ) ; methodNode . setGenericsTypes ( forwarderMethod . getGenericsTypes ( ) ) ; } } }
Creates a method to dispatch to "super traits" in a "stackable" fashion. The generated method looks like this:
<p>
<code>ReturnType trait$super$method(Class clazz, Arg1 arg1, Arg2 arg2, ...) {
if (SomeTrait.is(A) { return SomeOtherTrait$Trait$Helper.method(this, arg1, arg2) }
super.method(arg1,arg2)
}</code>
</p>
@param targetNode
@param forwarderMethod
@param interfacesToGenerateForwarderFor
@param genericsSpec