@@ -887,29 +887,42 @@ protected SymbolData defineSymbolData(final TypeDefBase typeDefBase, final Strin
887887 // Create the LinkedList for the SymbolDatas of the interfaces
888888 final ArrayList <SymbolData > interfaces = new ArrayList <SymbolData >();
889889
890- // Get or create SymbolDatas (continuations) for the interfaces
890+ // Get or create SymbolDatas for the interfaces
891891 ReferenceType [] rts = typeDefBase .getInterfaces ();
892- for (final ReferenceType rt : rts ) {
893- SymbolData sD = _lookupTypeFromWithinClass (rt , enclosingClassName );
894- if (sD != null && ! sD .isInterface ()) {
895- sD .setInterface (true );
896- // System.err.println("Interface type = " + sD);
897- // assert false;
892+ for (int i = 0 ; i < rts .length ; i ++) {
893+ final ReferenceType rt = rts [i ];
894+ final String rtName = rt .getName ();
895+ boolean forwardRef = false ;
896+ SymbolData iD = _lookupTypeFromWithinClass (rt , enclosingClassName );
897+ if (iD != null && ! iD .isContinuation () && ! iD .isInterface ()) {
898+ _addError ("The symbol " + rtName + " is not an interface" , typeDefBase );
898899 }
899- interfaces .add (sD ); // Note: confirm that null can be added to an ArrayList
900- if (sD == null ) {
901- // create a fixup for this interface reference
900+ if (iD == null || iD .isContinuation ()) { // create a dummy symbol pending fixUp TODO: is this necessary?
901+ iD = new SymbolData (rtName );
902+ forwardRef = true ;
903+ }
904+
905+ interfaces .add (iD );
906+ if (forwardRef ) {
907+ // create a fixup for this interface slot
908+ final int j = i ;
902909 Command fixUp = new Command () {
903910 public void execute () {
904- SymbolData newSD = _lookupTypeFromWithinClass (rt , enclosingClassName );
905- assert newSD != null && newSD .isInterface (); // EXPAND
906- int lastIndex = interfaces .size () - 1 ;
907- interfaces .set (lastIndex , newSD );
911+ SymbolData newID = _lookupTypeFromWithinClass (rt , enclosingClassName );
912+ if (newID == null ) _addError ("The symbol " + rtName + " is not defined" , typeDefBase );
913+ else if (! newID .isInterface ())
914+ _addError ("The symbol " + rtName + " is not an interface" , typeDefBase );
915+ interfaces .set (j , newID );
916+ sd .addEnclosingData (newID );
908917 }
909918 };
910919 fixUps .add (fixUp );
911920 }
912921 }
922+
923+ // Set the inferfaces; fixups will be done on the elements of the interface ArrayList, but this does not
924+ // add the found interface to the enclosing data of sd.
925+ sd .setInterfaces (interfaces );
913926
914927 // Create SymbolData variable for superclass
915928 SymbolData superSD = null ;
@@ -918,39 +931,32 @@ public void execute() {
918931
919932 if (typeDefBase instanceof InterfaceDef ) {
920933 // set Object as the super class of this, so that it will know it implements Object's methods.
921- superSD = getSymbolData ("java.lang.Object" , typeDefBase .getSourceInfo (), false );
934+ SymbolData objectSD = getSymbolData ("java.lang.Object" , typeDefBase .getSourceInfo (), false );
922935 sd .setInterface (true );
923- sd .setSuperClass (superSD );
936+ sd .setSuperClass (objectSD );
924937 }
925938
926939 else if (typeDefBase instanceof ClassDef ) {
940+ sd .setInterface (false );
927941 ClassDef cd = (ClassDef ) typeDefBase ;
928942 final ReferenceType rt = cd .getSuperclass ();
929- superSD = _lookupTypeFromWithinClass (rt , enclosingClassName );
930- // if (superSD == null && rt.getName().equals("Object")) {
931- // System.err.println("ALARM: _lookupTypeFromWithinClass for 'Object' returned null");
932- // }
933- sd .setInterface (false );
943+ superSD = _lookupTypeFromWithinClass (rt , enclosingClassName );
934944
935945 if (superSD != null ) sd .setSuperClass (superSD );
936946 else {
937947 Command fixUp = new Command () {
938948 public void execute () {
939949 SymbolData newSuperSD = _lookupTypeFromWithinClass (rt , enclosingClassName );
940- // System.err.println("***** In a FIXUP, looking up type " + rt + " from within " + enclosingClassName);
941950 if (newSuperSD == null )
942- // newSuperSD = getSymbolData("java.lang.Object", typeDefBase.getSourceInfo(), false);
943- _addAndIgnoreError ("The class " + sd + " has an undefined superclass " + rt , typeDefBase );
944- else
951+ _addError ("The class " + sd + " has an undefined superclass " + rt , typeDefBase );
952+ else // TODO: Does not check that newSuperSD is not an interace
945953 sd .setSuperClass (newSuperSD );
946954 }
947955 };
948956 fixUps .add (fixUp );
949957 }
950958 }
951-
952- // Set the inferfaces; fixups will be done on the elements of the interface ArrayList
953- sd .setInterfaces (interfaces );
959+
954960
955961 // Remove symbol name from continuation table.
956962 _log .log ("REMOVING continuation " + qualifiedTypeName );
@@ -1091,16 +1097,16 @@ else if (superSD.isInterface()) {
10911097 protected VariableData [] formalParameters2VariableData (FormalParameter [] fps , SymbolData enclosing ) {
10921098 assert enclosing != null /* && (enclosing instanceof SymbolData || enclosing instanceof BlockData)*/ ;
10931099 // BodyData ::= MethodData | BlockData
1100+
10941101// Utilities.show("formalParameters2VariableData called on " + fps);
1095- // Should conssolidate with same method in FullJavadVisitor; almost identical
1102+ // Should consolidate with same method in FullJavadVisitor; almost identical
10961103 final VariableData [] varData = new VariableData [fps .length ];
10971104 final String enclosingClassName = enclosing .getName ();
10981105
1099- VariableDeclarator vd ;
11001106 String [] mav = getFormalParameterMav (enclosing );
11011107
1102- for (int i = 0 ; i < varData .length ; i ++) {
1103- vd = fps [i ].getDeclarator ();
1108+ for (int i = 0 ; i < fps .length ; i ++) {
1109+ VariableDeclarator vd = fps [i ].getDeclarator ();
11041110 String name = vd .getName ().getText (); // getName returns a Word
11051111
11061112 Type type = vd .getType ();
@@ -1118,6 +1124,9 @@ protected VariableData[] formalParameters2VariableData(FormalParameter[] fps, Sy
11181124 if (sd == null ) { // TODO !!!: can this happen?
11191125 // To establish a reference to a not-yet-defined type, create a fixup
11201126 final int j = i ;
1127+ /* The following is a kludge to make method signature collision detection work (unless different
1128+ * names are used for the same type). */
1129+ varData [j ].setType (new SymbolData (typeName ));
11211130 Command fixUp = new Command () {
11221131 public void execute () {
11231132 SymbolData newSd = _identifyType (typeName , si , enclosingClassName );
@@ -1132,7 +1141,6 @@ public void execute() {
11321141 varData [i ].gotValue ();
11331142 varData [i ].setIsLocalVariable (true );
11341143 }
1135-
11361144 return varData ;
11371145 }
11381146
0 commit comments