Symbol findType ( Env < AttrContext > env , Name name ) { if ( name == names . empty ) return typeNotFound ; // do not allow inadvertent "lookup" of anonymous types Symbol bestSoFar = typeNotFound ; Symbol sym ; boolean staticOnly = false ; for ( Env < AttrContext > env1 = env ; env1 . outer != null ; env1 = env1 . outer ) { if ( isStatic ( env1 ) ) staticOnly = true ; // First, look for a type variable and the first member type final Symbol tyvar = findTypeVar ( env1 , name , staticOnly ) ; sym = findImmediateMemberType ( env1 , env1 . enclClass . sym . type , name , env1 . enclClass . sym ) ; // Return the type variable if we have it, and have no // immediate member, OR the type variable is for a method. if ( tyvar != typeNotFound ) { if ( env . baseClause || sym == typeNotFound || ( tyvar . kind == TYP && tyvar . exists ( ) && tyvar . owner . kind == MTH ) ) { return tyvar ; } } // If the environment is a class def, finish up, // otherwise, do the entire findMemberType if ( sym == typeNotFound ) sym = findInheritedMemberType ( env1 , env1 . enclClass . sym . type , name , env1 . enclClass . sym ) ; if ( staticOnly && sym . kind == TYP && sym . type . hasTag ( CLASS ) && sym . type . getEnclosingType ( ) . hasTag ( CLASS ) && env1 . enclClass . sym . type . isParameterized ( ) && sym . type . getEnclosingType ( ) . isParameterized ( ) ) return new StaticError ( sym ) ; else if ( sym . exists ( ) ) return sym ; else bestSoFar = bestOf ( bestSoFar , sym ) ; JCClassDecl encl = env1 . baseClause ? ( JCClassDecl ) env1 . tree : env1 . enclClass ; if ( ( encl . sym . flags ( ) & STATIC ) != 0 ) staticOnly = true ; } if ( ! env . tree . hasTag ( IMPORT ) ) { sym = findGlobalType ( env , env . toplevel . namedImportScope , name , namedImportScopeRecovery ) ; if ( sym . exists ( ) ) return sym ; else bestSoFar = bestOf ( bestSoFar , sym ) ; sym = findGlobalType ( env , env . toplevel . packge . members ( ) , name , noRecovery ) ; if ( sym . exists ( ) ) return sym ; else bestSoFar = bestOf ( bestSoFar , sym ) ; sym = findGlobalType ( env , env . toplevel . starImportScope , name , starImportScopeRecovery ) ; if ( sym . exists ( ) ) return sym ; else bestSoFar = bestOf ( bestSoFar , sym ) ; } return bestSoFar ; }
Find an unqualified type symbol .