3c1f479b9d
Former-commit-id: 806294f5ded97629b74c85c09952f2a74fe182d9
71 lines
1.0 KiB
C#
71 lines
1.0 KiB
C#
using System;
|
|
|
|
class CI
|
|
{
|
|
public string this [string i] { set { } get { return ""; } }
|
|
public int? this [int i] { set { } get { return 1; } }
|
|
}
|
|
|
|
class C
|
|
{
|
|
static int TestArrayAccess ()
|
|
{
|
|
byte[] arr = null;
|
|
var v = arr? [0];
|
|
if (v != null)
|
|
return 1;
|
|
|
|
long?[] ar2 = null;
|
|
var v2 = ar2? [-1];
|
|
if (v2 != null)
|
|
return 2;
|
|
|
|
var v3 = arr? [0].GetHashCode () ?? 724;
|
|
if (v3 != 724)
|
|
return 3;
|
|
|
|
string[] ar3 = null;
|
|
var v4 = ar3?[0].Length;
|
|
if (v4 != null)
|
|
return 4;
|
|
|
|
// TODO: Disabled for now?
|
|
// arr? [0] += 2;
|
|
return 0;
|
|
}
|
|
|
|
static int TestIndexerAccess ()
|
|
{
|
|
CI ci = null;
|
|
var v = ci? ["x"];
|
|
if (v != null)
|
|
return 1;
|
|
|
|
var v2 = ci? [0];
|
|
if (v2 != null)
|
|
return 2;
|
|
|
|
var v3 = ci? [0].GetHashCode () ?? 724;
|
|
if (v3 != 724)
|
|
return 3;
|
|
|
|
// TODO: Disabled for now?
|
|
// ci? [0] += 3;
|
|
return 0;
|
|
}
|
|
|
|
static int Main ()
|
|
{
|
|
int res;
|
|
res = TestArrayAccess ();
|
|
if (res != 0)
|
|
return 10 + res;
|
|
|
|
res = TestIndexerAccess ();
|
|
if (res != 0)
|
|
return 20 + res;
|
|
|
|
Console.WriteLine ("ok");
|
|
return 0;
|
|
}
|
|
} |