Hey, I've run into a problem with my project. I can't seem to access Arrays which are initialized in a constructor. Here's a simple class that
illustrates the problem.
public class ArrayTest
{
val classFieldArray: Array[Int];
val classFieldArray2 = new Array[Int] (10, 0);
def this ()
{
classFieldArray = new Array[Int] (10, 0);
}
public def isFine ()
{
val localArray = new Array[Int] (10, 0);
localArray(2) = 5;
}
public def isAlsoFine ()
{
classFieldArray2(2) = 5;
}
public def wontCompile ()
{
classFieldArray(2) = 5;
/*Cannot assign expression to array element of given type.
Expression: 5
Array element: ArrayTest.this.classFieldArray(2)
Cause: Method apply(i0:
x10.lang.Int){x10.array.Array#this.region.rank==1}[]
in x10.array.Array[
x10.lang.Int]{self==ArrayTest#this.classFieldArray,
ArrayTest#this.classFieldArray.region!=null} cannot be called with arguments
(
x10.lang.Int{self==2}); Call invalid; calling environment does not entail
the method guard. */
}
}
the methods isFine () and isAlsoFine, compile fine. The method wontCompile, won't compile. The error message eclipse gives is the comment below it. I download the version of x10 I'm using just before break so it should be the most recent version. Can anyone tell me why this is happening? I'd be appreciative.