Repository navigation
Make read-only sequences of verifications generic - #852
Merged
Merged
Conversation
We make the read-only ``Sequence[...]`` arguments of the verification functions generic if their items are instances of a class with descendants. This way, the sequences of the descendants can be passed without a copy, as aas-core-meta V3.2 does, *e.g.*, in ``ID_shorts_are_unique(self.submodel_elements)``. Go declares a type parameter, *e.g.*, ``func IDShortsAreUnique[ ReferablesT ourtypes.IReferable](referables []ReferablesT)``, C++ a template defined in the header, C# the covariant ``IReadOnlyList<T>``, and Java the wildcard ``List<? extends T>``. Python and TypeScript accept the sequences of the descendants already. The methods stay invariant, since Go methods can not have type parameters and C++ virtual methods can not be templates, and so do the mutable ``List[...]`` arguments. The type inference now checks the items of all the list arguments, and restricts the usages of the generic sequences, *e.g.*, they can not be passed to a method. We support ``in`` on the generic sequences with the new ``ourcommon.SliceContainsInstance`` in Go, and the immutable aliases, *e.g.*, ``alias: Final[Sequence[Item]] = items``, which C# and Java now declare with ``var``. We test all this in the new common meta-model ``variance_of_containers``.
Coverage Report for CI Build 38812987249Coverage increased (+0.04%) to 90.188%Details
Uncovered ChangesNo uncovered changes found. Coverage Regressions690 previously-covered lines in 10 files lost coverage.
Coverage Stats
💛 - Coveralls |
1 of 5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
We make the read-only
Sequence[...]arguments of the verification functions generic if their items are instances of a class with descendants. This way, the sequences of the descendants can be passed without a copy, as aas-core-meta V3.2 does, e.g., inID_shorts_are_unique(self.submodel_elements).Go declares a type parameter, e.g.,
func IDShortsAreUnique[ ReferablesT ourtypes.IReferable](referables []ReferablesT), C++ a template defined in the header, C# the covariantIReadOnlyList<T>, and Java the wildcardList<? extends T>. Python and TypeScript accept the sequences of the descendants already.The methods stay invariant, since Go methods can not have type parameters and C++ virtual methods can not be templates, and so do the mutable
List[...]arguments. The type inference now checks the items of all the list arguments, and restricts the usages of the generic sequences, e.g., they can not be passed to a method.We support
inon the generic sequences with the newourcommon.SliceContainsInstancein Go, and the immutable aliases, e.g.,alias: Final[Sequence[Item]] = items, which C# and Java now declare withvar.We test all this in the new common meta-model
variance_of_containers.