Changeset 4311
- Timestamp:
- 11/03/09 21:46:01 (3 weeks ago)
- Location:
- trunk/ProjectFortress
- Files:
-
- 50 modified
-
astgen/Fortress.ast (modified) (3 diffs)
-
compiler_tests/XXX10d.test (modified) (1 diff)
-
compiler_tests/XXX10k.test (modified) (1 diff)
-
compiler_tests/XXX10s.test (modified) (1 diff)
-
src/com/sun/fortress/compiler/NamingCzar.java (modified) (8 diffs)
-
src/com/sun/fortress/compiler/codegen/CodeGen.java (modified) (1 diff)
-
src/com/sun/fortress/compiler/codegen/GenericNumberer.java (modified) (3 diffs)
-
src/com/sun/fortress/compiler/desugarer/ObjectExpressionVisitor.java (modified) (1 diff)
-
src/com/sun/fortress/compiler/desugarer/PreDisambiguationDesugaringVisitor.java (modified) (1 diff)
-
src/com/sun/fortress/compiler/desugarer/VarRefContainer.java (modified) (2 diffs)
-
src/com/sun/fortress/compiler/disambiguator/TypeDisambiguator.java (modified) (2 diffs)
-
src/com/sun/fortress/compiler/index/Coercion.java (modified) (1 diff)
-
src/com/sun/fortress/compiler/index/DeclaredMethod.java (modified) (3 diffs)
-
src/com/sun/fortress/compiler/index/FieldGetterOrSetterMethod.java (modified) (3 diffs)
-
src/com/sun/fortress/compiler/index/FunctionalMethod.java (modified) (3 diffs)
-
src/com/sun/fortress/compiler/index/HasSelfType.java (modified) (2 diffs)
-
src/com/sun/fortress/compiler/index/TraitIndex.java (modified) (1 diff)
-
src/com/sun/fortress/compiler/typechecker/TypeAnalyzer.java (modified) (2 diffs)
-
src/com/sun/fortress/compiler/typechecker/TypeAnalyzerJUTest.java (modified) (2 diffs)
-
src/com/sun/fortress/compiler/typechecker/TypeAnalyzerUtil.java (modified) (1 diff)
-
src/com/sun/fortress/compiler/typechecker/TypeCheckerTestCase.java (modified) (2 diffs)
-
src/com/sun/fortress/compiler/typechecker/TypeNormalizer.java (modified) (1 diff)
-
src/com/sun/fortress/compiler/typechecker/TypesUtil.java (modified) (2 diffs)
-
src/com/sun/fortress/interpreter/evaluator/EvalType.java (modified) (2 diffs)
-
src/com/sun/fortress/interpreter/evaluator/ScoutVisitor.java (modified) (1 diff)
-
src/com/sun/fortress/interpreter/evaluator/types/FTraitOrObject.java (modified) (1 diff)
-
src/com/sun/fortress/nodes_util/ErrorMsgMaker.java (modified) (1 diff)
-
src/com/sun/fortress/nodes_util/ExprFactory.java (modified) (3 diffs)
-
src/com/sun/fortress/nodes_util/NodeComparator.java (modified) (2 diffs)
-
src/com/sun/fortress/nodes_util/NodeFactory.java (modified) (12 diffs)
-
src/com/sun/fortress/parser/DelimitedExpr.rats (modified) (1 diff)
-
src/com/sun/fortress/parser/TraitObject.rats (modified) (4 diffs)
-
src/com/sun/fortress/repository/ForeignJava.java (modified) (1 diff)
-
src/com/sun/fortress/scala_src/disambiguator/SelfParamDisambiguator.scala (modified) (4 diffs)
-
src/com/sun/fortress/scala_src/linker/HygienicRenamer.scala (modified) (2 diffs)
-
src/com/sun/fortress/scala_src/typechecker/CoercionOracle.scala (modified) (2 diffs)
-
src/com/sun/fortress/scala_src/typechecker/ExclusionOracle.scala (modified) (2 diffs)
-
src/com/sun/fortress/scala_src/typechecker/ExportChecker.scala (modified) (1 diff)
-
src/com/sun/fortress/scala_src/typechecker/IndexBuilder.scala (modified) (2 diffs)
-
src/com/sun/fortress/scala_src/typechecker/STypeChecker.scala (modified) (1 diff)
-
src/com/sun/fortress/scala_src/typechecker/TypeHierarchyChecker.scala (modified) (1 diff)
-
src/com/sun/fortress/scala_src/typechecker/TypeWellFormedChecker.scala (modified) (3 diffs)
-
src/com/sun/fortress/scala_src/typechecker/impls/Common.scala (modified) (1 diff)
-
src/com/sun/fortress/scala_src/types/CoveringAnalyzer.scala (modified) (1 diff)
-
src/com/sun/fortress/scala_src/types/TypeAnalyzer.scala (modified) (3 diffs)
-
src/com/sun/fortress/scala_src/useful/SNodeUtil.scala (modified) (1 diff)
-
src/com/sun/fortress/scala_src/useful/STypesUtil.scala (modified) (2 diffs)
-
src/com/sun/fortress/syntax_abstractions/util/BaseTypeCollector.java (modified) (1 diff)
-
src/com/sun/fortress/syntax_abstractions/util/FortressTypeToJavaType.java (modified) (1 diff)
-
src/com/sun/fortress/tools/FortressAstToConcrete.java (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ProjectFortress/astgen/Fortress.ast
r4296 r4311 176 176 * it is initialized by compiler.disambiguator.SelfParamDisambiguator. 177 177 */ 178 abstract TraitObjectDecl(TraitTypeHeader header, Option< Type> selfType) implements Generic;178 abstract TraitObjectDecl(TraitTypeHeader header, Option<SelfType> selfType) implements Generic; 179 179 /** 180 180 * trait declaration in components or APIs … … 562 562 * end 563 563 */ 564 ObjectExpr(Option< Type> selfType);564 ObjectExpr(Option<SelfType> selfType); 565 565 /** 566 566 * object expression rewritten by interpreter.rewrite.Disambiguate … … 1033 1033 UnknownType(); 1034 1034 /** 1035 * the type of "self" in a trait or object 1036 * internal node 1037 */ 1038 abstract SelfType(); 1039 /** 1040 * the type of "self" in a trait or object declaration 1041 * internal node 1042 */ 1043 TraitSelfType(BaseType named, List<NamedType> comprised); 1044 /** 1045 * the type of "self" in an object expression 1046 * internal node 1047 */ 1048 ObjectExprType(List<BaseType> extended); 1049 /** 1035 1050 * named type 1036 1051 */ -
trunk/ProjectFortress/compiler_tests/XXX10d.test
r4259 r4311 20 20 ${STATIC_TESTS_DIR}/Compiled10.d.fss:20:13-17:\n\ 21 21 \ Could not check call to function g\n\ 22 \ - O->() is not applicable to an argument of type AND(T,OR(O,P)).\n\22 \ - O->() is not applicable to an argument of type T.\n\ 23 23 File Compiled10.d.fss has 1 error.\n 24 24 compile_out_equals= -
trunk/ProjectFortress/compiler_tests/XXX10k.test
r4286 r4311 20 20 ${STATIC_TESTS_DIR}/Compiled10.k.fss:33:5-9:\n\ 21 21 \ Could not check call to function k\n\ 22 \ - Q->() is not applicable to an argument of type AND(T[\\U\\],U).\n\22 \ - Q->() is not applicable to an argument of type T[\\U\\].\n\ 23 23 ${STATIC_TESTS_DIR}/Compiled10.k.fss:34:5-7:\n\ 24 24 \ Could not check call to function h\n\ 25 \ - AND(T[\\U\\],U)->() is not applicable to an argument of type T[\\U\\].\n\25 \ - T[\\U\\]->() is not applicable to an argument of type T[\\U\\].\n\ 26 26 ${STATIC_TESTS_DIR}/Compiled10.k.fss:36:5-7:\n\ 27 27 \ Could not check call to function j\n\ -
trunk/ProjectFortress/compiler_tests/XXX10s.test
r4292 r4311 21 21 ${STATIC_TESTS_DIR}/Compiled10.s.fss:20:3-33:\n\ 22 22 \ Invalid overloading of f:\n\ 23 \ ( AND(Bar[\\O,P\\],OR(O,P)), Bar[\\O,P\\]) -> () @ ${STATIC_TESTS_DIR}/Compiled10.s.fss:20:3-33\n\24 \ and ( AND(Bar[\\P,O\\],OR(P,O)), Bar[\\P,O\\]) -> () @ ${STATIC_TESTS_DIR}/Compiled10.s.fss:20:3-33\n\23 \ (Bar[\\O,P\\], Bar[\\O,P\\]) -> () @ ${STATIC_TESTS_DIR}/Compiled10.s.fss:20:3-33\n\ 24 \ and (Bar[\\P,O\\], Bar[\\P,O\\]) -> () @ ${STATIC_TESTS_DIR}/Compiled10.s.fss:20:3-33\n\ 25 25 File Compiled10.s.fss has 1 error.\n 26 26 compile_out_equals= -
trunk/ProjectFortress/src/com/sun/fortress/compiler/NamingCzar.java
r4305 r4311 42 42 import com.sun.fortress.nodes.NamedType; 43 43 import com.sun.fortress.nodes.Param; 44 import com.sun.fortress.nodes.TraitSelfType; 44 45 import com.sun.fortress.nodes.TraitType; 45 46 import com.sun.fortress.nodes.TraitTypeWhere; … … 872 873 throw new CompilerError(x,"emitDesc of type "+x+" failed"); 873 874 } 875 @Override 874 876 public String forArrowType(ArrowType t) { 875 877 String res = makeArrowDescriptor(t, ifNone); … … 878 880 return res; 879 881 } 880 882 @Override 881 883 public String forTupleType(TupleType t) { 882 884 if ( NodeUtil.isVoidType(t) ) … … 888 890 return jvmTypeDescs(t.getElements(), ifNone); 889 891 } 892 @Override 890 893 public String forAnyType (AnyType t) { 891 894 return descFortressAny; 892 895 } 896 @Override 893 897 public String forVarType (VarType t) { 894 898 // … … 897 901 return s; 898 902 } 903 @Override 904 public String forTraitSelfType(TraitSelfType t) { 905 return t.getNamed().accept(this); 906 } 907 @Override 899 908 public String forTraitType(TraitType t) { 900 909 // I think this is wrong! What about API names? … … 929 938 final APIName ifNone) { 930 939 return type.accept(new NodeAbstractVisitor<String>() { 940 @Override 931 941 public String defaultCase(Node x) { 932 942 throw new CompilerError(x,"methodDesc of type "+x+" failed"); 933 943 } 934 944 @Override 935 945 public String forArrowType(ArrowType t) { 936 946 if (NodeUtil.isVoidType(t.getDomain())) … … 941 951 942 952 // TODO CASES BELOW OUGHT TO JUST FAIL, WILL TEST SOON. 953 @Override 943 954 public String forTupleType(TupleType t) { 944 955 if ( NodeUtil.isVoidType(t) ) … … 954 965 return res; 955 966 } 967 @Override 956 968 public String forAnyType (AnyType t) { 957 969 return descFortressAny; 958 970 } 971 @Override 972 public String forTraitSelfType(TraitSelfType t) { 973 return t.getNamed().accept(this); 974 } 975 @Override 959 976 public String forTraitType(TraitType t) { 960 977 String result = specialFortressDescriptors.get(t); -
trunk/ProjectFortress/src/com/sun/fortress/compiler/codegen/CodeGen.java
r4305 r4311 2417 2417 } 2418 2418 2419 return exprType.unwrap(); 2419 Type ty = exprType.unwrap(); 2420 if (ty instanceof TraitSelfType) 2421 ty = ((TraitSelfType)ty).getNamed(); 2422 2423 return ty; 2420 2424 } 2421 2425 private Option<Type> exprOptType(Expr expr) { -
trunk/ProjectFortress/src/com/sun/fortress/compiler/codegen/GenericNumberer.java
r4296 r4311 15 15 trademarks of Sun Microsystems, Inc. in the U.S. and other countries. 16 16 ******************************************************************************/ 17 /* 18 * Created on Sep 22, 2009 19 * 20 */ 17 21 18 package com.sun.fortress.compiler.codegen; 22 19 … … 38 35 import com.sun.fortress.nodes.StaticParam; 39 36 import com.sun.fortress.nodes.StaticParamKind; 37 import com.sun.fortress.nodes.TraitSelfType; 40 38 import com.sun.fortress.nodes.TraitType; 41 39 import com.sun.fortress.nodes.Type; … … 124 122 125 123 @Override 124 public Node forTraitSelfType(TraitSelfType that) { 125 return that.getNamed().accept(this); 126 } 127 128 @Override 126 129 public Node forTraitType(TraitType that) { 127 130 TypeInfo info_result = (TypeInfo) recur(that.getInfo()); -
trunk/ProjectFortress/src/com/sun/fortress/compiler/desugarer/ObjectExpressionVisitor.java
r4112 r4311 647 647 staticParams, 648 648 extendsClauses, 649 decls, params, Option.< Type>none());649 decls, params, Option.<SelfType>none()); 650 650 if(enclosingSelf != null) { 651 651 VarRef receiver = makeVarRefFromParam(enclosingSelf); -
trunk/ProjectFortress/src/com/sun/fortress/compiler/desugarer/PreDisambiguationDesugaringVisitor.java
r4275 r4311 74 74 ExprInfo info, 75 75 TraitTypeHeader header, 76 Option< Type> selfType) {76 Option<SelfType> selfType) { 77 77 Span span = NodeUtil.getSpan(that); 78 78 List<TraitTypeWhere> extendsClause = rewriteExtendsClause(that, header.getExtendsClause()); -
trunk/ProjectFortress/src/com/sun/fortress/compiler/desugarer/VarRefContainer.java
r4300 r4311 22 22 import java.util.List; 23 23 24 import com.sun.fortress.nodes.ASTNode; 25 import com.sun.fortress.nodes.Decl; 26 import com.sun.fortress.nodes.Expr; 27 import com.sun.fortress.nodes.FnRef; 28 import com.sun.fortress.nodes.Id; 29 import com.sun.fortress.nodes.IdOrOp; 30 import com.sun.fortress.nodes.LValue; 31 import com.sun.fortress.nodes.LocalVarDecl; 32 import com.sun.fortress.nodes.Node; 33 import com.sun.fortress.nodes.ObjectDecl; 34 import com.sun.fortress.nodes.Param; 35 import com.sun.fortress.nodes.StaticArg; 36 import com.sun.fortress.nodes.StaticParam; 37 import com.sun.fortress.nodes.TraitTypeWhere; 38 import com.sun.fortress.nodes.Type; 39 import com.sun.fortress.nodes.VarDecl; 40 import com.sun.fortress.nodes.VarRef; 41 import com.sun.fortress.nodes.FieldRef; 42 import com.sun.fortress.nodes.WhereClause; 24 import com.sun.fortress.nodes.*; 43 25 import com.sun.fortress.nodes_util.ExprFactory; 44 26 import com.sun.fortress.nodes_util.Modifiers; … … 101 83 ObjectDecl container = 102 84 NodeFactory.makeObjectDecl( NodeUtil.getSpan(origDeclNode), containerDeclId(), 103 Option.<List<Param>>some(params), Option.< Type>none() );85 Option.<List<Param>>some(params), Option.<SelfType>none() ); 104 86 105 87 return container; -
trunk/ProjectFortress/src/com/sun/fortress/compiler/disambiguator/TypeDisambiguator.java
r4280 r4311 101 101 that.getInfo(), 102 102 header, 103 v.recurOnOptionOf Type(that.getSelfType()),103 v.recurOnOptionOfSelfType(that.getSelfType()), 104 104 v.recurOnListOfBaseType(NodeUtil.getExcludesClause(that)), 105 105 v.recurOnOptionOfListOfNamedType(NodeUtil.getComprisesClause(that))); … … 126 126 that.getInfo(), 127 127 header, 128 v.recurOnOptionOf Type(that.getSelfType()),128 v.recurOnOptionOfSelfType(that.getSelfType()), 129 129 v.recurOnOptionOfListOfParam(NodeUtil.getParams(that))); 130 130 } -
trunk/ProjectFortress/src/com/sun/fortress/compiler/index/Coercion.java
r4291 r4311 65 65 66 66 // Return type always a TraitType inserted by CoercionLifter. 67 final TraitType returnType = (TraitType) NodeUtil.getReturnType(ast).unwrap(); 67 Type returnTy = NodeUtil.getReturnType(ast).unwrap(); 68 final TraitType returnType; 69 if (returnTy instanceof TraitSelfType) 70 returnType = (TraitType)((TraitSelfType)returnTy).getNamed(); 71 else returnType = (TraitType) returnTy; 72 68 73 69 74 _lifted = true; -
trunk/ProjectFortress/src/com/sun/fortress/compiler/index/DeclaredMethod.java
r4291 r4311 35 35 private final FnDecl _ast; 36 36 private final Id _declaringTrait; 37 private final Option< Type> _selfType;37 private final Option<SelfType> _selfType; 38 38 39 39 public DeclaredMethod(FnDecl ast, TraitObjectDecl traitDecl) { … … 52 52 _ast = (FnDecl) that._ast.accept(visitor); 53 53 _declaringTrait = that._declaringTrait; 54 _selfType = visitor.recurOnOptionOf Type(that._selfType);54 _selfType = visitor.recurOnOptionOfSelfType(that._selfType); 55 55 56 56 _thunk = that._thunk; … … 109 109 } 110 110 111 public Option< Type> selfType() {111 public Option<SelfType> selfType() { 112 112 return _selfType; 113 113 } -
trunk/ProjectFortress/src/com/sun/fortress/compiler/index/FieldGetterOrSetterMethod.java
r4291 r4311 36 36 protected final Binding _ast; 37 37 protected final Id _declaringTrait; 38 protected final Option< Type> _selfType;38 protected final Option<SelfType> _selfType; 39 39 protected final Option<FnDecl> _fnDecl; 40 40 … … 61 61 _ast = (Binding) that._ast.accept(visitor); 62 62 _declaringTrait = that._declaringTrait; 63 _selfType = visitor.recurOnOptionOf Type(that._selfType);63 _selfType = visitor.recurOnOptionOfSelfType(that._selfType); 64 64 if (that._fnDecl.isSome()) { 65 65 _fnDecl = Option.some((FnDecl) that._fnDecl.unwrap().accept(visitor)); … … 106 106 } 107 107 108 public Option< Type> selfType() {108 public Option<SelfType> selfType() { 109 109 return _selfType; 110 110 } -
trunk/ProjectFortress/src/com/sun/fortress/compiler/index/FunctionalMethod.java
r4291 r4311 42 42 protected final Id _declaringTrait; 43 43 protected final List<StaticParam> _traitParams; 44 protected final Option< Type> _selfType;44 protected final Option<SelfType> _selfType; 45 45 protected final int _selfPosition; 46 46 … … 68 68 _declaringTrait = that._declaringTrait; 69 69 _traitParams = visitor.recurOnListOfStaticParam(that._traitParams); 70 _selfType = visitor.recurOnOptionOf Type(that._selfType);70 _selfType = visitor.recurOnOptionOfSelfType(that._selfType); 71 71 _selfPosition = that._selfPosition; 72 72 … … 169 169 } 170 170 171 public Option< Type> selfType() {171 public Option<SelfType> selfType() { 172 172 return _selfType; 173 173 } -
trunk/ProjectFortress/src/com/sun/fortress/compiler/index/HasSelfType.java
r4094 r4311 18 18 package com.sun.fortress.compiler.index; 19 19 20 import com.sun.fortress.nodes. Type;20 import com.sun.fortress.nodes.SelfType; 21 21 import com.sun.fortress.nodes.Id; 22 22 import edu.rice.cs.plt.tuple.Option; … … 28 28 public interface HasSelfType { 29 29 public Id declaringTrait(); 30 public Option< Type> selfType();30 public Option<SelfType> selfType(); 31 31 public int selfPosition(); 32 32 } -
trunk/ProjectFortress/src/com/sun/fortress/compiler/index/TraitIndex.java
r4309 r4311 57 57 } 58 58 59 public Option< Type> typeOfSelf() {59 public Option<SelfType> typeOfSelf() { 60 60 if (this.ast() instanceof TraitObjectDecl) { 61 61 return ((TraitObjectDecl) this.ast()).getSelfType(); 62 62 } 63 return Option.< Type>none();63 return Option.<SelfType>none(); 64 64 } 65 65 -
trunk/ProjectFortress/src/com/sun/fortress/compiler/typechecker/TypeAnalyzer.java
r4280 r4311 268 268 Type outer_result = (Type) outer_t.accept(new NodeUpdateVisitor() { 269 269 270 @Override public BaseType forTraitSelfTypeOnly(TraitSelfType t, 271 TypeInfo i, 272 BaseType named, 273 List<NamedType> comprised) { 274 return (BaseType) named.accept(this); 275 } 276 277 @Override public Type forObjectExprTypeOnly(ObjectExprType t, 278 TypeInfo i, 279 List<BaseType> extended) { 280 Type result = mt(extended, history); 281 return t.equals(result) ? t : result; 282 } 283 270 284 @Override public BaseType forTraitTypeOnly(TraitType t, 271 285 TypeInfo i, … … 607 621 result = sub_type.accept(new NodeAbstractVisitor<ConstraintFormula>() { 608 622 @Override public ConstraintFormula forType(Type s) { return falseFormula(); } 623 @Override public ConstraintFormula forTraitSelfType(TraitSelfType s) { 624 return s.getNamed().accept(this); 625 } 626 @Override public ConstraintFormula forObjectExprType(ObjectExprType s) { 627 return intersectionSub(NodeFactory.makeIntersectionType(s.getExtended()), 628 super_type, h); 629 } 609 630 @Override public ConstraintFormula forTraitType(TraitType s) { 610 631 if (super_type instanceof TraitType) { -
trunk/ProjectFortress/src/com/sun/fortress/compiler/typechecker/TypeAnalyzerJUTest.java
r4280 r4311 38 38 import com.sun.fortress.compiler.index.*; 39 39 import com.sun.fortress.compiler.typechecker.constraints.ConstraintFormula; 40 import com.sun.fortress.nodes.APIName; 41 import com.sun.fortress.nodes.Api; 42 import com.sun.fortress.nodes.BaseType; 43 import com.sun.fortress.nodes.Component; 44 import com.sun.fortress.nodes.Decl; 45 import com.sun.fortress.nodes.Effect; 46 import com.sun.fortress.nodes.Id; 47 import com.sun.fortress.nodes.IdOrOpOrAnonymousName; 48 import com.sun.fortress.nodes.Import; 49 import com.sun.fortress.nodes.KeywordType; 50 import com.sun.fortress.nodes.StaticParam; 51 import com.sun.fortress.nodes.TraitDecl; 52 import com.sun.fortress.nodes.TraitTypeWhere; 53 import com.sun.fortress.nodes.Type; 54 import com.sun.fortress.nodes.VarDecl; 55 import com.sun.fortress.nodes.WhereClause; 40 import com.sun.fortress.nodes.*; 56 41 import com.sun.fortress.nodes_util.NodeFactory; 57 42 import com.sun.fortress.nodes_util.NodeUtil; … … 496 481 ast = NodeFactory.makeTraitDecl(span, NodeFactory.makeId(span, name), 497 482 Collections.<StaticParam>emptyList(), 498 extendsClause, Option.< Type>none());483 extendsClause, Option.<SelfType>none()); 499 484 } 500 485 else { 501 486 ast = NodeFactory.makeTraitDecl(span, NodeFactory.makeId(span, name), 502 487 Collections.<StaticParam>emptyList(), 503 extendsClause, Option.< Type>none());488 extendsClause, Option.<SelfType>none()); 504 489 } 505 490 return new ProperTraitIndex(ast, -
trunk/ProjectFortress/src/com/sun/fortress/compiler/typechecker/TypeAnalyzerUtil.java
r4280 r4311 191 191 return t.getName().getApiName().isNone() && names.contains(t.getName()); 192 192 } 193 @Override public Boolean forTraitSelfType(TraitSelfType t) { 194 return t.getNamed().accept(this); 195 } 193 196 @Override public Boolean forTraitType(TraitType t) { 194 197 for (StaticArg arg : t.getArgs()) { -
trunk/ProjectFortress/src/com/sun/fortress/compiler/typechecker/TypeCheckerTestCase.java
r3963 r4311 28 28 29 29 import com.sun.fortress.compiler.index.*; 30 import com.sun.fortress.nodes.ArrowType; 31 import com.sun.fortress.nodes.Decl; 32 import com.sun.fortress.nodes.Id; 33 import com.sun.fortress.nodes.TraitType; 34 import com.sun.fortress.nodes.NodeAbstractVisitor; 35 import com.sun.fortress.nodes.Param; 36 import com.sun.fortress.nodes.IdOrOpOrAnonymousName; 37 import com.sun.fortress.nodes.StaticArg; 38 import com.sun.fortress.nodes.StaticParam; 39 import com.sun.fortress.nodes.TraitDecl; 40 import com.sun.fortress.nodes.BaseType; 41 import com.sun.fortress.nodes.TraitTypeWhere; 42 import com.sun.fortress.nodes.TupleType; 43 import com.sun.fortress.nodes.Type; 44 import com.sun.fortress.nodes.WhereClause; 30 import com.sun.fortress.nodes.*; 45 31 import com.sun.fortress.nodes_util.NodeFactory; 46 32 import com.sun.fortress.nodes_util.Span; … … 90 76 } 91 77 TraitDecl ast = NodeFactory.makeTraitDecl(span, NodeFactory.makeId(span, name), sparams, 92 extendsClause, Option.< Type>none());78 extendsClause, Option.<SelfType>none()); 93 79 return new ProperTraitIndex(ast, 94 80 Collections.<Id, Method>emptyMap(), -
trunk/ProjectFortress/src/com/sun/fortress/compiler/typechecker/TypeNormalizer.java
r4275 r4311 56 56 ASTNodeInfo info, 57 57 TraitTypeHeader header, 58 Option< Type> selfType,58 Option<SelfType> selfType, 59 59 List<BaseType> excludesClause, 60 60 Option<List<NamedType>> comprises) { -
trunk/ProjectFortress/src/com/sun/fortress/compiler/typechecker/TypesUtil.java
r3928 r4311 32 32 import com.sun.fortress.compiler.Types; 33 33 import com.sun.fortress.compiler.typechecker.constraints.ConstraintFormula; 34 import com.sun.fortress.nodes.AnyType; 35 import com.sun.fortress.nodes.ArrayType; 36 import com.sun.fortress.nodes.ArrowType; 37 import com.sun.fortress.nodes.BottomType; 38 import com.sun.fortress.nodes.Id; 39 import com.sun.fortress.nodes.IdOrOp; 40 import com.sun.fortress.nodes.IntersectionType; 41 import com.sun.fortress.nodes.KindBool; 42 import com.sun.fortress.nodes.KindDim; 43 import com.sun.fortress.nodes.KindInt; 44 import com.sun.fortress.nodes.KindNat; 45 import com.sun.fortress.nodes.KindOp; 46 import com.sun.fortress.nodes.KindType; 47 import com.sun.fortress.nodes.KindUnit; 48 import com.sun.fortress.nodes.MatrixType; 49 import com.sun.fortress.nodes.Node; 50 import com.sun.fortress.nodes.NodeAbstractVisitor; 51 import com.sun.fortress.nodes.NodeDepthFirstVisitor; 52 import com.sun.fortress.nodes.NodeDepthFirstVisitor_void; 53 import com.sun.fortress.nodes.ObjectExpr; 54 import com.sun.fortress.nodes.Op; 55 import com.sun.fortress.nodes.OutAfterTypeChecking; 56 import com.sun.fortress.nodes.WhereClause; 57 import com.sun.fortress.nodes.StaticArg; 58 import com.sun.fortress.nodes.StaticParam; 59 import com.sun.fortress.nodes.TraitType; 60 import com.sun.fortress.nodes.TraitTypeWhere; 61 import com.sun.fortress.nodes.Type; 62 import com.sun.fortress.nodes.TypeAbstractVisitor; 63 import com.sun.fortress.nodes.UnionType; 34 import com.sun.fortress.nodes.*; 64 35 import com.sun.fortress.nodes._InferenceVarType; 65 36 import com.sun.fortress.nodes_util.ExprFactory; … … 477 448 478 449 /** 479 * Given an ObjectExpr, returns the Type of the expression.480 * @return481 */482 public static Type getObjectExprType(ObjectExpr obj) {483 List<Type> extends_types = CollectUtil.makeList(IterUtil.map(NodeUtil.getExtendsClause(obj),484 new Lambda<TraitTypeWhere,Type>(){485 public Type value(TraitTypeWhere arg0) {486 return arg0.getBaseType();487 }}));488 Type self_type =489 extends_types.isEmpty() ?490 Types.OBJECT :491 Types.makeIntersection(extends_types);492 return self_type;493 }494 495 /**496 450 * Take a node with _InferenceVarType, and TypeCheckerResults, which containt 497 451 * constraints on those inference vars, solve, and replace the inference vars -
trunk/ProjectFortress/src/com/sun/fortress/interpreter/evaluator/EvalType.java
r4260 r4311 55 55 } 56 56 57 public FType evalType(TraitSelfType t) { 58 return evalType(t.getNamed()); 59 } 60 57 61 // Returns the type that has the same name as the trait, in this 58 62 // environment (used in unification). … … 517 521 public FType forAnyType(AnyType a) { 518 522 return FTypeTop.ONLY; 523 } 524 525 public FType forTraitSelfType(TraitSelfType x) { 526 return x.getNamed().accept(this); 527 } 528 529 public FType forObjectExprType(ObjectExprType x) { 530 List<BaseType> extended = x.getExtended(); 531 if (!extended.isEmpty()) 532 return extended.get(0).accept(this); 533 else return NI.nyi("Can't interpret an empty intersection type."); 519 534 } 520 535 -
trunk/ProjectFortress/src/com/sun/fortress/interpreter/evaluator/ScoutVisitor.java
r4002 r4311 66 66 // TODO Auto-generated method stub 67 67 super.forVarType(that); 68 } 69 70 @Override 71 public void forTraitSelfType(TraitSelfType that) { 72 // TODO Auto-generated method stub 73 super.forTraitSelfType(that); 68 74 } 69 75 -
trunk/ProjectFortress/src/com/sun/fortress/interpreter/evaluator/types/FTraitOrObject.java
r4169 r4311 271 271 BoundingMap<String, FType, TypeLatticeOps> abm, 272 272 Type val) { 273 if (val instanceof TraitSelfType) 274 val = ((TraitSelfType)val).getNamed(); 273 275 if (DUMP_UNIFY) System.out.println("unify GT/O " + this + " and " + val + " abm= " + abm); 274 276 if (!(val instanceof TraitType)) { -
trunk/ProjectFortress/src/com/sun/fortress/nodes_util/ErrorMsgMaker.java
r4296 r4311 310 310 } 311 311 312 public String forTraitSelfType(TraitSelfType node) { 313 //return "SelfType " + node.getNamed().accept(this); 314 return node.getNamed().accept(this); 315 } 316 317 public String forObjectExprType(ObjectExprType node) { 318 // Could use U+2227 = AND if we supported Unicode output 319 //return "AND" + Useful.listInParens(mapSelf(node.getExtended())); 320 List<BaseType> extended = node.getExtended(); 321 if (extended.size() == 1) 322 return extended.get(0).accept(this); 323 else 324 return "AND" + Useful.listInParens(mapSelf(node.getExtended())); 325 } 326 312 327 public String forTraitType(TraitType node) { 313 328 String constructorName = NodeUtil.shortNameString(node.getName()); -
trunk/ProjectFortress/src/com/sun/fortress/nodes_util/ExprFactory.java
r4300 r4311 948 948 List<TraitTypeWhere> extendsC, 949 949 List<Decl> decls, 950 Option< Type> selfType) {950 Option<SelfType> selfType) { 951 951 return makeObjectExpr(span, false, Option.<Type>none(), 952 952 extendsC, decls, selfType); … … 958 958 List<TraitTypeWhere> extendsC, 959 959 List<Decl> decls, 960 Option< Type> selfType) {960 Option<SelfType> selfType) { 961 961 TraitTypeHeader header = NodeFactory.makeTraitTypeHeader(NodeFactory.makeId(span, "_"), 962 962 extendsC, decls); … … 968 968 Option<Type> ty, 969 969 TraitTypeHeader header, 970 Option< Type> selfType) {970 Option<SelfType> selfType) { 971 971 ExprInfo info = NodeFactory.makeExprInfo(span, parenthesized, ty); 972 972 return new ObjectExpr(info, header, selfType); -
trunk/ProjectFortress/src/com/sun/fortress/nodes_util/NodeComparator.java
r4260 r4311 354 354 static int compare(OpArg left, OpArg right) { 355 355 return compare(left.getName().getOriginalName(), right.getName().getOriginalName()); 356 } 357 358 static int compare(TraitSelfType left, TraitSelfType right) { 359 int c = compare(left.getNamed(), right.getNamed()); 360 if (c != 0) return c; 361 return typeListComparer.compare(left.getComprised(), 362 right.getComprised()); 363 } 364 365 static int compare(ObjectExprType left, ObjectExprType right) { 366 return typeListComparer.compare(left.getExtended(), 367 right.getExtended()); 356 368 } 357 369 … … 410 422 if (left instanceof TraitType) { 411 423 return compare((TraitType) left, (TraitType) right); 424 } else if (left instanceof TraitSelfType) { 425 return subtypeCompareTo(((TraitSelfType)left).getNamed(), 426 ((TraitSelfType)right).getNamed()); 427 } else if (left instanceof ObjectExprType) { 428 int x = typeListComparer.compare(((ObjectExprType)left).getExtended(), 429 ((ObjectExprType)right).getExtended()); 430 return x; 412 431 } else if (left instanceof TupleType) { 413 432 if ( NodeUtil.isVoidType((TupleType)left) ) -
trunk/ProjectFortress/src/com/sun/fortress/nodes_util/NodeFactory.java
r4296 r4311 295 295 excludesC, 296 296 comprisesC, 297 Option.< Type>some(selfType));297 Option.<SelfType>some(makeSelfType(selfType))); 298 298 } 299 299 … … 302 302 List<StaticParam> sparams, 303 303 List<TraitTypeWhere> extendsC, 304 Option< Type> selfType) {304 Option<SelfType> selfType) { 305 305 return makeTraitDecl(span, Modifiers.None, name, 306 306 sparams, extendsC, Option.<WhereClause>none(), … … 317 317 List<BaseType> excludesC, 318 318 Option<List<NamedType>> comprisesC, 319 Option< Type> selfType) {319 Option<SelfType> selfType) { 320 320 return makeTraitDecl(span, mods, name, sparams, extendsC, whereC, decls, 321 321 excludesC, comprisesC, false, selfType); … … 330 330 Option<List<NamedType>> comprisesC, 331 331 boolean comprisesEllipses, 332 Option< Type> selfType) {332 Option<SelfType> selfType) { 333 333 TraitTypeHeader header = makeTraitTypeHeader(mods, name, sparams, whereC, 334 334 Option.<List<Type>>none(), … … 343 343 Option<List<NamedType>> comprisesC, 344 344 boolean comprisesEllipses, 345 Option< Type> selfType) {345 Option<SelfType> selfType) { 346 346 return new TraitDecl(info, header, selfType, excludesC, comprisesC, comprisesEllipses); 347 347 } … … 350 350 List<TraitTypeWhere> extendsC, 351 351 List<Decl> decls, 352 Option< Type> selfType) {352 Option<SelfType> selfType) { 353 353 return makeObjectDecl(span, Modifiers.None, name, 354 354 Collections.<StaticParam>emptyList(), … … 362 362 public static ObjectDecl makeObjectDecl(Span span, Id name, 363 363 Option<List<Param>> params, 364 Option< Type> selfType) {364 Option<SelfType> selfType) { 365 365 return makeObjectDecl(span, Modifiers.None, name, 366 366 Collections.<StaticParam>emptyList(), … … 378 378 List<Decl> decls, 379 379 Option<List<Param>> params, 380 Option< Type> selfType) {380 Option<SelfType> selfType) { 381 381 return makeObjectDecl(span, Modifiers.None, name, 382 382 sparams, extendsC, … … 390 390 List<TraitTypeWhere> extendsC) { 391 391 return makeObjectDecl(NodeUtil.getSpan(selfType), 392 Modifiers.None,393 selfType.getName(),394 NodeUtil.getStaticParams(selfType),395 extendsC,396 Option.<WhereClause>none(),397 Collections.<Decl>emptyList(),398 Option.<List<Param>>none(),399 Option.<List<Type>>none(),400 Option.<Contract>none(),401 Option.<Type>some(selfType));392 Modifiers.None, 393 selfType.getName(), 394 NodeUtil.getStaticParams(selfType), 395 extendsC, 396 Option.<WhereClause>none(), 397 Collections.<Decl>emptyList(), 398 Option.<List<Param>>none(), 399 Option.<List<Type>>none(), 400 Option.<Contract>none(), 401 Option.<SelfType>some(makeSelfType(selfType))); 402 402 } 403 403 … … 410 410 Option<List<Type>> throwsC, 411 411 Option<Contract> contract, 412 Option< Type> selfType) {412 Option<SelfType> selfType) { 413 413 TraitTypeHeader header = makeTraitTypeHeader(mods, name, sparams, whereC, 414 414 throwsC, contract, extendsC, … … 875 875 } 876 876 877 public static ObjectExprType makeObjectExprType(List<BaseType> extended) { 878 return makeObjectExprType(NodeUtil.spanAll(extended), false, extended); 879 } 880 881 public static ObjectExprType makeObjectExprType(Span span, boolean parenthesized, 882 List<BaseType> extended) { 883 TypeInfo info = makeTypeInfo(span, parenthesized); 884 return new ObjectExprType(info, extended); 885 } 886 887 public static SelfType makeSelfType(TraitType self) { 888 return makeTraitSelfType(NodeUtil.getSpan(self), false, 889 self, Collections.<NamedType>emptyList()); 890 } 891 892 public static SelfType makeSelfType(TraitType self, List<NamedType> comprised) { 893 return makeTraitSelfType(NodeUtil.getSpan(self), false, self, comprised); 894 } 895 896 public static SelfType makeTraitSelfType(Span span, boolean parenthesized, 897 BaseType self, List<NamedType> comprised) { 898 TypeInfo info = makeTypeInfo(span, parenthesized); 899 return new TraitSelfType(info, self, comprised); 900 } 901 877 902 public static TraitType makeTraitType(TraitType original) { 878 903 return makeTraitType(NodeUtil.getSpan(original), NodeUtil.isParenthesized(original), … … 2144 2169 return makeMatrixType(NodeUtil.getSpan(t), true, t.getElemType(), 2145 2170 t.getDimensions()); 2171 } 2172 public Type forTraitSelfType(TraitSelfType t) { 2173 return makeTraitSelfType(NodeUtil.getSpan(t), true, 2174 t.getNamed(), t.getComprised()); 2175 } 2176 public Type forObjectExprType(ObjectExprType t) { 2177 return makeObjectExprType(NodeUtil.getSpan(t), true, t.getExtended()); 2146 2178 } 2147 2179 public Type forTraitType(TraitType t) { -
trunk/ProjectFortress/src/com/sun/fortress/parser/DelimitedExpr.rats
r4080 r4311 57 57 { if (a1 == null) a1 = Collections.<TraitTypeWhere>emptyList(); 58 58 if (a2 == null) a2 = Collections.<Decl>emptyList(); 59 yyValue = ExprFactory.makeObjectExpr(createSpan(yyStart,yyCount), a1, a2, Option.<Type>none()); 59 yyValue = ExprFactory.makeObjectExpr(createSpan(yyStart,yyCount), 60 a1, a2, Option.<SelfType>none()); 60 61 } 61 62 / Do -
trunk/ProjectFortress/src/com/sun/fortress/parser/TraitObject.rats
r3986 r4311 49 49 a4, a3.getExcludes(), 50 50 a3.getComprises(), a3.getEllipses(), 51 Option.< Type>none());51 Option.<SelfType>none()); 52 52 }; 53 53 … … 141 141 fhc.getThrowsClause(), 142 142 fhc.getContractClause(), 143 Option.< Type>none());143 Option.<SelfType>none()); 144 144 }; 145 145 … … 227 227 a4, a3.getExcludes(), 228 228 a3.getComprises(), a3.getEllipses(), 229 Option.< Type>none());229 Option.<SelfType>none()); 230 230 }; 231 231 … … 293 293 fhc.getThrowsClause(), 294 294 fhc.getContractClause(), 295 Option.< Type>none());295 Option.<SelfType>none()); 296 296 }; 297 297 -
trunk/ProjectFortress/src/com/sun/fortress/repository/ForeignJava.java
r4291 r4311 395 395 excludesC, 396 396 comprisesC, 397 Option.<com.sun.fortress.nodes. Type>none());397 Option.<com.sun.fortress.nodes.SelfType>none()); 398 398 // Need to fake up an API for this class, too. 399 399 classToTraitDecl.put(imported_class, td); -
trunk/ProjectFortress/src/com/sun/fortress/scala_src/disambiguator/SelfParamDisambiguator.scala
r4259 r4311 52 52 case SObjectDecl(_, STraitTypeHeader(sparams,_,name,_,_,_,_,_), _, _) => 53 53 // Add a type to self parameters of methods 54 val self_type = NF.make TraitType(name.asInstanceOf[Id],55 TypeEnv.staticParamsToArgs(toJavaList(sparams)))54 val self_type = NF.makeSelfType(NF.makeTraitType(name.asInstanceOf[Id], 55 TypeEnv.staticParamsToArgs(toJavaList(sparams)))) 56 56 replaceSelfParamsWithType(node, self_type).asInstanceOf[ObjectDecl] match { 57 57 case SObjectDecl(info, header, _, params) => … … 71 71 _, _, comprisesC, _) => 72 72 // Add a type to self parameters of methods 73 var self_type: Type = NF.makeTraitType(name.asInstanceOf[Id], 74 TypeEnv.staticParamsToArgs(toJavaList(sparams))) 75 comprisesC match { 76 case Some(comprises@_::_) => 77 self_type = NF.makeIntersectionType(self_type, 78 NF.makeMaybeUnionType(toJavaList(comprises))) 79 case _ => 73 val type_name = NF.makeTraitType(name.asInstanceOf[Id], 74 TypeEnv.staticParamsToArgs(toJavaList(sparams))) 75 val self_type = comprisesC match { 76 case Some(comprises@_::_) => NF.makeSelfType(type_name, toJavaList(comprises)) 77 case _ => NF.makeSelfType(type_name) 78 80 79 } 81 80 replaceSelfParamsWithType(node, self_type).asInstanceOf[TraitDecl] match { … … 87 86 case oe@SObjectExpr(_, STraitTypeHeader(sparams,_,name,_,_,_,_,_), _) => 88 87 // Add a type to self parameters of methods 89 val self_type = TypesUtil.getObjectExprType(oe)88 val self_type = getObjectExprType(oe) 90 89 replaceSelfParamsWithType(oe, self_type) match { 91 90 case SObjectExpr(info, header, _) => … … 103 102 * @param self_type 104 103 */ 105 def replaceSelfParamsWithType(that_node: Any, self_type: Type): Node = {104 def replaceSelfParamsWithType(that_node: Any, self_type: SelfType): Node = { 106 105 object replacer extends Walker { 107 106 var traitNestingDepth = 0 -
trunk/ProjectFortress/src/com/sun/fortress/scala_src/linker/HygienicRenamer.scala
r4296 r4311 140 140 SLValue(walk(getInfo).asInstanceOf[com.sun.fortress.nodes.ASTNodeInfo], walk(getName).asInstanceOf[com.sun.fortress.nodes.Id], walk(getMods).asInstanceOf[com.sun.fortress.nodes_util.Modifiers], walk(getIdType).asInstanceOf[Option[com.sun.fortress.nodes.Type]], walk(isMutable).asInstanceOf[Boolean]) 141 141 case SObjectDecl(getInfo, getHeader, getParams, getSelfType) => 142 SObjectDecl(walk(getInfo).asInstanceOf[com.sun.fortress.nodes.ASTNodeInfo], walk(getHeader).asInstanceOf[com.sun.fortress.nodes.TraitTypeHeader], walk(getSelfType).asInstanceOf[Option[com.sun.fortress.nodes. Type]], walk(getParams).asInstanceOf[Option[List[com.sun.fortress.nodes.Param]]])142 SObjectDecl(walk(getInfo).asInstanceOf[com.sun.fortress.nodes.ASTNodeInfo], walk(getHeader).asInstanceOf[com.sun.fortress.nodes.TraitTypeHeader], walk(getSelfType).asInstanceOf[Option[com.sun.fortress.nodes.SelfType]], walk(getParams).asInstanceOf[Option[List[com.sun.fortress.nodes.Param]]]) 143 143 case SObjectExpr(getInfo, getHeader, getSelfType) => 144 SObjectExpr(walk(getInfo).asInstanceOf[com.sun.fortress.nodes.ExprInfo], walk(getHeader).asInstanceOf[com.sun.fortress.nodes.TraitTypeHeader], walk(getSelfType).asInstanceOf[Option[com.sun.fortress.nodes. Type]])144 SObjectExpr(walk(getInfo).asInstanceOf[com.sun.fortress.nodes.ExprInfo], walk(getHeader).asInstanceOf[com.sun.fortress.nodes.TraitTypeHeader], walk(getSelfType).asInstanceOf[Option[com.sun.fortress.nodes.SelfType]]) 145 145 case SOp(getInfo, getApiName, getText, getFixity, isEnclosing) => 146 146 SOp(walk(getInfo).asInstanceOf[com.sun.fortress.nodes.ASTNodeInfo], walk(getApiName).asInstanceOf[Option[com.sun.fortress.nodes.APIName]], walk(getText).asInstanceOf[String], walk(getFixity).asInstanceOf[com.sun.fortress.nodes.Fixity], walk(isEnclosing).asInstanceOf[Boolean]) … … 202 202 STokenSymbol(walk(getInfo).asInstanceOf[com.sun.fortress.nodes.ASTNodeInfo], walk(getToken).asInstanceOf[String]) 203 203 case STraitDecl(getInfo, getHeader, getExcludesClause, getComprisesClause, isComprisesEllipses, getSelfType) => 204 STraitDecl(walk(getInfo).asInstanceOf[com.sun.fortress.nodes.ASTNodeInfo], walk(getHeader).asInstanceOf[com.sun.fortress.nodes.TraitTypeHeader], walk(getSelfType).asInstanceOf[Option[com.sun.fortress.nodes.Type]], walk(getExcludesClause).asInstanceOf[List[com.sun.fortress.nodes.BaseType]], walk(getComprisesClause).asInstanceOf[Option[List[com.sun.fortress.nodes.NamedType]]], walk(isComprisesEllipses).asInstanceOf[Boolean]) 204 STraitDecl(walk(getInfo).asInstanceOf[com.sun.fortress.nodes.ASTNodeInfo], walk(getHeader).asInstanceOf[com.sun.fortress.nodes.TraitTypeHeader], walk(getSelfType).asInstanceOf[Option[com.sun.fortress.nodes.SelfType]], walk(getExcludesClause).asInstanceOf[List[com.sun.fortress.nodes.BaseType]], walk(getComprisesClause).asInstanceOf[Option[List[com.sun.fortress.nodes.NamedType]]], walk(isComprisesEllipses).asInstanceOf[Boolean]) 205 case STraitSelfType(getInfo, getNamed, getComprised) => 206 STraitSelfType(walk(getInfo).asInstanceOf[com.sun.fortress.nodes.TypeInfo], 207 walk(getNamed).asInstanceOf[com.sun.fortress.nodes.BaseType], 208 walk(getComprised).asInstanceOf[List[com.sun.fortress.nodes.NamedType]]) 209 case SObjectExprType(getInfo, getExtended) => 210 SObjectExprType(walk(getInfo).asInstanceOf[com.sun.fortress.nodes.TypeInfo], 211 walk(getExtended).asInstanceOf[List[com.sun.fortress.nodes.BaseType]]) 205 212 case STraitType(getInfo, getName, getArgs, getStaticParams) => 206 213 STraitType(walk(getInfo).asInstanceOf[com.sun.fortress.nodes.TypeInfo], walk(getName).asInstanceOf[com.sun.fortress.nodes.Id], walk(getArgs).asInstanceOf[List[com.sun.fortress.nodes.StaticArg]], walk(getStaticParams).asInstanceOf[List[com.sun.fortress.nodes.StaticParam]]) -
trunk/ProjectFortress/src/com/sun/fortress/scala_src/typechecker/CoercionOracle.scala
r4296 r4311 88 88 89 89 /** The set of all arrow types for coercions from types T to U. */ 90 def getCoercionsTo(u: Type): Set[LiftedCoercion] = { 90 def getCoercionsTo(uu: Type): Set[LiftedCoercion] = { 91 val u = 92 if (uu.isInstanceOf[TraitSelfType] && 93 uu.asInstanceOf[TraitSelfType].getNamed.isInstanceOf[TraitType]) 94 uu.asInstanceOf[TraitSelfType].getNamed.asInstanceOf[TraitType] 95 else uu 96 91 97 if (!u.isInstanceOf[TraitType]) return Set() 92 98 … … 144 150 : Option[Option[CoercionInvocation]] = (t, u) match { 145 151 case (_, u:TraitType) => checkCoercionTrait(t, u, expr) 152 case (_, u:TraitSelfType) => checkCoercion(t, u.getNamed, expr) 146 153 case (t:TupleType, u:TupleType) => checkCoercionTuple(t, u, expr) 147 154 case (t:ArrowType, u:ArrowType) => checkCoercionArrow(t, u, expr) -
trunk/ProjectFortress/src/com/sun/fortress/scala_src/typechecker/ExclusionOracle.scala
r4292 r4311 147 147 case (_:TupleType ,_) => true 148 148 case (_, _:TupleType) => true 149 case (f:TraitSelfType, s:TraitSelfType) => excludes(f.getNamed, s.getNamed) 150 case (f:ObjectExprType, s:ObjectExprType) => true 149 151 case (f:TraitType, s:TraitType) => 150 152 ( toOption(typeAnalyzer.traits.typeCons(f.getName)), … … 224 226 } 225 227 case STraitType(i,n,a,p) => STraitType(i, n, a.map(saSubst), p.map(spSubst)) 228 case STraitSelfType(i,n,ts) => 229 STraitSelfType(i, tySubst(n).asInstanceOf[BaseType], 230 ts.map(tySubst).asInstanceOf[List[NamedType]]) 231 case SObjectExprType(i,ts) => 232 SObjectExprType(i, ts.map(tySubst).asInstanceOf[List[TraitType]]) 226 233 case STupleType(i,e,v,k) => STupleType(i, e.map(tySubst), v, k) 227 234 case SArrowType(i,d,r,e,b,m) => SArrowType(i, tySubst(d), tySubst(r), e, b, m.map(miSubst)) -
trunk/ProjectFortress/src/com/sun/fortress/scala_src/typechecker/ExportChecker.scala
r4280 r4311 433 433 case (SVarType(_, nameL, _), SVarType(_, nameR, _)) => 434 434 equalIds(nameL, nameR) 435 case (STraitSelfType(_, namedL, tysL), 436 STraitSelfType(_, namedR, tysR)) => 437 equalTypes(namedL, namedR) && 438 equalListTypes(tysL, tysR) 439 case (SObjectExprType(_, tysL), SObjectExprType(_, tysR)) => 440 equalListTypes(tysL, tysR) 435 441 case (STraitType(_, nameL, argsL, paramsL), 436 442 STraitType(_, nameR, argsR, paramsR)) => -
trunk/ProjectFortress/src/com/sun/fortress/scala_src/typechecker/IndexBuilder.scala
r4275 r4311 236 236 excludes: List[BaseType], 237 237 comprises: Option[List[NamedType]], 238 self: Option[ Type]) = {238 self: Option[SelfType]) = { 239 239 val dIndex = typeConses.get(dName).asInstanceOf[ProperTraitIndex] 240 240 if ( comprises.isDefined ) { … … 252 252 // add d to t's excludes clause 253 253 typ = toOption(self) match { 254 case Some(ty) if (ty.isInstanceOf[TraitType]) => 255 ty.asInstanceOf[TraitType] 256 case Some(ty) if (ty.isInstanceOf[IntersectionType]) => 257 ty.asInstanceOf[IntersectionType].getElements.get(0).asInstanceOf[TraitType] 254 case Some(ty) if (ty.isInstanceOf[TraitSelfType] && 255 ty.asInstanceOf[TraitSelfType].getNamed.isInstanceOf[TraitType]) => 256 ty.asInstanceOf[TraitSelfType].getNamed.asInstanceOf[TraitType] 258 257 case _ => 259 258 NF.makeTraitType(dName.asInstanceOf[Id], -
trunk/ProjectFortress/src/com/sun/fortress/scala_src/typechecker/STypeChecker.scala
r4291 r4311 355 355 protected def assertTrait(t: BaseType, 356 356 msg: String, 357 error_loc: Node) = t match { 357 error_loc: Node): Unit = t match { 358 case tt:TraitSelfType => assertTrait(tt.getNamed, msg, error_loc) 358 359 case tt:TraitType => toOption(traits.typeCons(tt.getName)) match { 359 360 case Some(ti) if ti.isInstanceOf[ProperTraitIndex] => -
trunk/ProjectFortress/src/com/sun/fortress/scala_src/typechecker/TypeHierarchyChecker.scala
r4279 r4311 118 118 c.parameters.get(0).getIdType.unwrap match { 119 119 case STraitType(_,name,_,_) => kids = name::kids 120 case STraitSelfType(_,STraitType(_,name,_,_),_) => kids = name::kids 120 121 case _ => 121 122 } -
trunk/ProjectFortress/src/com/sun/fortress/scala_src/typechecker/TypeWellFormedChecker.scala
r4275 r4311 98 98 if ( ! analyzer.env.contains(name) ) 99 99 error("Unbound type: " + name, t) 100 case t@STraitSelfType(_, named, tys) => walk(named); tys.foreach(walk) 101 case t@SObjectExprType(_, tys) => tys.foreach(walk) 100 102 case t@STraitType(_, name, sargs, _) => 101 103 getTypes(name) match { … … 123 125 // Keyword parameters are not yet supported... 124 126 case STupleType(_, elements, varargs, keywords) => 125 elements.foreach( (t:Type) => walk(t))127 elements.foreach(walk) 126 128 varargs match { 127 129 case Some(ty) => walk(ty) … … 130 132 // Effects are not yet supported... 131 133 case SArrowType(_, domain, range, effect, io, _) => walk(domain); walk(range) 132 case SIntersectionType(_, elements) => elements.foreach( (t:Type) => walk(t))133 case SUnionType(_, elements) => elements.foreach( (t:Type) => walk(t))134 case SIntersectionType(_, elements) => elements.foreach(walk) 135 case SUnionType(_, elements) => elements.foreach(walk) 134 136 case _:LabelType => // OK 135 137 case _:DimBase => // OK -
trunk/ProjectFortress/src/com/sun/fortress/scala_src/typechecker/impls/Common.scala
r4309 r4311 145 145 */ 146 146 protected def traitTypesCallable(typ: Type): Set[TraitType] = typ match { 147 case t:TraitSelfType => traitTypesCallable(t.getNamed) 148 147 149 case t:TraitType => Set(t) 148 150 -
trunk/ProjectFortress/src/com/sun/fortress/scala_src/types/CoveringAnalyzer.scala
r4285 r4311 44 44 ta.meet(ts) 45 45 case SUnionType(_, e) => ta.join(e.map(minimize)) 46 case t:TraitSelfType => minimize(t.getNamed) 47 case t:ObjectExprType => t 46 48 case t:TraitType => ta.join(comprisesLeaves(t)) 47 49 //ToDo: Handle keywords -
trunk/ProjectFortress/src/com/sun/fortress/scala_src/types/TypeAnalyzer.scala
r4285 r4311 25 25 import com.sun.fortress.nodes._ 26 26 import com.sun.fortress.nodes_util.NodeFactory.typeSpan 27 import com.sun.fortress.nodes_util.{NodeFactory => NF} 27 28 import com.sun.fortress.scala_src.nodes._ 28 29 import com.sun.fortress.scala_src.typechecker.ConstraintFormula … … 54 55 def join(x: Iterable[Type]): Type = normalize(makeUnionType(x)) 55 56 56 def subtype(x: Type, y: Type): ConstraintFormula = sub(normalize(x), normalize(y)) 57 58 private def sub(x: Type, y: Type): ConstraintFormula = (x,y) match { 57 private def removeSelf(x: Type) = { 58 object remover extends Walker { 59 override def walk(y: Any): Any = y match { 60 case t:TraitSelfType => 61 if (t.getComprised.isEmpty) t.getNamed 62 else NF.makeIntersectionType(t.getNamed, 63 NF.makeMaybeUnionType(t.getComprised)) 64 case t:ObjectExprType => NF.makeIntersectionType(t.getExtended) 65 case _ => super.walk(y) 66 } 67 } 68 remover(x).asInstanceOf[Type] 69 } 70 71 def subtype(x: Type, y: Type): ConstraintFormula = 72 sub(normalize(removeSelf(x)), normalize(removeSelf(y))) 73 74 private def sub(x: Type, y: Type): ConstraintFormula = (x, y) match { 59 75 case (s,t) if (s==t) => TRUE 60 76 case (s: BottomType, _) => TRUE … … 151 167 152 168 153 def excludes(x: Type, y: Type) = exc(normalize(x), normalize(y)) 154 155 private def exc(x: Type, y: Type): Boolean = (x,y) match { 169 def excludes(x: Type, y: Type) = 170 exc(normalize(removeSelf(x)), normalize(removeSelf(y))) 171 172 private def exc(x: Type, y: Type): Boolean = (x, y) match { 156 173 case (s: BottomType, _) => true 157 174 case (_, t: BottomType) => true -
trunk/ProjectFortress/src/com/sun/fortress/scala_src/useful/SNodeUtil.scala
r4275 r4311 184 184 def getTraitType(ty: Type): Option[TraitType] = ty match { 185 185 case tt:TraitType => Some(tt) 186 case tt: IntersectionType => getTraitType(tt.getElements.get(0))186 case tt:TraitSelfType => getTraitType(tt.getNamed) 187 187 case _ => None 188 188 } -
trunk/ProjectFortress/src/com/sun/fortress/scala_src/useful/STypesUtil.scala
r4309 r4311 417 417 def checkSubtype(subtype: Type, supertype: Type) 418 418 (implicit analyzer: TypeAnalyzer): ConstraintFormula = { 419 419 420 val constraint = analyzer.subtype(subtype, supertype) 421 420 422 if (!constraint.isInstanceOf[ConstraintFormula]) { 421 423 bug("Not a ConstraintFormula.") … … 974 976 } 975 977 } 978 979 /** 980 * Given an ObjectExpr, returns the Type of the expression. 981 * @return 982 */ 983 def getObjectExprType(obj: ObjectExpr): SelfType = { 984 var extends_types = 985 toList(NU.getExtendsClause(obj)).map(_.getBaseType) 986 if (extends_types.isEmpty) extends_types = List(Types.OBJECT) 987 NF.makeObjectExprType(toJavaList(extends_types)) 988 } 989 976 990 } -
trunk/ProjectFortress/src/com/sun/fortress/syntax_abstractions/util/BaseTypeCollector.java
r4002 r4311 36 36 37 37 @Override 38 public String forTraitSelfType(TraitSelfType that) { 39 return that.getNamed().accept(this); 40 } 41 42 @Override 38 43 public String forTraitTypeOnly(TraitType that, 39 44 String info, -
trunk/ProjectFortress/src/com/sun/fortress/syntax_abstractions/util/FortressTypeToJavaType.java
r3998 r4311 38 38 39 39 @Override 40 public String forTraitSelfType(TraitSelfType that) { 41 return that.getNamed().accept(this); 42 } 43 44 @Override 40 45 public String forTraitType(TraitType that) { 41 46 if (that.getArgs().size() == 0) { -
trunk/ProjectFortress/src/com/sun/fortress/tools/FortressAstToConcrete.java
r4296 r4311 2122 2122 2123 2123 @Override 2124 public String forTraitSelfTypeOnly(TraitSelfType that, 2125 String info, 2126 String named_result, 2127 List<String> comprised_result) { 2128 return named_result; 2129 } 2130 2131 @Override 2132 public String forObjectExprTypeOnly(ObjectExprType that, 2133 String info, 2134 List<String> extended_result) { 2135 return "ObjectExprType"; 2136 } 2137 2138 @Override 2124 2139 public String forArrayTypeOnly(ArrayType that, String info, String type_result, String indices_result) { 2125 2140 StringBuilder s = new StringBuilder();

