示例#1
0
 internal static bool IsValidPolymorphicCast(TypeUsage fromType, TypeUsage toType)
 {
     if (!TypeSemantics.IsPolymorphicType(fromType) || !TypeSemantics.IsPolymorphicType(toType))
     {
         return(false);
     }
     if (!TypeSemantics.IsStructurallyEqual(fromType, toType) && !TypeSemantics.IsSubTypeOf(fromType, toType))
     {
         return(TypeSemantics.IsSubTypeOf(toType, fromType));
     }
     return(true);
 }