-
Notifications
You must be signed in to change notification settings - Fork 108
Open
Labels
bugSomething isn't workingSomething isn't working
Description
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:
Lines 117 to 153 in f5ecf68
| 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.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working