Improve handling of generic classes #12

Closed
opened 2022-12-21 15:25:23 +01:00 by Dutch · 1 comment
Owner

Currently, this loop exists in the DaoExProcessor:

var entityClassType = classDeclaration.getAllSuperTypes()
                .first { t -> t.declaration.resolveName() == classNameRoomExDao }
                .arguments.first().type!!.resolve()

            // Todo: Handling of generic classes is not a great solution at this point. Should probably create a method to recursively traverse all superclasses and check all typearguments.
            while (entityClassType.isGeneric()) {

                // Now whe know that this type is generic, so we need to go the tree further up to check its actual base type
                entityClassType = classDeclaration.getAllSuperTypes()
                    .first { t -> t.declaration.toString() == entityClassType.declaration.parent.toString() }
                    .arguments.first().type!!.resolve()
            }

Just like the TODO comment suggests, this should be a helper function, probably an extension.

Currently, this loop exists in the DaoExProcessor: ```Kotlin var entityClassType = classDeclaration.getAllSuperTypes() .first { t -> t.declaration.resolveName() == classNameRoomExDao } .arguments.first().type!!.resolve() // Todo: Handling of generic classes is not a great solution at this point. Should probably create a method to recursively traverse all superclasses and check all typearguments. while (entityClassType.isGeneric()) { // Now whe know that this type is generic, so we need to go the tree further up to check its actual base type entityClassType = classDeclaration.getAllSuperTypes() .first { t -> t.declaration.toString() == entityClassType.declaration.parent.toString() } .arguments.first().type!!.resolve() } ``` Just like the `TODO` comment suggests, this should be a helper function, probably an extension.
Dutch added this to the Release v1.0 project 2022-12-21 15:27:54 +01:00
Dutch self-assigned this 2022-12-21 15:27:57 +01:00
Dutch added this to the v1.0 milestone 2022-12-21 15:35:43 +01:00
Author
Owner

Solved in 46cb586737

Solved in 46cb58673765685ebf18d7442debf45ebb174e69
Dutch closed this issue 2023-01-02 15:13:36 +01:00
Commenting is not possible because the repository is archived.
No labels
No milestone
No project
No assignees
1 participant
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Dutch/RoomEx#12
No description provided.