Open
Conversation
Research how Spock transforms spec fields (instance, @shared, final) and document the findings as a design record to guide Spockk's implementation of field handling for lifecycle methods. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add comprehensive compilation tests that validate field transformations according to Spock's field handling design: - Instance var/val fields with initializer movement - Instance lateinit var fields without initialization - Shared var/val fields with renaming and accessor generation - Shared lateinit var fields with accessors - Static fields (should remain untransformed) - Multiple fields with preserved declaration order - Field reference replacement in features Tests are marked with @PendingFeature as field handling is not yet implemented. These tests serve as the specification for the upcoming implementation. Related to #159 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Add runtime tests that validate field handling behavior using JUnit Platform's EngineTestKit: - Shared field access from subclass - Shared fields with dollar-prefixed names ($unshared, $shared) - Shared field getter/setter type compatibility with interfaces - Shared fields reset between spec runs - Static fields persist between spec runs Tests are organized with: - Test files in flat runtime package - Test fixture samples in fields/smoke subpackages Two tests marked @PendingFeature as they require field transformation implementation. Three tests pass with current behavior. Related to #159 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Add smoke test that validates shared fields with different visibility modifiers (private, protected, public, internal) are accessible from derived classes. The test uses an abstract base class with 4 shared fields and 4 feature methods that access them. The derived class simply inherits, and features run in the derived class context to verify inherited shared field access works correctly. This is a natural end-to-end test written in Spockk syntax. Related to #159 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
… claude/kotlin-field-transformations-mT0OD
…formations Add FieldRewriter that transforms spec fields following Spock conventions: - Instance var fields: make private, move initializer to $spock_initializeFields - Instance val fields: rename with $spock_finalField_ prefix, make mutable, generate explicit getter delegating to DEFAULT property accessor - Shared fields: rename with $spock_sharedField_ prefix, make protected volatile, route getter/setter through specificationContext.sharedInstance via irAs cast - Add @FieldMetadata annotations to all fields - Replace field references in feature methods with getter/setter calls Also updates SpockkTransformationContextCollector, InternalIdentifiers, and SpecRewriter to support field context collection and rewriting. Work in progress: instance field tests pass, shared field expected files still need updates for correct IR matching. https://claude.ai/code/session_01EgHR3wxhDRu61RuDX1RBhU
… behavior - Fix shared field getter/setter to use GET_FIELD/SET_FIELD for override fields to avoid infinite recursion when the getter/setter body is updated to route through specificationContext.sharedInstance - Fix backing field visibility: Kotlin backing fields are always private even for protected properties - Add IrStatementOrigin.GET_PROPERTY and IMPLICIT_ARGUMENT origins to irGetSharedInstance() to match Kotlin-generated IR - Cast specificationContext to SpecificationContext (concrete class) before calling getSharedInstance() since it's not on ISpecificationContext - Add registerParentSharedFields() to handle subclass access to parent shared fields by mapping fake override getter/setter symbols - Always create FieldRewriter for spec classes (even with no fields) so parent shared field references in subclass features are replaced - Fix createValFieldSetter to inherit property visibility instead of hardcoded PRIVATE - Remove setSharedField from MultipleFields expected file (source is val) - Remove @PendingFeature from shared fields reset test (now passing) - Update expected transformation files with correct annotations, declaration order, and cast syntax https://claude.ai/code/session_01EgHR3wxhDRu61RuDX1RBhU
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.