code: FunctionType buildAndRegister() {
      if (returnType == null) {
        provideDefaultReturnType();
        checkNotNull(returnType);
      }
  
      if (parametersNode == null) {
        throw new IllegalStateException(
            "All Function types must have params and a return type");
      }
  
      FunctionType fnType;
      if (isConstructor) {
        fnType = getOrCreateConstructor();
      } else if (isInterface) {
        fnType = getOrCreateInterface();
      } else {
        fnType =
            FunctionType.builder(typeRegistry)
                .withName(fnName)
                .withSourceNode(contents.getSourceNode())
                .withParamsNode(parametersNode)
                .withReturnType(returnType, returnTypeInferred)
                .withTypeOfThis(thisType)
                .withTemplateKeys(templateTypeNames)
                .withIsAbstract(isAbstract)
                .withClosurePrimitiveId(closurePrimitiveId)
                .build();
        maybeSetBaseType(fnType);
      }
  
      if (implementedInterfaces != null && fnType.isConstructor()) {
        fnType.setImplementedInterfaces(implementedInterfaces);
      }
  
      if (extendedInterfaces != null) {
        fnType.setExtendedInterfaces(extendedInterfaces);
      }
  
      if (isRecord) {
        fnType.setImplicitMatch(true);
      }
  
      return fnType;
    }
docs: Builds the function type, and puts it in the registry.