Skip to content

fix: make jserializer factory functions WASM-compatible#5

Open
abdalraheemKshinba wants to merge 6 commits into
erabti:mainfrom
abdalraheemKshinba:fix/wasm-function-type-compatibility
Open

fix: make jserializer factory functions WASM-compatible#5
abdalraheemKshinba wants to merge 6 commits into
erabti:mainfrom
abdalraheemKshinba:fix/wasm-function-type-compatibility

Conversation

@abdalraheemKshinba
Copy link
Copy Markdown

This fixes WASM builds by replacing bare Function factory types with typed generic function signatures, avoiding function type compatibility errors in Dart WASM.\n\nThis branch is based on the Dart 3.7/analyzer 9 migration work from abdalraheemKshinba:jserializer_library#1 / upstream #3, so it may be reviewed as a stacked follow-up to #3 if needed.

@abdalraheemKshinba
Copy link
Copy Markdown
Author

Note: this PR is stacked on top of #3 (the Dart 3.7 / analyzer 9 migration). GitHub cannot set the base of this upstream PR to abdalraheemKshinba:feat/migrate-to-dart-3.7-analyzer-9 because PR base branches must exist in the upstream repo.\n\nFor the clean minimal diff, review the fork PR: https://github.com/abdalraheemKshinba/jserializer_library/pull/1\n\nOnce #3 is merged into upstream main, this PR should show only the WASM function type compatibility fix.

@abdalraheemKshinba abdalraheemKshinba force-pushed the fix/wasm-function-type-compatibility branch 5 times, most recently from 62d1c38 to bd3b830 Compare May 19, 2026 13:26
- Update all packages to SDK >=3.7.0 <4.0.0
- Migrate to analyzer >=8.0.0 <10.0.0
- Update source_gen to >=4.0.0 <5.0.0
- Update build to >=3.0.0 <5.0.0
- Fix all breaking API changes:
  - TypeChecker.fromRuntime -> TypeChecker.fromUrl
  - Element.name returns String? (add null assertions)
  - parameters -> formalParameters
  - enclosingElement3 -> enclosingElement
  - getDisplayString(withNullability:) -> getDisplayString()
  - PropertyAccessorElement -> GetterElement
  - ParameterElement -> FormalParameterElement
  - library.definingCompilationUnit -> library.firstFragment
  - param.metadata -> param.metadata.annotations
- Add caching optimizations to generator and type resolver
- Remove tracked IDE and system files, add .gitignore
- Internal git refs point to erabti:main

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@abdalraheemKshinba abdalraheemKshinba force-pushed the fix/wasm-function-type-compatibility branch from bd3b830 to dff851e Compare May 19, 2026 14:46
Internal jserializer and merging_builder git refs now point to the
fork's migration branch instead of erabti:main, since the migration
changes haven't been merged upstream yet. Once PRs erabti#3 and erabti#5 are
merged into erabti/jserializer_library main, these refs should be
updated back to erabti:main.
@abdalraheemKshinba abdalraheemKshinba force-pushed the fix/wasm-function-type-compatibility branch from dff851e to 5cd6d24 Compare May 19, 2026 14:52
The generator code references safeLookup for safe field lookup
configuration, but the annotation class was missing this parameter.
@abdalraheemKshinba abdalraheemKshinba force-pushed the fix/wasm-function-type-compatibility branch from 5cd6d24 to 5ed771a Compare May 19, 2026 14:59
abdalraheemKshinba and others added 3 commits May 19, 2026 17:16
The caching optimization from the perf PR could miss annotated classes
from libraries loaded after stabilization. Revert to always loading
the full library list for each annotated file.
…compatibility

In WASM, calling a bare Function with generic type arguments fails at
runtime. Change typeFactory parameter from Function to dynamic Function<X>()
so the generated code uses properly typed function closures.

Changes:
- generator.dart: refer('Function') -> refer('dynamic Function<X>()')
- types_registry.dart: all (f) and (Function f) -> (dynamic Function<X>() f)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@abdalraheemKshinba abdalraheemKshinba force-pushed the fix/wasm-function-type-compatibility branch from 5ed771a to e3267d8 Compare May 19, 2026 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant