private void tryToMoveMemberFunction ( NameInfo nameInfo , JSModule deepestCommonModuleRef , ClassMemberFunction classMemberFunction ) { // We should only move a property across chunks if: // 1) We can move it deeper in the chunk graph, // 2) and it's a normal member function, and not a GETTER_DEF or a SETTER_DEF, // 3) and the class is available in the global scope. Var rootVar = classMemberFunction . getRootVar ( ) ; if ( rootVar == null || ! rootVar . isGlobal ( ) ) { return ; } Node definitionNode = classMemberFunction . getDefinitionNode ( ) ; // Only attempt to move normal member functions. // A getter or setter cannot be as easily defined outside of the class to which it belongs. if ( ! definitionNode . isMemberFunctionDef ( ) ) { return ; } if ( moduleGraph . dependsOn ( deepestCommonModuleRef , classMemberFunction . getModule ( ) ) ) { if ( hasUnmovableRedeclaration ( nameInfo , classMemberFunction ) ) { // If it has been redeclared on the same object, skip it. return ; } Node destinationParent = compiler . getNodeForCodeInsertion ( deepestCommonModuleRef ) ; String className = rootVar . getName ( ) ; if ( noStubFunctions ) { moveClassInstanceMethodWithoutStub ( className , definitionNode , destinationParent ) ; } else { moveClassInstanceMethodWithStub ( className , definitionNode , destinationParent ) ; } } }
If possible move a class instance member function definition to the deepest chunk common to all uses of the method .