Skip to content

Add support for 'interface' and 'unmanaged' generic constraints#437

Open
Bazooper-blip wants to merge 2 commits into
integrated-application-development:masterfrom
Bazooper-blip:generic-constraints-interface-unmanaged
Open

Add support for 'interface' and 'unmanaged' generic constraints#437
Bazooper-blip wants to merge 2 commits into
integrated-application-development:masterfrom
Bazooper-blip:generic-constraints-interface-unmanaged

Conversation

@Bazooper-blip
Copy link
Copy Markdown

Delphi 13 introduces two new generic constraint keywords:

  • 'interface': ensures type parameter implements an interface
  • 'unmanaged': ensures type parameter is a simple value type

Adds full constraint pipeline: API interfaces, AST nodes, constraint implementations with cross-constraint compatibility, grammar rules, visitor methods, and comprehensive tests.

Closes #413, closes #414

Delphi 13 introduces two new generic constraint keywords:
- 'interface': ensures type parameter implements an interface
- 'unmanaged': ensures type parameter is a simple value type

Adds full constraint pipeline: API interfaces, AST nodes,
constraint implementations with cross-constraint compatibility,
grammar rules, visitor methods, and comprehensive tests.

Closes integrated-application-development#413, closes integrated-application-development#414

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Collaborator

@cirras cirras left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes look good on the surface but don't entirely match reality and can't be accepted without some changes.

You should test your assumptions against an actual Delphi 13 compiler.

- Make incompatible constraint pairs return VIOLATED instead of
  COMPATIBLE/SATISFIED:
  - interface vs constructor (interfaces can't be instantiated)
  - record vs unmanaged (records can hold managed fields)
  - type-constraint vs unmanaged (class hierarchy is managed)
- Rewrite UnmanagedConstraint type check:
  - Accept pointer types
  - For records, recursively verify every field is unmanaged itself
- Remove invalid constraint combinations from grammar fixture
- Update constraint tests for the new compatibility matrix
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.

Support unmanaged generic constraint Support interface generic constraint

2 participants