Skip to content

Type aliases aren't unwrapped when processing property, function, and signal registrations #773

Open
@marcopennekamp

Description

@marcopennekamp

I'm trying to define type aliases for primitives and Godot types, but I'm running into issues with registered properties/functions/signals.

Version: 0.11.0-4.3

Property Registration

I have the following type alias:

typealias SchemaId = String

I'm trying to register a property with this type:

@Export
@RegisterProperty
var schemaId: SchemaId = ""

But this leads to the following exception during compilation (from KSP):

[ksp] <path>: Registered property can only be of type primitive, core type, node type or ref counted

Expected behavior: The registration processor recognizes that the SchemaId type is actually a String type.

Function Registration

I have the following type alias:

typealias GlobalPosition = Vector2

I'm trying to register the following function:

@RegisterFunction
fun changeZone(destinationScene: PackedScene, destinationPosition: GlobalPosition) {
    // ...
}

Unfortunately, this leads to the following registration in the class's registrar:

function(MyGame::changeZone, NIL, OBJECT, GLOBALPOSITION, KtFunctionArgument(OBJECT, "godot.PackedScene", "destinationScene"), KtFunctionArgument(GLOBALPOSITION, "mygame.core.GlobalPosition", "destinationPosition"), KtFunctionArgument(NIL, "kotlin.Unit"), KtRpcConfig(RPC_MODE_DISABLED.id.toInt(), false, TRANSFER_MODE_RELIABLE.id.toInt(), 0))

The generated code cannot be compiled because GLOBALPOSITION doesn't exist.

Expected behavior: The registration processor recognizes that GlobalPosition is a Vector2 and uses this type in the registrar.

Signal Registration

Taking the same GlobalPosition type alias, I'm trying to declare the following signal:

@RegisterSignal
val changeZone by signal2<PackedScene, GlobalPosition>("destinationScene", "destinationGlobalPosition")

This results in the following registrar code:

signal(GlobalSignals::changeZone, KtFunctionArgument(OBJECT, "godot.PackedScene", "destinationScene"), KtFunctionArgument(GLOBALPOSITION, "mygame.core.GlobalPosition", "destinationGlobalPosition"))

This again fails to compile because GLOBALPOSITION doesn't exist.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions