Changeset 3834

Show
Ignore:
Timestamp:
06/10/09 18:11:17 (6 months ago)
Author:
sukyoungryu
Message:

[type checker] Fixed small things in the Scala type checker. Moved three tests from not_working_static_tests to compiler_tests.

Location:
trunk
Files:
6 added
3 removed
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/Library/CompilerLibrary.fsi

    r3310 r3834  
    1818api CompilerLibrary 
    1919 
     20ignore(_:Any):() 
     21 
    2022end 
  • trunk/ProjectFortress/src/com/sun/fortress/scala_src/typechecker/STypeChecker.scala

    r3833 r3834  
    304304                                          receiverType: Type): 
    305305                                              Set[Method] = { 
    306      
     306 
    307307    val traitTypes = traitTypesCallable(receiverType) 
    308308    val ttAsWheres = traitTypes.map(NodeFactory.makeTraitTypeWhere) 
     
    430430                                            expectedType: Option[Type]): 
    431431                                      Option[(ArrowType, List[StaticArg])] = { 
    432      
     432 
    433433    val arrows = conjuncts(fnType).toList.map(_.asInstanceOf[ArrowType]) 
    434434    staticallyMostApplicableArrow(arrows, argType, expectedType) 
    435435  } 
    436    
     436 
    437437  /** 
    438438   * Return the statically most applicable arrow type along with the static args 
     
    445445                                            expectedType: Option[Type]): 
    446446                                        Option[(ArrowType, List[StaticArg])] = { 
    447      
     447 
    448448    // Filter applicable arrows and their instantiated args. 
    449449    val arrowsAndInstantiations = 
     
    705705      extendsC.foreach( (t:TraitTypeWhere) => 
    706706                        assertTrait(t.getBaseType, 
    707                                     "Objects can only extend traits.", o) ) 
     707                                    "Objects can only extend traits.", t.getBaseType) ) 
    708708      val checkerWSparams = this.extend(sparams, params, where) 
    709709      var method_checker = checkerWSparams 
     
    927927      extendsC.foreach( (t:TraitTypeWhere) => 
    928928                        assertTrait(t.getBaseType, 
    929                                     "Objects can only extend traits.", o) ) 
     929                                    "Objects can only extend traits.", t.getBaseType) ) 
    930930      var method_checker = this 
    931931      var field_checker = this 
     
    943943      val oi = IndexBuilder.buildObjectExprIndex(o) 
    944944      val methods = new UnionRelation(inheritedMethods(extendsC), 
    945                                       oi.asInstanceOf[ObjectTraitIndex].dottedMethods.asInstanceOf) 
     945                                      oi.asInstanceOf[ObjectTraitIndex].dottedMethods.asInstanceOf[Relation[IdOrOpOrAnonymousName, Method]]) 
    946946      method_checker = method_checker.extendWithMethods(methods) 
    947947      method_checker = method_checker.extendWithFunctions(oi.asInstanceOf[ObjectTraitIndex].functionalMethods) 
     
    13081308    } 
    13091309 
    1310     case SSubscriptExpr(SExprInfo(span, paren, _), obj, subs, op, sargs) => {     
     1310    case SSubscriptExpr(SExprInfo(span, paren, _), obj, subs, op, sargs) => { 
    13111311      val checkedObj = checkExpr(obj) 
    13121312      val checkedSubs = subs.map(checkExpr) 
    13131313      val objType = getType(checkedObj).getOrElse(return expr) 
    1314        
     1314 
    13151315      // Convert sub types into a single type or tuple of types. 
    13161316      if (!haveTypes(checkedSubs)) return expr 
     
    13201320          NodeFactory.makeTupleType(NodeUtil.getSpan(expr), toJavaList(t)) 
    13211321      } 
    1322        
     1322 
    13231323      // Get the methods and arrows from the op. 
    13241324      val methods = findMethodsInTraitHierarchy(op.get, objType) 
     
    13281328               flatMap(m => staticInstantiation(sargs, getArrowFromMethod(m))). 
    13291329               map(_.asInstanceOf[ArrowType]) 
    1330        
     1330 
    13311331      staticallyMostApplicableArrow(arrows.toList, subsType, None) match { 
    13321332        case Some((arrow, sargs)) => 
     
    13361336                         op, 
    13371337                         sargs) 
    1338         case one =>  
     1338        case one => 
    13391339          // TODO: Better error message. 
    13401340          signal(expr, "Receiver type %s does not have applicable overloading of %s for argument type %s.". 
     
    13431343      } 
    13441344    } 
    1345      
     1345 
    13461346    case SStringLiteralExpr(SExprInfo(span,parenthesized,_), text) => 
    13471347      SStringLiteralExpr(SExprInfo(span,parenthesized,Some(Types.STRING)), text) 
     
    14361436      val checkedArgs = args.map(checkExpr) 
    14371437      if (!haveTypes(checkedArgs)) return expr 
    1438        
     1438 
    14391439      def checkAsInfix() = checkExpr(checkedArgs.reduceLeft( 
    14401440        (e1, e2) => SOpExpr(info, infixOp, List(e1, e2)))) 
    14411441 
    1442       // Attempt to check the multifix.       
     1442      // Attempt to check the multifix. 
    14431443      val checkedMultifixOp = 
    14441444        new TryChecker(current, traits, env, analyzer). 
    14451445          tryCheckExpr(multifixOp). 
    14461446          getOrElse(return checkAsInfix()) 
    1447        
     1447 
    14481448      val opType = getType(checkedMultifixOp).getOrElse(return expr) 
    14491449      val argType = 
     
    16021602    // "\n" + expr.toStringVerbose()) 
    16031603  } 
    1604    
     1604 
    16051605  /** 
    16061606   * A type checker that doesn't report its errors. Use the tryCheck() and 
     
    16231623      throw errors.errors.last 
    16241624    } 
    1625    
     1625 
    16261626    /** 
    16271627     * Adds to error log and throws the exception it made. 
    16281628     */ 
    16291629    override protected def signal(hasAt:HasAt, msg:String) = signal(msg, hasAt) 
    1630      
     1630 
    16311631    /** 
    16321632     * Check the given node; return it if successful, None otherwise. 
     
    16411641      } 
    16421642    } 
    1643      
     1643 
    16441644    /** 
    16451645     * Check the given expression; return it if successful, None otherwise.