File tree Expand file tree Collapse file tree
Assets/Editor Toolbox/Editor/Utilities Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -164,14 +164,14 @@ public static List<Type> FindTypes(TypeConstraintContext constraint)
164164 {
165165 List < Type > typesList ;
166166 var parentType = constraint . TargetType ;
167- //NOTE: if parent type is generic and has non-generic arguments then we can try to create derived generic types with the same generic constraints
167+ //NOTE: if parent type is generic and has non-generic arguments then we can try to create derived generic types with the same constraints
168168 if ( CanBeSourceForGenericTypes ( parentType ) )
169169 {
170170 var parentGenericType = parentType . GetGenericTypeDefinition ( ) ;
171171 var parentGenericArgs = parentGenericType . GetGenericArguments ( ) ;
172172 typesList = GetDerivedTypes ( parentGenericType , ( sourceType ) =>
173173 {
174- var targetType = sourceType ;
174+ Type targetType ;
175175 //NOTE: type is a generic definition, it means we can check if constraints are matched
176176 if ( sourceType . IsGenericTypeDefinition )
177177 {
@@ -187,10 +187,14 @@ public static List<Type> FindTypes(TypeConstraintContext constraint)
187187 }
188188 catch ( ArgumentException )
189189 {
190- //NOTE: that's the easiest way to check if all generic constraints are ok
190+ //NOTE: unfortunately, this is the easiest way to check if all generic constraints are ok
191191 return null ;
192192 }
193193 }
194+ else
195+ {
196+ targetType = sourceType ;
197+ }
194198
195199 //NOTE: we need to check inheritance since all processed types are derived from the generic type definition
196200 if ( ! IsTypeAssignableFrom ( parentType , targetType ) )
You can’t perform that action at this time.
0 commit comments