Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Get rid of pervasive casts in the reflection API #8220
At the moment, reflection code is very often plagued by casts. Not those brutal and obvious asInstanceOf's, but rather the sneaky asXXX methods on symbols.
Got a method from a list of members and want to figure out its return type - do a cast. Got a class from Type.typeSymbol and want to check out its type params - do a cast. And so on, and so forth.
This has to stop.
This, by the way, is going to require us to rethink our classification of symbols within the reflection API in order to be consistent with the language we're reflecting against, not with internal implementation details of a compiler for that language. In particular, we're going to need things like FieldSymbols and TypeMemberSymbols, and maybe even dedicated symbol classes for value and type parameters.