- if (target_tp.TypeArguments != null) {
- foreach (var targ in target_tp.TypeArguments) {
- if (!TypeSpecComparer.Override.IsEqual (source_type, targ))
- continue;
-
- return source == null ? EmptyExpression.Null : new ClassCast (source, target_type);
- }
- }
-/*
- if (target_tp.Interfaces != null) {
- foreach (TypeSpec iface in target_tp.Interfaces) {
- if (!TypeManager.IsGenericParameter (iface))
- continue;
-
- if (TypeManager.IsSubclassOf (source_type, iface))
- return source == null ? EmptyExpression.Null : new ClassCast (source, target_type, true);
- }
+ //
+ // From a type parameter U to T, provided T depends on U
+ //
+ if (target_tp.TypeArguments != null && target_tp.HasDependencyOn (source_type)) {
+ return source == null ? EmptyExpression.Null : new ClassCast (source, target_type);