Changeset 3851
- Timestamp:
- 06/15/09 12:40:58 (5 months ago)
- Location:
- trunk/ProjectFortress
- Files:
-
- 9 modified
-
compiler_tests/Compiled6.g.fss (modified) (1 diff)
-
compiler_tests/Compiled6.h.fss (modified) (1 diff)
-
compiler_tests/Compiled6.i.fss (modified) (1 diff)
-
compiler_tests/Compiled6.m.fss (modified) (1 diff)
-
compiler_tests/XXX6g.test (modified) (1 diff)
-
compiler_tests/XXX6i.test (modified) (1 diff)
-
src/com/sun/fortress/compiler/ReturnTypeChecker.java (modified) (2 diffs)
-
src/com/sun/fortress/scala_src/typechecker/STypeChecker.scala (modified) (3 diffs)
-
src/com/sun/fortress/tests/unit_tests/FileTests.java (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ProjectFortress/compiler_tests/Compiled6.g.fss
r3840 r3851 20 20 21 21 object O 22 setter x(y:ZZ32) = y22 setter x(y:ZZ32): () = y 23 23 end 24 24 -
trunk/ProjectFortress/compiler_tests/Compiled6.h.fss
r3840 r3851 20 20 21 21 object O 22 setter x(y:ZZ32) = ()22 setter x(y:ZZ32): () = () 23 23 getter x(): String = "" 24 24 end -
trunk/ProjectFortress/compiler_tests/Compiled6.i.fss
r3840 r3851 20 20 21 21 object O 22 x(y: ZZ32) = ()23 x(y: ZZ32) = ()22 x(y: ZZ32): () = () 23 x(y: ZZ32): () = () 24 24 end 25 25 -
trunk/ProjectFortress/compiler_tests/Compiled6.m.fss
r3840 r3851 25 25 26 26 object O extends T 27 f(y:ZZ32) = ()27 f(y:ZZ32): () = () 28 28 end 29 29 -
trunk/ProjectFortress/compiler_tests/XXX6g.test
r3762 r3851 18 18 compile 19 19 compile_err_equals=\ 20 ${STATIC_TESTS_DIR}/Compiled6.g.fss:22: 3-22:\n\21 \ Setter declarations must return void.\n\20 ${STATIC_TESTS_DIR}/Compiled6.g.fss:22:26:\n\ 21 \ Function body has type ZZ32, but declared return type is ().\n\ 22 22 File Compiled6.g.fss has 1 error.\n 23 23 compile_out_equals= -
trunk/ProjectFortress/compiler_tests/XXX6i.test
r3783 r3851 18 18 compile 19 19 compile_err_equals=\ 20 ${STATIC_TESTS_DIR}/Compiled6.i.fss:22:3- 17:\n\21 ${STATIC_TESTS_DIR}/Compiled6.i.fss:23:3- 17:\n\20 ${STATIC_TESTS_DIR}/Compiled6.i.fss:22:3-21:\n\ 21 ${STATIC_TESTS_DIR}/Compiled6.i.fss:23:3-21:\n\ 22 22 \ There are multiple declarations of x with the same type: ZZ32 -> ()\n\ 23 23 File Compiled6.i.fss has 1 error.\n -
trunk/ProjectFortress/src/com/sun/fortress/compiler/ReturnTypeChecker.java
r3845 r3851 22 22 import com.sun.fortress.exceptions.StaticError; 23 23 import com.sun.fortress.nodes.FnDecl; 24 import com.sun.fortress.nodes.IdOrOp; 25 import com.sun.fortress.nodes.IdOrOpOrAnonymousName; 24 26 import com.sun.fortress.nodes.LetFn; 25 27 import com.sun.fortress.nodes.Node; … … 44 46 @Override 45 47 public void forFnDecl(FnDecl that) { 46 if(that.getHeader().getReturnType().isNone()){ 48 IdOrOpOrAnonymousName name = that.getHeader().getName(); 49 boolean isCoercion = (name instanceof IdOrOp) ? 50 ((IdOrOp)name).getText().equals("coerce") : 51 false; 52 if (!isCoercion && that.getHeader().getReturnType().isNone()) { 47 53 errors.add(StaticError.make("The Scala Typechecker requires return types on function:" + that.getUnambiguousName(), that)); 48 54 } -
trunk/ProjectFortress/src/com/sun/fortress/scala_src/typechecker/STypeChecker.scala
r3845 r3851 112 112 analyzer.extend(sparams, where), errors) 113 113 } 114 115 private def extend(id: Id, typ: Type): STypeChecker = 116 extend(List[LValue](NodeFactory.makeLValue(id, typ))) 114 117 115 118 private def extendWithFunctions(methods: Relation[IdOrOpOrAnonymousName, JavaFunctionalMethod]) = … … 827 830 val newContract = contract.map(c => newChecker.check(c)) 828 831 val newBody = newChecker.checkExpr(body, returnType, "Function body", 829 "declared return") 830 832 "declared return") 831 833 832 834 val newType = (returnType, getType(newBody)) match { 833 case ( _, Some(bt)) if NodeUtil.isSetter(f) =>834 isSubtype( bt, Types.VOID, f, "Setter declarations must return void.")835 case (Some(rt), _) if NodeUtil.isSetter(f) => 836 isSubtype(rt, Types.VOID, f, "Setter declarations must return void.") 835 837 Some(Types.VOID) 836 838 case (None, bt) => bt … … 1640 1642 case None => signal(id, errorMsg("Type of the variable '", id, "' not found.")); v 1641 1643 } 1644 1645 case STypecase(SExprInfo(span, paren, _), 1646 bindIds, bindExpr, clauses, elseClause) => { 1647 if (bindIds.size != 1) 1648 NI.nyi("Typecase only supports a single identifier for now.") 1649 1650 // Make sure the bindId is not shadowing. 1651 val bindId = bindIds.first 1652 if (getTypeFromName(bindId).isDefined) { 1653 signal(bindId, "Cannot shadow name: %s".format(bindId)) 1654 return expr 1655 } 1656 1657 // Make sure the expr has a type. 1658 val checkedExpr = bindExpr.map(checkExpr). 1659 getOrElse(NI.nyi("Typecase currently must have a bound expression.")) 1660 val checkedType = getType(checkedExpr).getOrElse(return expr) 1661 1662 // Check each clause with the bound id having static type of the guard. 1663 def checkClause(c: TypecaseClause): TypecaseClause = c match { 1664 case STypecaseClause(info, List(matchType), body) => 1665 val checkedBody = 1666 this.extend(bindId, matchType). 1667 checkExpr(body).asInstanceOf[Block] 1668 STypecaseClause(info, List(matchType), checkedBody) 1669 1670 case _ => 1671 NI.nyi("Typecase only supports a single match type for now.") 1672 } 1673 val checkedClauses = clauses.map(checkClause) 1674 val clauseTypes = 1675 checkedClauses.map(c => getType(c.getBody).getOrElse(return expr)) 1676 1677 // Check the else clause with the new binding. 1678 val checkedElse = 1679 elseClause.map(e => this.extend(bindId, checkedType). 1680 checkExpr(e).asInstanceOf[Block]) 1681 val elseType = checkedElse.map(getType(_).getOrElse(return expr)) 1682 1683 // Build union type of all clauses and else. 1684 val allTypes = elseType match { 1685 case Some(t) => Set(clauseTypes:_*) + t 1686 case _ => Set(clauseTypes:_*) 1687 } 1688 val unionType = NodeFactory.makeUnionType(allTypes) 1689 1690 STypecase(SExprInfo(span, paren, Some(unionType)), 1691 bindIds, 1692 Some(checkedExpr), 1693 checkedClauses, 1694 checkedElse) 1695 } 1696 1697 case SAsExpr(SExprInfo(span, paren, _), sub, typ) => { 1698 val checkedSub = checkExpr(sub, Some(typ), "Expression", "ascripted") 1699 SAsExpr(SExprInfo(span, paren, Some(typ)), checkedSub, typ) 1700 } 1701 1702 case SAsIfExpr(SExprInfo(span, paren, _), sub, typ) => { 1703 val checkedSub = checkExpr(sub, Some(typ), "Expression", "assumed") 1704 SAsIfExpr(SExprInfo(span, paren, Some(typ)), checkedSub, typ) 1705 } 1642 1706 1643 1707 case _ => throw new Error(errorMsg("Not yet implemented: ", expr.getClass)) -
trunk/ProjectFortress/src/com/sun/fortress/tests/unit_tests/FileTests.java
r3844 r3851 972 972 || test_name.startsWith("Compiled4") 973 973 || test_name.startsWith("Compiled5") 974 //|| test_name.startsWith("Compiled6") 975 // || test_name.startsWith("Compiled7") 976 // || test_name.startsWith("Compiled8") 974 977 ); 975 978 }

