OverloadSelector

Resolves Java/Kotlin overloading -- i.e. picks, among all public members of type named alike, the one whose formal parameters best match a given list of Prolog Term arguments -- using termToObjectConverter to score how well each candidate parameter type fits each argument (see TermToObjectConverter.priorityOfConversion).

This is what allows Prolog code such as X.println(1) and X.println("a") to reach different overloads of println on the same type without the Prolog programmer ever naming a type explicitly (see as/2, it.unibo.tuprolog.solve.libs.oop.OOP.CAST_OPERATOR, for when the automatic choice needs to be overridden).

The default (JVM) implementation selects overloads reflectively.

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

The converter used to score how well a Term argument fits a candidate parameter type.

Link copied to clipboard
abstract val type: KClass<*>

The type whose members this selector resolves overloads on.

Functions

Link copied to clipboard
abstract fun findConstructor(arguments: List<Term>): KCallable<*>

Finds the public constructor of type whose formal parameters best match arguments.

Link copied to clipboard
abstract fun findMethod(name: String, arguments: List<Term>): KCallable<*>

Finds the public method (or property getter) of type named name whose formal parameters best match arguments.

Link copied to clipboard
abstract fun findProperty(name: String, value: Term): KMutableProperty<*>

Finds the public mutable property of type named name whose setter accepts value.