@@ -1984,7 +1984,6 @@ public ConstraintSet defaultCase(Type paramArg) {
19841984 // Note that this might be a capture variable with an inference-variable bound
19851985 if (vars .contains (param )) { return EMPTY_CONSTRAINTS .andLowerBound (param , arg ); }
19861986 else {
1987- debug .log ();
19881987 Thunk <ConstraintSet > recurOnLowerBound = new Thunk <ConstraintSet >() {
19891988 public ConstraintSet value () {
19901989 return arg .apply (new TypeAbstractVisitor <ConstraintSet >() {
@@ -2891,9 +2890,9 @@ public ConstructorInvocation value(DJConstructor k, SignatureChecker checker) {
28912890 });
28922891
28932892 // TODO: provide more error-message information
2894- if ( IterUtil .isEmpty (results )) { throw new UnmatchedLookupException (); }
2895- else if (IterUtil . sizeOf ( results ) > 1 ) { throw new UnmatchedLookupException (); }
2896- else { return results . iterator (). next ( ); }
2893+ int matches = IterUtil .sizeOf (results );
2894+ if (matches != 1 ) { throw new UnmatchedLookupException (matches ); }
2895+ else { return IterUtil . first ( results ); }
28972896 }
28982897
28992898 public boolean containsMethod (Type t , String name ) {
@@ -3049,9 +3048,9 @@ public ObjectMethodInvocation value(DJMethod m, SignatureChecker checker) {
30493048 new LookupMethod (true ),
30503049 new LookupMethod (false ));
30513050 // TODO: provide more error-message information
3052- if ( IterUtil .isEmpty (results )) { throw new UnmatchedLookupException (); }
3053- else if (IterUtil . sizeOf ( results ) > 1 ) { throw new UnmatchedLookupException (); }
3054- else { return results . iterator (). next ( ); }
3051+ int matches = IterUtil .sizeOf (results );
3052+ if (matches != 1 ) { throw new UnmatchedLookupException (matches ); }
3053+ else { return IterUtil . first ( results ); }
30553054 }
30563055
30573056 /**
@@ -3169,9 +3168,9 @@ public StaticMethodInvocation value(DJMethod m, SignatureChecker checker) {
31693168 Iterable <? extends StaticMethodInvocation > results = lookupMember (t , new LookupMethod (true ),
31703169 new LookupMethod (false ));
31713170 // TODO: provide more error-message information
3172- if ( IterUtil .isEmpty (results )) { throw new UnmatchedLookupException (); }
3173- else if (IterUtil . sizeOf ( results ) > 1 ) { throw new UnmatchedLookupException (); }
3174- else { return results . iterator (). next ( ); }
3171+ int matches = IterUtil .sizeOf (results );
3172+ if (matches != 1 ) { throw new UnmatchedLookupException (matches ); }
3173+ else { return IterUtil . first ( results ); }
31753174 }
31763175
31773176
@@ -3276,9 +3275,9 @@ private boolean validField(DJField f) {
32763275 new LookupField (true ),
32773276 new LookupField (false ));
32783277 // TODO: provide more error-message information
3279- if ( IterUtil .isEmpty (results )) { throw new UnmatchedLookupException (); }
3280- else if (IterUtil . sizeOf ( results ) > 1 ) { throw new UnmatchedLookupException (); }
3281- else { return results . iterator (). next ( ); }
3278+ int matches = IterUtil .sizeOf (results );
3279+ if (matches != 1 ) { throw new UnmatchedLookupException (matches ); }
3280+ else { return IterUtil . first ( results ); }
32823281 }
32833282
32843283
@@ -3342,9 +3341,9 @@ private boolean validField(DJField f) {
33423341 Iterable <? extends StaticFieldReference > results = lookupMember (t , new LookupField (true ),
33433342 new LookupField (false ));
33443343 // TODO: provide more error-message information
3345- if ( IterUtil .isEmpty (results )) { throw new UnmatchedLookupException (); }
3346- else if (IterUtil . sizeOf ( results ) > 1 ) { throw new UnmatchedLookupException (); }
3347- else { return results . iterator (). next ( ); }
3344+ int matches = IterUtil .sizeOf (results );
3345+ if (matches != 1 ) { throw new UnmatchedLookupException (matches ); }
3346+ else { return IterUtil . first ( results ); }
33483347 }
33493348
33503349
@@ -3415,20 +3414,23 @@ public ClassType lookupClass(Expression object, String name, Iterable<? extends
34153414 */
34163415 public ClassType lookupClass (Type t , final String name , Iterable <? extends Type > typeArgs )
34173416 throws InvalidTargetException , InvalidTypeArgumentException , UnmatchedLookupException {
3418- // System.out.println("\nLooking up class " + name + " in type " + userRepresentation(t));
3419- Lambda <Boolean , Predicate <DJClass >> makePred = new Lambda <Boolean , Predicate <DJClass >>() {
3420- public Predicate <DJClass > value (final Boolean includePrivate ) {
3421- return new Predicate <DJClass >() {
3422- public Boolean value (DJClass c ) {
3423- if (c .declaredName ().equals (name )) {
3424- return includePrivate || !c .accessibility ().equals (Access .PRIVATE );
3417+ debug .logStart (new String []{"t" , "name" , "typeArgs" }, t , name , typeArgs );
3418+ try {
3419+ Lambda <Boolean , Predicate <DJClass >> makePred = new Lambda <Boolean , Predicate <DJClass >>() {
3420+ public Predicate <DJClass > value (final Boolean includePrivate ) {
3421+ return new Predicate <DJClass >() {
3422+ public Boolean value (DJClass c ) {
3423+ if (c .declaredName ().equals (name )) {
3424+ return includePrivate || !c .accessibility ().equals (Access .PRIVATE );
3425+ }
3426+ else { return false ; }
34253427 }
3426- else { return false ; }
3427- }
3428- };
3429- }
3430- };
3431- return lookupClass ( t , makePred , typeArgs , name );
3428+ };
3429+ }
3430+ };
3431+ return lookupClass ( t , makePred , typeArgs , name );
3432+ }
3433+ finally { debug . logEnd (); }
34323434 }
34333435
34343436 /**
@@ -3444,20 +3446,24 @@ public Boolean value(DJClass c) {
34443446 */
34453447 public ClassType lookupStaticClass (Type t , final String name , final Iterable <? extends Type > typeArgs )
34463448 throws InvalidTargetException , InvalidTypeArgumentException , UnmatchedLookupException {
3447- Lambda <Boolean , Predicate <DJClass >> makePred = new Lambda <Boolean , Predicate <DJClass >>() {
3448- public Predicate <DJClass > value (final Boolean includePrivate ) {
3449- return new Predicate <DJClass >() {
3450- public Boolean value (DJClass c ) {
3451- if (c .declaredName ().equals (name )) {
3452- if (includePrivate ) { return c .isStatic (); }
3453- else { return c .isStatic () && !c .accessibility ().equals (Access .PRIVATE ); }
3449+ debug .logStart (new String []{"t" , "name" , "typeArgs" }, t , name , typeArgs );
3450+ try {
3451+ Lambda <Boolean , Predicate <DJClass >> makePred = new Lambda <Boolean , Predicate <DJClass >>() {
3452+ public Predicate <DJClass > value (final Boolean includePrivate ) {
3453+ return new Predicate <DJClass >() {
3454+ public Boolean value (DJClass c ) {
3455+ if (c .declaredName ().equals (name )) {
3456+ if (includePrivate ) { return c .isStatic (); }
3457+ else { return c .isStatic () && !c .accessibility ().equals (Access .PRIVATE ); }
3458+ }
3459+ else { return false ; }
34543460 }
3455- else { return false ; }
3456- }
3457- };
3458- }
3459- };
3460- return lookupClass ( t , makePred , typeArgs , name );
3461+ };
3462+ }
3463+ };
3464+ return lookupClass ( t , makePred , typeArgs , name );
3465+ }
3466+ finally { debug . logEnd (); }
34613467 }
34623468
34633469 /** Look up an inner class based on the given predicate. */
@@ -3466,8 +3472,8 @@ private ClassType lookupClass(Type t, Lambda<? super Boolean, ? extends Predicat
34663472 throws InvalidTargetException , InvalidTypeArgumentException , UnmatchedLookupException {
34673473 Iterable <? extends ClassType > results = lookupClasses (t , makePred , typeArgs );
34683474 // TODO: provide more error-message information
3469- if ( IterUtil .isEmpty (results )) { throw new UnmatchedLookupException (); }
3470- else if (IterUtil . sizeOf ( results ) > 1 ) { throw new UnmatchedLookupException (); }
3475+ int matches = IterUtil .sizeOf (results );
3476+ if (matches != 1 ) { throw new UnmatchedLookupException (matches ); }
34713477 else {
34723478 ClassType result = IterUtil .first (results );
34733479 final Iterable <VariableType > params = SymbolUtil .allTypeParameters (result .ofClass ());
@@ -3626,7 +3632,6 @@ private boolean inBounds(Iterable<? extends VariableType> params, Iterable<? ext
36263632 if (isEqual (t , checkedT )) { return IterUtil .empty (); }
36273633 }
36283634
3629- // System.out.println("Searching for member in type " + userRepresentation(t));
36303635 final Iterable <? extends T > baseResult = t .apply (baseCase );
36313636 alreadyChecked .add (t );
36323637 if (!IterUtil .isEmpty (baseResult )) { return baseResult ; }
0 commit comments