Changeset 4304 for trunk/ProjectFortress
- Timestamp:
- 11/02/09 13:29:21 (3 weeks ago)
- Location:
- trunk/ProjectFortress
- Files:
-
- 4 modified
-
compiler_tests/AfterTypeChecking.test (modified) (1 diff)
-
src/com/sun/fortress/scala_src/typechecker/AbstractMethodChecker.scala (modified) (4 diffs)
-
src/com/sun/fortress/scala_src/typechecker/OverloadingChecker.scala (modified) (1 diff)
-
src/com/sun/fortress/scala_src/useful/STypesUtil.scala (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ProjectFortress/compiler_tests/AfterTypeChecking.test
r4286 r4304 25 25 Compiled9.g Compiled9.j Compiled9.k Compiled9.l Compiled9.m Compiled9.o Compiled9.p Compiled9.t Compiled9.u Compiled9.y Compiled9.ab Compiled9.ac Compiled9.ah Compiled9.ai Compiled9.aj \ 26 26 Compiled10.Comprehensions3 Compiled10.l Compiled10.m Compiled10.r \ 27 Compiled11 Compiled12 27 Compiled11 \ 28 Compiled12 Compiled12.inherit.fss 28 29 typecheck -
trunk/ProjectFortress/src/com/sun/fortress/scala_src/typechecker/AbstractMethodChecker.scala
r4289 r4304 26 26 import com.sun.fortress.compiler.index.ComponentIndex 27 27 import com.sun.fortress.compiler.index.{Functional => JavaFunctional} 28 import com.sun.fortress.compiler.index.HasSelfType 28 29 import com.sun.fortress.compiler.index.TraitIndex 29 30 import com.sun.fortress.compiler.typechecker.StaticTypeReplacer … … 105 106 } 106 107 107 private def inheritedAbstractMethods(extended_traits: List[TraitTypeWhere]) = 108 inheritedAbstractMethodsHelper(new HierarchyHistory(), extended_traits) 109 110 private def inheritedAbstractMethodsHelper(hist: HierarchyHistory, 111 extended_traits: List[TraitTypeWhere]): 112 Map[IdOrOp, (TraitType, Set[FnDecl])] = { 113 var h = hist 114 var map = new HashMap[IdOrOp, (TraitType, Set[FnDecl])]() 115 for ( trait_ <- extended_traits ; if ! h.hasExplored(trait_.getBaseType) ) { 116 trait_.getBaseType match { 117 case ty@STraitType(info, name, args, params) => 118 h.explore(ty) 119 val tci = typeAnalyzer.traits.typeCons(name) 120 if ( tci.isSome && tci.unwrap.isInstanceOf[TraitIndex] ) { 121 val ti = tci.unwrap.asInstanceOf[TraitIndex] 122 map.put(name, (ty, collectAbstractMethods(name, toList(NU.getDecls(ti.ast))))) 123 val old_hist = h 124 map ++= inheritedAbstractMethodsHelper(h, toList(ti.extendsTypes)) 125 h = old_hist 126 } else error(NU.getSpan(trait_), 127 "Trait types are expected in an extends clause but found " 128 + ty.toStringVerbose + "\n" + tci.getClass) 129 case SAnyType(_) => 130 case ty => error(NU.getSpan(trait_), 131 "Trait types are expected in an extends clause but found " 132 + ty.toStringVerbose) 108 private def inheritedAbstractMethods(extended_traits: List[TraitTypeWhere]) = { 109 val inherited = inheritedMethods(typeAnalyzer.traits, extended_traits, 110 Set(), typeAnalyzer) 111 val map = new HashMap[IdOrOp, (TraitType, Set[FnDecl])]() 112 for (pair <- inherited) { 113 val (_, ftn) = (pair.first, pair.second) 114 val name = ftn._1.asInstanceOf[HasSelfType].declaringTrait 115 val tci = typeAnalyzer.traits.typeCons(name) 116 if ( tci.isSome && tci.unwrap.isInstanceOf[TraitIndex] ) { 117 val ti = tci.unwrap.asInstanceOf[TraitIndex] 118 map.put(name, (ftn._3, 119 collectAbstractMethods(name, toList(NU.getDecls(ti.ast))))) 133 120 } 134 121 } … … 144 131 } else if ( mods.isAbstract ) set += fd 145 132 case _ => }) 146 set133 set 147 134 } 148 135 … … 152 139 private def implement(d: FnDecl, decls: List[Decl], ast: TraitType): Boolean = 153 140 decls.exists( (decl: Decl) => decl match { 154 case fd @SFnDecl(_,_,_,_,_)=> implement(d, fd, ast)141 case fd:FnDecl => implement(d, fd, ast) 155 142 case _ => false 156 143 } ) -
trunk/ProjectFortress/src/com/sun/fortress/scala_src/typechecker/OverloadingChecker.scala
r4292 r4304 198 198 toList(traitOrObject.extendsTypes), 199 199 methods, typeAnalyzer) 200 .asInstanceOf[Set[JavaPair[IdOrOpOrAnonymousName, (JavaFunctional, StaticTypeReplacer)]]] 200 .asInstanceOf[Set[JavaPair[IdOrOpOrAnonymousName, (JavaFunctional, StaticTypeReplacer, TraitType)]]] 201 .map(p => { val t = p.second 202 new JavaPair(p.first, (t._1, t._2)) }) 201 203 202 204 for ( f <- methods.map(x => x.first) ; if isDeclaredName(f) ) { -
trunk/ProjectFortress/src/com/sun/fortress/scala_src/useful/STypesUtil.scala
r4300 r4304 872 872 given: Set[(String, Type)]) 873 873 : Set[Pair[IdOrOpOrAnonymousName, 874 (Functional, StaticTypeReplacer )]] = {874 (Functional, StaticTypeReplacer, TraitType)]] = { 875 875 var allMethods = given 876 876 // a set of inherited methods: 877 877 // a set of pairs of method names and 878 // pairs of Functionals and static parameters substitutions879 var methods = Set[Pair[IdOrOpOrAnonymousName, (Functional, StaticTypeReplacer )]]()878 // triples of Functionals, static parameters substitutions, and declaring trait 879 var methods = Set[Pair[IdOrOpOrAnonymousName, (Functional, StaticTypeReplacer, TraitType)]]() 880 880 var h = history 881 881 for (trait_ <- extended_traits) { … … 902 902 val paramTy = paramsToArgs.replaceIn(new_pair._2) 903 903 if (!isOverride(fname, paramTy, allMethods, analyzer)) { 904 methods += new Pair(method_name, (method_func, paramsToArgs ))904 methods += new Pair(method_name, (method_func, paramsToArgs, ty)) 905 905 allMethods += ((fname, paramTy)) 906 906 }

