Skip to content

Commit 9f2520d

Browse files
committed
Minor refactor changes
1 parent 438ff7f commit 9f2520d

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

Assets/Editor Toolbox/Editor/Utilities/TypeUtility.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff 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))

0 commit comments

Comments
 (0)