[dnm] Prototype for ofType and ofGeneric TypeMarkers - #3034
Closed
atrocities wants to merge 1 commit into
Closed
Conversation
Generate changelog in
|
Author
|
Closing in favor of #3035 |
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.
Generated Conjure code creates anon TypeMarker subclasses liberally. This is done in order to capture generic type information for parameterized classes. Since type erasure prevents directly passing in generic type information as a constructor argument for TypeMarker, the full paramaterized type must come from a subtype, and obtained with getGenericSuperclass().
As far as I can tell, the anon TypeMarker subclasses are also generated for non-paramaterized types for the sake of uniformity.
The major drawback is that these TypeMarker classes pollute the class space, and end up consuming material amounts of metaspace.
Introduce an ofGeneric factory for TypeMarker that accepts the generic type arguments for the paramaterized type as a list, and use the of factory method for TypeMarkers that encapsulate non-paramaterized types. It is, however, not actually typesafe at compile time.