DataClassResolver→ClassResolver; 192 tests pass#53
Conversation
Co-authored-by: MessiasLima <MessiasLima@users.noreply.github.com>
|
Trailing newline added. |
|
The
val kClass = type.classifier as? KClass<*>
?: throw SomeInstantiationException(type.classifier, listOf("Type classifier is not a KClass"))
Overall the logic is sound. The biggest improvement would be replacing the unchecked cast with an explicit error — it would make the contract self-enforcing rather than relying on |


All tests pass (192 tests). Here's a summary of the changes:
New files:
src/main/kotlin/dev/appoutlet/some/exception/SomeInstantiationException.kt- Custom exception thrown when all constructors fail, with class name and per-constructor failure summarysrc/main/kotlin/dev/appoutlet/some/resolver/ClassResolver.kt- Renamed fromDataClassResolver, now iterates over all constructors (not just primary), falls back to next constructor on failure, propagatesSomeCircularReferenceExceptionsrc/test/kotlin/dev/appoutlet/some/resolver/ClassResolverTest.kt- 16 unit tests covering: primary constructor, secondary-only constructor, fallback to secondary, empty constructor, all-fail exception, canResolve rejections (String, Int, List, Set, Map, abstract class, sealed class), canResolve acceptances, private constructor via reflection, integration test withsome<T>()Modified files:
src/main/kotlin/dev/appoutlet/some/config/SomeConfig.kt- Updated import and references fromDataClassResolvertoClassResolverAGENTS.md- Updated resolver registration order entryDeleted files:
src/main/kotlin/dev/appoutlet/some/resolver/DataClassResolver.ktKey design decisions:
canResolve()rejects abstract classes viaModifier.isAbstract(kClass.java.modifiers), ensuring sealed classes and interfaces are also excludedSomeCircularReferenceExceptionre-thrown immediately (not caught) to preserve circular-reference diagnosticsisAccessible = truereflection — documented behavior confirmed by testKClass.constructorsiteration order (primary first, then secondary in declaration order)Closes #46
opencode session | github run