Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use constant ids for RoArrayType GetMethodsCore #61177

Merged
merged 1 commit into from
Nov 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,6 @@ public sealed override bool Equals([NotNullWhen(true)] object? obj)
if (DeclaringType != other.DeclaringType)
return false;

if (ReturnType != other.ReturnType)
return false;

if (_uniquifier != other._uniquifier)
return false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ internal sealed override IEnumerable<MethodInfo> GetMethodsCore(NameFilter? filt
{
int rank = _rank;

int uniquifier = 0;
RoType systemInt32 = Loader.GetCoreType(CoreType.Int32);
RoType elementType = GetRoElementType();
RoType systemVoid = Loader.GetCoreType(CoreType.Void);
Expand All @@ -163,7 +162,7 @@ internal sealed override IEnumerable<MethodInfo> GetMethodsCore(NameFilter? filt
{
getParameters[i] = systemInt32;
}
yield return new RoSyntheticMethod(this, uniquifier++, "Get", elementType, getParameters);
yield return new RoSyntheticMethod(this, 0, "Get", elementType, getParameters);
}

if (filter == null || filter.Matches("Set"))
Expand All @@ -174,7 +173,7 @@ internal sealed override IEnumerable<MethodInfo> GetMethodsCore(NameFilter? filt
setParameters[i] = systemInt32;
}
setParameters[rank] = elementType;
yield return new RoSyntheticMethod(this, uniquifier++, "Set", systemVoid, setParameters);
yield return new RoSyntheticMethod(this, 1, "Set", systemVoid, setParameters);
}

if (filter == null || filter.Matches("Address"))
Expand All @@ -184,7 +183,7 @@ internal sealed override IEnumerable<MethodInfo> GetMethodsCore(NameFilter? filt
{
addressParameters[i] = systemInt32;
}
yield return new RoSyntheticMethod(this, uniquifier++, "Address", elementType.GetUniqueByRefType(), addressParameters);
yield return new RoSyntheticMethod(this, 2, "Address", elementType.GetUniqueByRefType(), addressParameters);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,20 @@ void testEqual(Type type1, Type type2)
testEqual(typeof(long[]).Project(), typeof(long[]).Project());
}

[Fact]
static void TestArrayGetMethodsResultEqualsFilteredGetMethod()
{
Type type = typeof(int[]).Project();

Assert.Equal(type.GetMethod("Get"), type.GetMethods().First(m => m.Name == "Get"));
Assert.Equal(type.GetMethod("Set"), type.GetMethods().First(m => m.Name == "Set"));
Assert.Equal(type.GetMethod("Address"), type.GetMethods().First(m => m.Name == "Address"));

Assert.NotEqual(type.GetMethod("Get"), type.GetMethods().First(m => m.Name == "Set"));
Assert.NotEqual(type.GetMethod("Set"), type.GetMethods().First(m => m.Name == "Address"));
Assert.NotEqual(type.GetMethod("Address"), type.GetMethods().First(m => m.Name == "Get"));
}

[Fact]
public static void TestArrayAddressMethod()
{
Expand Down