[Nice-commit] Nice/src/bossa/syntax literalarray.nice,1.1,1.2
Brought to you by:
bonniot
From: Daniel B. <bo...@us...> - 2004-07-30 18:31:19
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32295/src/bossa/syntax Modified Files: literalarray.nice Log Message: For literal arrays with a known expected type, perform type-checking on the elements instead of inferring the type of the whole array. Index: literalarray.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/literalarray.nice,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** literalarray.nice 28 Jul 2004 14:40:33 -0000 1.1 --- literalarray.nice 30 Jul 2004 18:31:10 -0000 1.2 *************** *** 66,71 **** if (elementType != null) ! for (elem : elements) ! elem.adjustToExpectedType(elementType); return this; --- 66,95 ---- if (elementType != null) ! { ! // Accept for us the type the context imposes, and just check ! // that the array elements fit. ! if (this.type == null && expectedType.isMonomorphic()) ! { ! for (int i = 0; i < elements.length; i++) ! { ! elements[i] = elements[i].noOverloading(); ! try { ! mlsub.typing.Typing.leq(elements[i].getType(), elementType); ! } ! catch (mlsub.typing.TypingEx ex) { ! throw User.error ! (elements[i], "Incorrect type for array element:" + ! "\nFound : " + elements[i].getType() + ! "\nExpected : " + elementType); ! } ! } ! ! // Make the context type our type. ! this.type = expectedType; ! } ! ! for (elem : elements) ! elem.adjustToExpectedType(elementType); ! } return this; *************** *** 91,95 **** if (elementType != null) for (elem : elements) ! elem.adjustToExpectedType(elementType); } --- 115,119 ---- if (elementType != null) for (elem : elements) ! elem.adjustToExpectedType(elementType); } |