MemberName

data class MemberName

Represents the name of a member (such as a function or a property).

Parameters

packageName

e.g. kotlin.collections

enclosingClassName

e.g. Map.Entry.Companion, if the member is declared inside the companion object of the Map.Entry class

simpleName

e.g. isBlank, size

isExtension

whether the member is an extension property or an extension function. Default is false.

If there is a member with the same name as this member in a local scope, the generated code will include this member's fully-qualified name to avoid ambiguity, e.g.:

package com.squareup.tacos

import kotlin.Unit

public class TacoTest {
public fun test(): Unit {
kotlin.error("errorText")
}

public fun error(): Unit {
}
}

However, since Kotlin compiler does not allow fully-qualified extension members, if isExtension is set to true for this MemberName, the generated code will include an import for this member and its simple name at the call site, e.g.:

package com.squareup.tacos

import kotlin.Unit
import kotlin.hashCode

public class TacoTest {
public override fun hashCode(): Unit {
var result = super.hashCode
if (result == 0) {
result = result * 37 + embedded_message.hashCode()
super.hashCode = result
}
return result
}
}

Constructors

Link copied to clipboard
fun MemberName(packageName: String, simpleName: String)
Link copied to clipboard
fun MemberName(packageName: String, simpleName: String, isExtension: Boolean)
Link copied to clipboard
fun MemberName(enclosingClassName: ClassName, simpleName: String)
Link copied to clipboard
fun MemberName(enclosingClassName: ClassName, simpleName: String, isExtension: Boolean)
Link copied to clipboard
fun MemberName(packageName: String, operator: KOperator)
Link copied to clipboard
fun MemberName(enclosingClassName: ClassName, operator: KOperator)

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
fun reference(): CodeBlock

Callable reference to this member. Emits enclosingClassName if it exists, followed by the reference operator ::, followed by either simpleName or the fully-qualified name if this is a top-level member.

Link copied to clipboard
open override fun toString(): String

Properties

Link copied to clipboard
val canonicalName: String

Fully qualified name using . as a separator, like kotlin.String.isBlank.

Link copied to clipboard
val enclosingClassName: ClassName?
Link copied to clipboard
val isExtension: Boolean = false
Link copied to clipboard
val operator: KOperator? = null
Link copied to clipboard
val packageName: String
Link copied to clipboard
val simpleName: String