Skip to content

Support external library contracts in Latte and LiquidTypeChecking - #35

Open
alcides wants to merge 1 commit into
feat/latte-liquid-typecheckingfrom
feat/external-library-refinements
Open

alcides wants to merge 1 commit into
feat/latte-liquid-typecheckingfrom
feat/external-library-refinements

Conversation

@alcides

@alcides alcides commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator

External library specifications were previously rejected as unsupported. This change lets application code refine JDK and third-party library methods, constructors and fields through @ExternalRefinementsFor, using the same contracts in Latte and LiquidTypeChecking. For example, an ArrayList transition through a local alias is visible when checking the original variable's size.

  • Resolve and validate Java signatures, overloads, inherited members and field types in a per-model registry stored on Spoon's AST. Placeholder bodies and field initializers do not become implementation facts.
  • Apply ownership contracts to external parameters and results, including constructor parameters. Preserve shared-object rejection, borrowed mutation effects and consumption of all caller aliases on @Free transfers.
  • Check parameter/result refinements, state transitions and state sets. Include external calls and constructor effects in loop analysis, and retain conservative global and unknown-call effects.
  • Add CLI/API classpath support and analyze separate specification/application paths together. A test builds a library JAR and verifies both API and CLI use without initializing the library.
  • Add checked examples, an external-specification guide, 42 focused tests and 15 promoted upstream inputs. All 410 imported fixture sources remain unchanged.

Validation: mvn -B spotless:apply clean verify -Pcompatibility passes with 522 tests, zero failures/errors, and 180/311 exact upstream matches (previously 165), with zero analysis crashes. The compatibility gate still checks every imported input and rejects newly accepted negative cases.

Library specifications are trusted contracts. Container-size specifications do not infer element ownership or return aliases. Expanded varargs calls require explicit arrays; varargs method references require an explicit-array lambda. These boundaries are documented and unsupported adapters are diagnosed explicitly.

This PR is stacked on feat/latte-liquid-typechecking, whose completed implementation was pushed as 1eb2448. Its diff contains only external-library support and related integration fixes. CI also runs for PRs targeting that base.

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