Description
dotnet/coreclr#14420 will optimize sucessful ISINST(x)
orCASTCLASS(x)
to be simply x
. However the successful cast may give us "better" type information about x
than we had before, and right now we lose that information.
We attempt this type improvement for some of the unoptimized cases when the result is produced in a temp, see the last few lines of impCastClassOrIsInstToTree
. However blindly setting the type to the cast type may not always be better. For instance casting from a known class to an interface type isn't really providing much in the way of useful information.
So we should only do this sort of thing when the target type is a class, and we've cast from supertype to subtype, or from an interface to a class type.
category:cq
theme:importer
skill-level:expert
cost:small