use erased extensions to implement operatorExtension API #1295
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.
This uses erased extensions to implement the operatorExtension API. It is an alternative to #1293 and relies on ShiftLeftSecurity/overflowdb-codegen#86
I guess we should move discussion of implementation details of the erased extensions (e.g. naming bikeshedding) to ShiftLeftSecurity/overflowdb-codegen#86 and move general discussion of this approach here.
So: Are we happy with erased extensions? The idea of erased extensions is that we add an unused covariant generic type parameter to our classes, and make a type-alias
type oldClassName = newClassName[Any]. The parametric type gets erased, i.e. does not affect runtime behavior.However, it participates in scala type inference and implicit conversions. Hence we can use it for DSL-style things like the operator extensions.
Since the operator extensions are supposed to be a simple example, I compressed it down to two files (make it easier for newcomers to grok the entire package).
Note that the erased extensions cannot be runtime-checked -- i.e. there can be no runtime type errors or
x.isInstanceOf[Assignmant]checks.Generally, I see three approaches to the underlying issue with subclassing the NodeRef classes:
cc @mpollmeier @fabsx00 @ml86 and @hubertp