<s> package org . eclipse . jdt . internal . compiler . lookup ; public class InferenceContext { private TypeBinding [ ] [ ] [ ] collectedSubstitutes ; MethodBinding genericMethod ; int depth ; int status ; TypeBinding expectedType ; boolean hasExplicitExpectedType ; public boolean isUnchecked ; TypeBinding [ ] substitutes ; final static int FAILED = 1 ; public InferenceContext ( MethodBinding genericMethod ) { this . genericMethod = genericMethod ; TypeVariableBinding [ ] typeVariables = genericMethod . typeVariables ; int varLength = typeVariables . length ; this . collectedSubstitutes = new TypeBinding [ varLength ] [ 3 ] [ ] ; this . substitutes = new TypeBinding [ varLength ] ; } public TypeBinding [ ] getSubstitutes ( TypeVariableBinding typeVariable , int constraint ) { return this . collectedSubstitutes [ typeVariable . rank ] [ constraint ] ; } public boolean hasUnresolvedTypeArgument ( ) { for ( int i = 0 , varLength = this . substitutes . length ; i < varLength ; i ++ ) { if ( this . substitutes [ i ] == null ) { return true ; } } return false ; } public void recordSubstitute ( TypeVariableBinding typeVariable , TypeBinding actualType , int constraint ) { TypeBinding [ ] [ ] variableSubstitutes = this . collectedSubstitutes [ typeVariable . rank ] ; insertLoop : { TypeBinding [ ] constraintSubstitutes = variableSubstitutes [ constraint ] ; int length ; if ( constraintSubstitutes == null ) { length = 0 ; constraintSubstitutes = new TypeBinding [ 1 ] ; } else { length = constraintSubstitutes . length ; for ( int i = 0 ; i < length ; i ++ ) { TypeBinding substitute = constraintSubstitutes [ i ] ; if ( substitute == actualType ) return ; if ( substitute == null ) { constraintSubstitutes [ i ] = actualType ; break insertLoop ; } } System . arraycopy ( constraintSubstitutes , 0 , constraintSubstitutes = new TypeBinding [ length + 1 ] , 0 , length ) ; } constraintSubstitutes [ length ] = actualType ; variableSubstitutes [ constraint ] = constraintSubstitutes ; } } public String toString ( ) { StringBuffer buffer = new StringBuffer ( 20 ) ; buffer . append ( "" ) ; for ( int i = 0 , length = this . genericMethod . typeVariables . length ; i < length ; i ++ ) { buffer . append ( this . genericMethod . typeVariables [ i ] ) ; } buffer . append ( this . genericMethod ) ; buffer . append ( "nt[status=" ) ; switch ( this . status ) { case 0 : buffer . append ( "ok]" ) ; break ; case FAILED : buffer . append ( "failed]" ) ; break ; } if ( this . expectedType == null ) { buffer . append ( "" ) ; } else { buffer . append ( "" ) . append ( this . expectedType . shortReadableName ( ) ) . append ( ']' ) ; } buffer . append ( " [depth=" ) . append ( this . depth ) . append ( ']' ) ; buffer . append ( "" ) ; for ( int i = 0 , length = this . collectedSubstitutes == null ? 0 : this . collectedSubstitutes . length ; i < length ; i ++ ) { TypeBinding [ ] [ ] collected = this . collectedSubstitutes [ i ] ; for ( int j = TypeConstants . CONSTRAINT_EQUAL ; j <= TypeConstants . CONSTRAINT_SUPER ; j ++ ) { TypeBinding [ ] constraintCollected = collected [ j ] ; if ( constraintCollected != null ) { for ( int k = 0 , clength = constraintCollected . length ; k < clength ; k ++ ) { buffer . append ( "ntt" ) . append ( this . genericMethod . typeVariables [ i ] . sourceName ) ; switch ( j ) { case TypeConstants . CONSTRAINT_EQUAL : buffer . append ( "=" ) ; break ; case TypeConstants . CONSTRAINT_EXTENDS : buffer . append ( "<:" ) ; break ; case TypeConstants . CONSTRAINT_SUPER : buffer . append ( ">:" ) ; break ; } if ( constraintCollected [ k ] != null ) { buffer . append ( constraintCollected [ k ] . shortReadableName ( ) ) ; } } } } } buffer . append ( "}]" ) ; buffer . append ( "nt[inferred=" ) ; int count = 0 ; for ( int i = 0 , length = this . substitutes == null ? 0 : this . substitutes . length ; i < length ; i ++ ) { if ( this . substitutes [ i ] == null ) continue ; count ++ ; buffer . append ( '{' ) . append ( this . genericMethod . typeVariables [ i ] . sourceName ) ; buffer . append ( "=" ) . append ( this . substitutes [ i ] . shortReadableName ( ) ) . append ( '}' ) ; } if ( count == 0 ) buffer . append ( "{}" ) ; buffer . append ( ']' ) ; return buffer . toString ( ) ; } } </s>