Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DynamicCast Rework, Part 1: Specification #33010

Merged

Conversation

tbkka
Copy link
Contributor

@tbkka tbkka commented Jul 20, 2020

This is the proposed specification for dynamic casting, which has been under development as part of PR #29658

Splitting this out so it can be reviewed and merged separately from the implementation.

@tbkka tbkka requested a review from CodaFi July 20, 2020 21:19
docs/DynamicCasting.md Outdated Show resolved Hide resolved
docs/DynamicCasting.md Outdated Show resolved Hide resolved
docs/DynamicCasting.md Outdated Show resolved Hide resolved
docs/DynamicCasting.md Outdated Show resolved Hide resolved
docs/DynamicCasting.md Outdated Show resolved Hide resolved
docs/DynamicCasting.md Outdated Show resolved Hide resolved
@gottesmm
Copy link
Contributor

@tbkka had a thought. While this document is awesome I am worried about divergences. Really whatever behavior is specified here should have an associated test that validates this. I almost imagine that we could have a sub-folder of lit tests just for this spec. I am imagining that we would want anything that is specified to have an explicit link to the test that validates that an implementation obeys this spec.

Take it or leave it = ).

@tbkka
Copy link
Contributor Author

tbkka commented Jul 20, 2020

Really whatever behavior is specified here should have an associated test that validates this.

A test suite is in the works.

@gottesmm
Copy link
Contributor

gottesmm commented Jul 21, 2020

@tbkka nice! The dream I was imagining inline links to the individual test cases. Thanks so much for your attention to detail here! = ).

docs/DynamicCasting.md Outdated Show resolved Hide resolved
docs/DynamicCasting.md Outdated Show resolved Hide resolved
@tbkka tbkka force-pushed the tbkka/dynamicCastRework-pt1-Specification branch from 02e5922 to 6a5a8c2 Compare July 30, 2020 22:13
@tbkka
Copy link
Contributor Author

tbkka commented Aug 14, 2020

PR #33473 has a test suite to go along with this spec. The test suite is based on some stuff I've been using locally to validate work on PR #29658 but is rewritten and reorganized.

@tbkka tbkka changed the title Dynamic Casting specification DynamicCast Rework, Pt 1: Specification Aug 14, 2020
@tbkka tbkka changed the title DynamicCast Rework, Pt 1: Specification DynamicCast Rework, Part 1: Specification Aug 14, 2020
@tbkka tbkka force-pushed the tbkka/dynamicCastRework-pt1-Specification branch from 6a5a8c2 to 5ba1827 Compare August 17, 2020 15:57
@tbkka
Copy link
Contributor Author

tbkka commented Aug 17, 2020

@swift-ci Please smoke test

@tbkka tbkka merged commit 4c684d7 into swiftlang:master Aug 17, 2020
tbkka added a commit to tbkka/swift that referenced this pull request Sep 1, 2020
This validation test exercises a large matrix of types and invariants for
dynamic casting.  It's formulated as a Python script that emits a number of
Swift test programs, compiles, and executes them.  The programs are compiled in
Swift 4 and 5 mode, with -O and -Onone.

The invariants used by these tests follow the specification presented
in PR swiftlang#33010.  It should be easy to add more as desired.

I've tried to design this in such a way that CI logs can provide enough
information to narrowly identify the problem area:  Separate test cases
are generated for each invariant and each type (in particular, this helps
with compiler crashes that report the full body of the function in question).
The files and test suites are named to identify the optimization mode.

The goal of this test suite is to cover a broad cross-section of casting
capabilities and combinations, and to make it easy to expand the matrix of
combinations.  New invariants can easily be added and applied to many types;
as new types are added to this test, they can exploit the existing invariants
and be exercised across all optimization modes.
tbkka added a commit to tbkka/swift that referenced this pull request Nov 2, 2020
This validation test exercises a large matrix of types and invariants for
dynamic casting.  It's formulated as a Python script that emits a number of
Swift test programs, compiles, and executes them.  The programs are compiled in
Swift 4 and 5 mode, with -O and -Onone.

The invariants used by these tests follow the specification presented
in PR swiftlang#33010.  It should be easy to add more as desired.

I've tried to design this in such a way that CI logs can provide enough
information to narrowly identify the problem area:  Separate test cases
are generated for each invariant and each type (in particular, this helps
with compiler crashes that report the full body of the function in question).
The files and test suites are named to identify the optimization mode.

The goal of this test suite is to cover a broad cross-section of casting
capabilities and combinations, and to make it easy to expand the matrix of
combinations.  New invariants can easily be added and applied to many types;
as new types are added to this test, they can exploit the existing invariants
and be exercised across all optimization modes.
@tbkka tbkka deleted the tbkka/dynamicCastRework-pt1-Specification branch August 1, 2024 16:36
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.

5 participants