Repository navigation
Add support for type annotations - #3992
PiIsRational wants to merge 70 commits into
Conversation
|
I have a stupid questions:
|
Review: PR #3992 — “Add support for type annotations”
SummaryThe PR reads type annotations from Java sources, stores them in The mechanical part of the refactor is careful and consistent; everything compiles, including the test sources. The new logic in the annotation path has several correctness problems that should be fixed before merge. High severity1.
|
Intended Change
The Goal of this Pull Request is to be able to use Java Type Annotations in Taclets.
To make this work the Type Annotations were added to the KeY Ast at the
TypeReferencelevel.The annotations were added to the type references, since they correspond to the syntactical
version of the types. Since in most places
KeYJavaTypes were used, there was the needto replace them.
The default matching behaviour was not altered and is compatible with the current
master branch. This means that there is no semantic difference between
Object oand
@Rep Object o. Therefore, no taclets need to be altered and annotations are simplyignored per default.
To interact with annotations in taclets there are currently 3 variable conditions:
hasAnnotation(SchemaVariable variable, String annot):It checks that the type (
TypeReference) ofvariablehas an annotation whosefully qualified name matches
annot. It supportsProgramVariables,New(simple constuctor calls) and Fields.
addAnnotation(SchemaVariable store, SchemaVariable read, String annot):It creates a copy of
readand stores instoreexcept that the last annotationof the type of
storenow corresponds toannot. If the given stringannotdoesnot match an annotation, the variable condition fails.
It supports
ProgramVariables andNew(simple constructor calls).removeAnnotation(SchemaVariable store, SchemaVariable read, String annot):It creates a copy of
readwhere all annotations of the type ofreadwith the fully qualified name matching
annotare removed and stores it instore.This variable condition matches always and only supports
New(simple constructor calls).Currently only, Marker annotations so annotations with no arguments
(such as
@NonNullor@Rep) are supported.Example
In the context of a Nullness type system (where the
@NonNull) annotationis type checked we could have something like the following snippet:
To be able to use the guarantee expressed by the annotation we could write the following
Taclet:
A further (similar) example can be found here.
The main use of this change is PR #3724 and can be found here (mainly in
universeDefs.key).Plan
Type of pull request
Ensuring quality
Additional information and contact(s)
@WolframPfeifer is involved in this Pull Request
The contributions within this pull request are licensed under GPLv2 (only) for inclusion in KeY.