Browse Source

Fix exception in type substitution when accessing multidimensional arrays that have a type parameter as element type. Closes #43.

pull/70/head
Daniel Grunwald 14 years ago
parent
commit
680d7a413e
  1. 6
      ICSharpCode.Decompiler/ILAst/TypeAnalysis.cs
  2. 1
      ICSharpCode.Decompiler/Tests/ICSharpCode.Decompiler.Tests.csproj
  3. 27
      ICSharpCode.Decompiler/Tests/MultidimensionalArray.cs

6
ICSharpCode.Decompiler/ILAst/TypeAnalysis.cs

@ -524,7 +524,11 @@ namespace Decompiler @@ -524,7 +524,11 @@ namespace Decompiler
if (gp.Owner.GenericParameterType == GenericParameterType.Method) {
return ((GenericInstanceMethod)member).GenericArguments[gp.Position];
} else {
return ((GenericInstanceType)member.DeclaringType).GenericArguments[gp.Position];
if (member.DeclaringType is ArrayType) {
return ((ArrayType)member.DeclaringType).ElementType;
} else {
return ((GenericInstanceType)member.DeclaringType).GenericArguments[gp.Position];
}
}
}
return type;

1
ICSharpCode.Decompiler/Tests/ICSharpCode.Decompiler.Tests.csproj

@ -50,6 +50,7 @@ @@ -50,6 +50,7 @@
<ItemGroup>
<Compile Include="DelegateConstruction.cs" />
<Compile Include="ExceptionHandling.cs" />
<Compile Include="MultidimensionalArray.cs" />
<Compile Include="Loops.cs" />
<Compile Include="PropertiesAndEvents.cs" />
<Compile Include="TestRunner.cs" />

27
ICSharpCode.Decompiler/Tests/MultidimensionalArray.cs

@ -0,0 +1,27 @@ @@ -0,0 +1,27 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
using System;
public static class MultidimensionalArray
{
internal class Generic<T, S> where T : new()
{
private T[,] a = new T[20, 20];
private S[,][] b = new S[20, 20][];
public T this[int i, int j]
{
get { return a[i, j]; }
set { a[i, j] = value; }
}
public void TestB(S x, ref S y)
{
b[5, 3] = new S[10];
b[5, 3][0] = default(S);
b[5, 3][1] = x;
b[5, 3][2] = y;
}
}
}
Loading…
Cancel
Save