Changeset 4286
- Timestamp:
- 10/24/09 23:14:49 (4 weeks ago)
- Location:
- trunk/ProjectFortress
- Files:
-
- 5 added
- 3 modified
-
compiler_tests/AfterTypeChecking.test (modified) (1 diff)
-
compiler_tests/Compiled10.k.fss (added)
-
compiler_tests/Compiled10.q.fss (added)
-
compiler_tests/Compiled10.r.fss (added)
-
compiler_tests/XXX10k.test (added)
-
compiler_tests/XXX10q.test (added)
-
src/com/sun/fortress/scala_src/typechecker/AbstractMethodChecker.scala (modified) (2 diffs)
-
src/com/sun/fortress/scala_src/useful/STypesUtil.scala (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ProjectFortress/compiler_tests/AfterTypeChecking.test
r4277 r4286 24 24 Compiled80 \ 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 Compiled10.Comprehensions3 Compiled10.l Compiled10.m \26 Compiled10.Comprehensions3 Compiled10.l Compiled10.m Compiled10.r \ 27 27 Compiled11 Compiled12 28 28 typecheck -
trunk/ProjectFortress/src/com/sun/fortress/scala_src/typechecker/AbstractMethodChecker.scala
r4251 r4286 67 67 checkObject(span, List(), name, extendsC, 68 68 walk(decls).asInstanceOf[List[Decl]]) 69 val inherited = inheritedMethods( extendsC)69 val inherited = inheritedMethods(traits, extendsC).map(t => t.first.asInstanceOf[IdOrOp].getText) 70 70 for ( d <- decls ; if d.isInstanceOf[FnDecl] ) { 71 71 if ( NU.isFunctionalMethod(NU.getParams(d.asInstanceOf[FnDecl])) && … … 101 101 } 102 102 typeAnalyzer = oldTypeAnalyzer 103 }104 105 def inheritedMethods(extendedTraits: List[TraitTypeWhere]) = {106 // Return all of the methods from super-traits107 def inheritedMethodsHelper(history: HierarchyHistory,108 extended_traits: List[TraitTypeWhere])109 : Set[String] = {110 var methods = new HashSet[String]()111 var done = false112 var h = history113 for ( trait_ <- extended_traits ; if (! done) ) {114 val type_ = trait_.getBaseType115 if ( ! h.hasExplored(type_) ) {116 h.explore(type_)117 type_ match {118 case ty@STraitType(_, name, _, params) =>119 toOption(traits.typeCons(name)) match {120 case Some(ti) =>121 if ( ti.isInstanceOf[TraitIndex] ) {122 val trait_params = ti.staticParameters123 val trait_args = ty.getArgs124 // Instantiate methods with static args125 var collected = toSet(ti.asInstanceOf[TraitIndex].dottedMethods).map(t => t.first)126 collected ++= toSet(ti.asInstanceOf[TraitIndex].functionalMethods).map(t => t.first)127 for ( pair <- collected ; if pair.isInstanceOf[IdOrOp] ) {128 methods += pair.asInstanceOf[IdOrOp].getText129 }130 val paramsToArgs = new StaticTypeReplacer(trait_params, trait_args)131 val instantiated_extends_types =132 toList(ti.asInstanceOf[TraitIndex].extendsTypes).map( (t:TraitTypeWhere) =>133 t.accept(paramsToArgs).asInstanceOf[TraitTypeWhere] )134 val old_hist = h135 methods ++= inheritedMethodsHelper(h, instantiated_extends_types)136 h = old_hist137 } else done = true138 case _ => done = true139 }140 case _ => done = true141 }142 }143 }144 methods145 }146 inheritedMethodsHelper(new HierarchyHistory(), extendedTraits)147 103 } 148 104 -
trunk/ProjectFortress/src/com/sun/fortress/scala_src/useful/STypesUtil.scala
r4285 r4286 19 19 20 20 import _root_.java.util.ArrayList 21 import scala.collection.{Set => CSet} 22 import edu.rice.cs.plt.tuple.Pair 21 23 import com.sun.fortress.compiler.GlobalEnvironment 22 24 import com.sun.fortress.compiler.Types … … 37 39 import com.sun.fortress.scala_src.typechecker.CnFalse 38 40 import com.sun.fortress.scala_src.typechecker.CnTrue 41 import com.sun.fortress.scala_src.typechecker.TraitTable 39 42 import com.sun.fortress.scala_src.types.TypeAnalyzer 40 43 import com.sun.fortress.scala_src.useful.Lists._ … … 870 873 case _ => addType(fn, arrow) 871 874 } 875 876 def inheritedMethods(traits: TraitTable, 877 extendedTraits: List[TraitTypeWhere]) = { 878 // Return all of the methods from super-traits 879 def inheritedMethodsHelper(history: HierarchyHistory, 880 extended_traits: List[TraitTypeWhere]) 881 : Set[Pair[IdOrOpOrAnonymousName, Function]] = { 882 var methods = Set[Pair[IdOrOpOrAnonymousName, Function]]() 883 var done = false 884 var h = history 885 for ( trait_ <- extended_traits ; if (! done) ) { 886 val type_ = trait_.getBaseType 887 if ( ! h.hasExplored(type_) ) { 888 h.explore(type_) 889 type_ match { 890 case ty@STraitType(_, name, _, params) => 891 toOption(traits.typeCons(name)) match { 892 case Some(ti) => 893 if ( ti.isInstanceOf[TraitIndex] ) { 894 val trait_params = ti.staticParameters 895 val trait_args = ty.getArgs 896 // Instantiate methods with static args 897 var collected: Collection[Pair[IdOrOpOrAnonymousName, Function]] = 898 toSet(ti.asInstanceOf[TraitIndex].dottedMethods).asInstanceOf[CSet[Pair[IdOrOpOrAnonymousName, Function]]] 899 collected ++= 900 toSet(ti.asInstanceOf[TraitIndex].functionalMethods).asInstanceOf[CSet[Pair[IdOrOpOrAnonymousName, Function]]] 901 for ( pair <- collected ; if pair.first.isInstanceOf[IdOrOp] ) { 902 methods += pair 903 } 904 val paramsToArgs = new StaticTypeReplacer(trait_params, trait_args) 905 val instantiated_extends_types = 906 toList(ti.asInstanceOf[TraitIndex].extendsTypes).map( (t:TraitTypeWhere) => 907 t.accept(paramsToArgs).asInstanceOf[TraitTypeWhere] ) 908 val old_hist = h 909 methods ++= inheritedMethodsHelper(h, instantiated_extends_types) 910 h = old_hist 911 } else done = true 912 case _ => done = true 913 } 914 case _ => done = true 915 } 916 } 917 } 918 methods 919 } 920 inheritedMethodsHelper(new HierarchyHistory(), extendedTraits) 921 } 922 872 923 }

