@@ -634,21 +634,53 @@ class X {
634634 else -> null
635635 }
636636
637+ /*
638+ * This is the normal getFunctionLabel function to use. If you want
639+ * to refer to the function in its source class then
640+ * classTypeArgsIncludingOuterClasses should be null. Otherwise, it
641+ * is the list of type arguments that need to be applied to its
642+ * enclosing classes to get the instantiation that this function is
643+ * in.
644+ */
637645 fun getFunctionLabel (f : IrFunction , classTypeArgsIncludingOuterClasses : List <IrTypeArgument >? ) : String {
638646 return getFunctionLabel(f, null , classTypeArgsIncludingOuterClasses)
639647 }
640648
641- fun getFunctionLabel (f : IrFunction , parentId : Label <out DbElement >? , classTypeArgsIncludingOuterClasses : List <IrTypeArgument >? ) =
642- getFunctionLabel(f.parent, parentId, getFunctionShortName(f), f.valueParameters, f.returnType, f.extensionReceiverParameter, getFunctionTypeParameters(f), classTypeArgsIncludingOuterClasses)
643-
649+ /*
650+ * There are some pairs of classes (e.g. `kotlin.Throwable` and
651+ * `java.lang.Throwable`) which are really just 2 different names
652+ * for the same class. However, we extract them as separate
653+ * classes. When extracting `kotlin.Throwable`'s methods, if we
654+ * looked up the parent ID ourselves, we would get as ID for
655+ * `java.lang.Throwable`, which isn't what we want. So we have to
656+ * allow it to be passed in.
657+ */
658+ fun getFunctionLabel (f : IrFunction , maybeParentId : Label <out DbElement >? , classTypeArgsIncludingOuterClasses : List <IrTypeArgument >? ) =
659+ getFunctionLabel(f.parent, maybeParentId, getFunctionShortName(f), f.valueParameters, f.returnType, f.extensionReceiverParameter, getFunctionTypeParameters(f), classTypeArgsIncludingOuterClasses)
660+
661+ /*
662+ * This function actually generates the label for a function.
663+ * Sometimes, a function is only generated by kotlinc when writing a
664+ * class file, so there is no corresponding `IrFunction` for it.
665+ * This function therefore takes all the constituent parts of a
666+ * function instead.
667+ */
644668 fun getFunctionLabel (
669+ // The parent of the function; normally f.parent.
645670 parent : IrDeclarationParent ,
671+ // The ID of the function's parent, or null if we should work it out ourselves.
646672 maybeParentId : Label <out DbElement >? ,
673+ // The name of the function; normally f.name.asString().
647674 name : String ,
675+ // The value parameters that the functions takes; normally f.valueParameters.
648676 parameters : List <IrValueParameter >,
677+ // The return type of the function; normally f.returnType.
649678 returnType : IrType ,
679+ // The extension receiver of the function, if any; normally f.extensionReceiverParameter.
650680 extensionReceiverParameter : IrValueParameter ? ,
681+ // The type parameters of the function. This does not include type parameters of enclosing classes.
651682 functionTypeParameters : List <IrTypeParameter >,
683+ // The type arguments of enclosing classes of the function.
652684 classTypeArgsIncludingOuterClasses : List <IrTypeArgument >?
653685 ): String {
654686 val parentId = maybeParentId ? : useDeclarationParent(parent, false , classTypeArgsIncludingOuterClasses, true )
0 commit comments