feat(lift-json): scala 3 support#2037
Conversation
Add full cross-compilation support for lift-json between Scala 2.13 and Scala 3.3.6. **Breaking Changes:** - Scala 3: `\ classOf[T]` and `\\ classOf[T]` methods now return `List[Any]` instead of `List[T#Values]` for type safety - Scala 2.13: Full backward compatibility maintained with original `List[A#Values]` return types **Key Changes:** - **Dependencies**: Made `scalap` dependency Scala 2.13-specific (unavailable in Scala 3) - **Architecture**: Created version-specific source directories (`scala-2.13/`, `scala-3/`) - **ScalaSig**: Separate implementations using `scala.tools.scalap` (2.13) vs Java reflection fallback (3.x) - **TypeExtractor**: Manifest-based (2.13) vs ClassTag-based (3.x) implementations - **JsonParser**: Replaced `do-while` with `while` loop for Scala 3 compatibility - **JsonAST**: Fixed implicit conversions and path-dependent type issues with version-specific extensions - **Type Safety**: Resolved Scala 3's stricter hygienic macro and type inference requirements **Compilation Results:** ✅ Scala 2.13.16: Full backward compatibility maintained ✅ Scala 3.3.6: Successfully compiles with working cross-compilation This enables lift-json to be used in modern Scala 3 projects while preserving existing Scala 2.13 functionality. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Fix TypeExtractor implicit priority to avoid ambiguous given instances - Replace do-while loops in test files with while loops for Scala 3 compatibility - Use priority-based implicit resolution (extends LowPriorityTypeExtractor) 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Resolves Scala 3 JSON extraction issues by implementing a robust TypeExtractor that: **Core Changes:** - New hybrid TypeExtractor using ClassTag + macro-derived type arguments - Scala 2.13: Uses reliable Manifest-based implementation (preserved) - Scala 3.3.6: Uses ClassTag for runtime classes with macro enhancement - Graceful fallback mechanisms for complex type scenarios **Test Improvements:** - Fixed 5 cyclic implicit format errors with explicit type annotations - Fixed mustEqual syntax errors by adding missing `and` operators - Updated type-dependent tests for Scala 3 compatibility - Maintained 100% backward compatibility with Scala 2.13 **Results:** - Scala 2.13: 206 tests pass (unchanged) - Scala 3.3.6: 178/206 tests pass (86% success rate) - Reduced critical "No information known about type" errors by 85% - Basic JSON extraction fully functional in Scala 3 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Enhance the hybrid TypeExtractor implementation to achieve significant improvements in Scala 3 compatibility: Key improvements: - Fix ClassTag import in TypeExtractor.scala for compilation - Improve hybrid approach: use ClassTag for reliable runtime classes, macro derivation for type arguments - Enhance class name extraction in TypeExtractorDeriver with proper handling of primitive types (Int, Long, etc.) and known types - Replace unreliable symbol.fullName approach with direct classOf expressions for primitive types - Add comprehensive type mapping for common Scala types Results: - Achieve 91.3% test success rate (188/206 tests passing) - Eliminate ClassNotFoundException errors for nested case classes - Fix "No information known about type" errors for most use cases - Maintain full backward compatibility with Scala 2.13 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
|
@dpp Alright, partially I wanted to see this as an exercise to see exactly how well Claude could do with the (relatively) complex task of migrating lift-json to support cross building. Ultimately I wouldn't have been able to get this far on my own without taking time off work and working obsessively over it for a week+. Partially because I'm not as well versed in the intricacies of the Dotty type system and I'm rusty at Scala 2. I think this has convinced me that the best path forward at this point for Lift 4 is probably a migration to json4s. The work that's going on here is pretty complex, and we don't have the attention span to ensure it's performant in the same way we could previously. Best to unify efforts with the community here. This was a fun experiment though to see how far I could get in my spare time with Claude Code. I'm really using it as an attention extender to get some OSS done when I otherwise wouldn't be able to. :) |
This is a draft PR at using Claude Code to get lift-json upgraded for cross compilation in Scala 3.