reflectType
does not check type parameter bounds
#59862
Labels
area-vm
Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends.
closed-not-planned
Closed as we don't intend to take action on the reported issue
library-mirrors
type-bug
Incorrect behavior (everything from a crash to more subtle misbehavior)
You can invoke
reflectType
with a type argument that is not a valid bound, creating a reflection of a mal-bounded type.If you do so, you can also invoke
newInstance
to create an instance of that invalid type.Example:
The first, non-F-bounded, example succeeds in assigning a
String
to a variable of typenum
, breaking soundness.The second part crashes with a segmentation fault in the
F
constructor, suggesting that it tries to do something with the type argument, maybe assuming it to implementF
or at least have a type variable, but it then fails horribly when it findsint
. (If I changeint
toList<int>
and42
to<int>[42]
the code runs and printsList<int>
, so the crash is probably related to not being a generic type).The text was updated successfully, but these errors were encountered: