Describe the bug in detail:
Trying to use .Remove on a UdonSharpBehaviour inherited class list, and get a compile error.
Provide steps/code to reproduce the bug:
Create a List of a UdonSharpBehaviour inherited class not overriding Equals method.
Then use .Remove, .Contains, or .IndexOf on that list.
Compile and error should pop up.
Expected behavior:
There should be no error.
Additional Information:
|
else if (symbol.Name == nameof(UdonSharpInternalUtility.IsUserDefinedTypeWithEquals)) |
|
{ |
|
// Return constant value based on if generic type is a user defined type with Equals |
|
TypeSymbol typeArg = symbol.TypeArguments[0]; |
|
bool isUserDefinedTypeWithEquals = typeArg.IsUdonSharpBehaviour || typeArg is ImportedUdonSharpTypeSymbol; |
|
if (isUserDefinedTypeWithEquals) |
|
{ |
|
// Check if the type has an Equals method |
|
IEnumerable<MethodSymbol> equalsMethods = typeArg.GetMembers<MethodSymbol>("Equals", context); |
|
isUserDefinedTypeWithEquals = equalsMethods.Any(e => e.Parameters.Length == 1 && |
|
e.ReturnType == context.GetTypeSymbol(SpecialType.System_Boolean) && |
|
e.Parameters[0].Type == context.GetTypeSymbol(SpecialType.System_Object)); |
|
|
|
TypeSymbol objectType = context.GetTypeSymbol(SpecialType.System_Object); |
|
|
|
if (typeArg.IsUdonSharpBehaviour) |
|
{ |
|
while (!isUserDefinedTypeWithEquals && typeArg != null && typeArg.IsUdonSharpBehaviour) |
|
{ |
|
if (typeArg.BaseType == objectType) |
|
break; |
|
|
|
equalsMethods = typeArg.BaseType.GetMembers<MethodSymbol>("Equals", context); |
|
isUserDefinedTypeWithEquals = equalsMethods.Any(e => e.Parameters.Length == 1 && |
|
e.ReturnType == context.GetTypeSymbol(SpecialType.System_Boolean) && |
|
e.Parameters[0].Type == context.GetTypeSymbol(SpecialType.System_Object)); |
|
|
|
typeArg = typeArg.BaseType; |
|
} |
|
} |
|
} |
|
|
|
IConstantValue constantValue = new ConstantValue<bool>(isUserDefinedTypeWithEquals); |
|
|
|
createdInvocation = new BoundConstantInvocationExpression(node, constantValue, context.GetTypeSymbol(SpecialType.System_Boolean)); |
|
return true; |
|
} |
UdonSharpBehaviour TypeSymbol.BaseType is returning null on
line 136.
Exception happens on
line 139.
Describe the bug in detail:
Trying to use .Remove on a UdonSharpBehaviour inherited class list, and get a compile error.
Provide steps/code to reproduce the bug:
Create a List of a UdonSharpBehaviour inherited class not overriding Equals method.
Then use .Remove, .Contains, or .IndexOf on that list.
Compile and error should pop up.
Expected behavior:
There should be no error.
Additional Information:
UdonSharp/Packages/com.merlin.UdonSharp/Editor/Compiler/Binder/BoundNodes/BoundInvocationExpression.cs
Lines 117 to 153 in f5ecf68
UdonSharpBehaviour TypeSymbol.BaseType is returning null on line 136.
Exception happens on line 139.