feat(compiler): add Any as a first-class type in the Wirespec language - #694
Merged
Conversation
Any was already representable in the AST (Reference.Any, produced by the
OpenAPI/Avro converters) but could not be written in Wirespec source. Add
it to the language and tooling:
- tokenize Any as a built-in type (WsAny) and parse it to Reference.Any,
supporting Any, Any?, Any[] and { Any }
- map Reference.Any to IR Type.Any instead of Type.Custom("Any"), so
emitters produce Object (Java), Any (Kotlin/Scala/Python), any
(TypeScript) and Box<dyn std::any::Any> (Rust) instead of a reference
to a non-existent Any class
- highlight Any as a keyword in the IntelliJ plugin; the LSP already
covers any SpecificType generically
- add parser coverage plus a shared CompileAnyTest fixture compiled by
all IR emitters and a Wirespec round-trip test
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Fixes the pre-existing format-check failure in the avro integration module that blocks CI. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
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.



What
Anywas already representable in the AST (Reference.Any, produced by the OpenAPI/Avro converters) but could not be written in Wirespec source. This PR makesAnya first-class type in the language, with IDE support.Changes
Language (compiler core)
Anyas a built-in type (WsAny : SpecificType), alongsideString,Integer,Unit, …Reference.Any, supportingAny,Any?,Any[]and{ Any }IR converter fix
Reference.Anynow maps to IRType.Anyinstead ofType.Custom("Any"), which would have emitted a reference to a non-existentAnyclass in Java/TypeScript. Emitted types per target:Object(Java),Any(Kotlin/Scala/Python),any(TypeScript),Box<dyn std::any::Any>(Rust). No existing fixtures changed.IDE
ANYelement type, lexer mapping, and keyword highlightingSpecificTypegenericallyTests
Any,Any?,Any[]inParseTypeTestCompileAnyTestfixture wired into the fixture updater, with generated fixtures and tests in all six IR emitters (Java, Kotlin, Python, Rust, Scala, TypeScript)Anyre-emits asAnyNotes
Type.Anymapping (Box<dyn Any>inside#[derive(Clone, PartialEq, …)]structs) likely won't compile as real Rust; that mapping predates this PR and may deserve a follow-up.🤖 Generated with Claude Code