Resolves a simple name as a type. Considers super classes, lexically enclosing classes, and
then arbitrary types available in the current environment.
172117
private Symbol resolveType(String name, SearchSuperTypes searchSuperTypes) {
    Symbol type = null;
    if (searchSuperTypes == SearchSuperTypes.YES) {
      type = getSuperType(enclosingClass, name);
    }
    if (enclosingClass.getSimpleName().contentEquals(name)) {
      type = enclosingClass;
    }
    if (type == null) {
      type = getLexicallyEnclosing(enclosingClass, name);
    }
    if (type == null) {
      type = attribIdent(name);
    }
    checkGuardedBy(
        !(type instanceof Symbol.PackageSymbol),
        "All we could find for '%s' was a package symbol.",
        name);
    return type;
  }
1310002
@SuppressWarnings({ "unchecked", "rawtypes" })
    protected Type resolveType(Type type) {

        Map<TypeVariable, Type> map = new HashMap<>();
        map.putAll(getTypeVariableMap());

        return ResolvableType.forType(type, new TypeVariableMapVariableResolver(map)).getType();
    }
1373573
String lookupName(ClassName className) {
    // If the top level simple name is masked by a current type variable, use the canonical name.
    String topLevelSimpleName = className.topLevelClassName().simpleName();
    if (currentTypeVariables.contains(topLevelSimpleName)) {
      return className.canonicalName;
    }

    // Find the shortest suffix of className that resolves to className. This uses both local type
    // names (so `Entry` in `Map` refers to `Map.Entry`). Also uses imports.
    boolean nameResolved = false;
    for (ClassName c = className; c != null; c = c.enclosingClassName()) {
      ClassName resolved = resolve(c.simpleName());
      nameResolved = resolved != null;

      if (resolved != null && Objects.equals(resolved.canonicalName, c.canonicalName)) {
        int suffixOffset = c.simpleNames().size() - 1;
        return join(".", className.simpleNames().subList(
            suffixOffset, className.simpleNames().size()));
      }
    }

    // If the name resolved but wasn't a match, we're stuck with the fully qualified name.
    if (nameResolved) {
      return className.canonicalName;
    }

    // If the class is in the same package, we're done.
    if (Objects.equals(packageName, className.packageName())) {
      referencedNames.add(topLevelSimpleName);
      return join(".", className.simpleNames());
    }

    // We'll have to use the fully-qualified name. Mark the type as importable for a future pass.
    if (!javadoc) {
      importableType(className);
    }

    return className.canonicalName;
  }
355004
private static Class<?> resolveType(ELContext context, PropertyDescriptor pd)
    {
        if (pd != null)
        {
            Object type = pd.getValue("type");
            if (type != null)
            {
                type = ((ValueExpression)type).getValue(context);
                if (type instanceof String)
                {
                    try
                    {
                        type = ClassUtils.javaDefaultTypeToClass((String)type);
                    }
                    catch (ClassNotFoundException e)
                    {
                        type = null;
                    }
                }
                return (Class<?>) type;
            }
            return pd.getPropertyType();
        }

        return null;
    }
1131809
static public Type resolveType (Class fromClass, Class toClass, Type type) {
		// Explicit type, eg String.
		if (type instanceof Class) return (Class)type;

		// Type variable, eg T.
		if (type instanceof TypeVariable) return resolveTypeVariable(fromClass, toClass, type, true);

		// Type which has a type parameter, eg ArrayList<T> or ArrayList<ArrayList<T>>.
		if (type instanceof ParameterizedType) return (Class)((ParameterizedType)type).getRawType();

		// Array which has a type variable, eg T[] or T[][], and also arrays with a type parameter, eg ArrayList<T>[].
		if (type instanceof GenericArrayType) {
			int dimensions = 1;
			while (true) {
				type = ((GenericArrayType)type).getGenericComponentType();
				if (!(type instanceof GenericArrayType)) break;
				dimensions++;
			}
			Type componentType = resolveType(fromClass, toClass, type);
			if (!(componentType instanceof Class)) return type;
			if (dimensions == 1) return Array.newInstance((Class)componentType, 0).getClass();
			return Array.newInstance((Class)componentType, new int[dimensions]).getClass();
		}

		// Type which has a wildcard, eg ArrayList<?>, ArrayList<? extends Number>, or ArrayList<? super Integer>.
		if (type instanceof WildcardType) {
			// Check upper bound first, it is more likely. There is always an upper bound.
			Type upperBound = ((WildcardType)type).getUpperBounds()[0];
			if (upperBound != Object.class) return resolveType(fromClass, toClass, upperBound);
			Type[] lowerBounds = ((WildcardType)type).getLowerBounds();
			if (lowerBounds.length != 0) return resolveType(fromClass, toClass, lowerBounds[0]);
			return Object.class;
		}

		// If this happens, there is a case we need to handle.
		throw new KryoException("Unable to resolve type: " + type);
	}
318807
def _resolve_name(self, name):
        
        res = [name]
        while True:
            orig_names = self._search("types", name)
            if orig_names is not None:
                name = orig_names[-1]
                # pop off the typedefd name
                res.pop()
                # add back on the original names
                res += orig_names
            else:
                break

        return res
661306
public TypeName resolve(TypeName inputType) {
		if (!hasTypeVariables())
			return inputType;
		
		if (inputType.isPrimitive() || inputType.isBoxedPrimitive() || inputType.equals(TypeName.get(String.class))) {
			return inputType;
		}
		
		if (TypeName.VOID.equals(inputType)) return inputType;
		
		TypeName resolved=null;
		if (inputType instanceof ParameterizedTypeName)
		{
			ParameterizedTypeName inputParametrizedTypeName=(ParameterizedTypeName)inputType;
			
			TypeName[] typeArguments=new TypeName[inputParametrizedTypeName.typeArguments.size()];
			int i=0;
			for (TypeName item: inputParametrizedTypeName.typeArguments)
			{
				typeArguments[i]=resolve(item);
				i++;
			}
			
			resolved=ParameterizedTypeName.get((ClassName)resolve(inputParametrizedTypeName.rawType), typeArguments);
			
			return resolved;
		} else if (inputType instanceof ArrayTypeName)
		{
			ArrayTypeName inputTypeName=(ArrayTypeName)inputType;
			
			resolved=ArrayTypeName.of(resolve(inputTypeName.componentType));
			
			return resolved;
		} else {
			// it's not a type variable
			if (inputType.toString().contains(".")) {
				return inputType;
			}
			// ASSERT: simple typeName 
			if (typeVariableMap.containsKey(inputType.toString())) {
				TypeName type = typeVariableMap.get(inputType.toString());
				return type;
			} else if (declaredTypeArgumentList.size()==1){
				resolved = declaredTypeArgumentList.get(0);
				// if we found an unique type variable, we use it.
				//typeVariableMap = new HashMap<>();
				//typeVariableMap.put(inputTypeName.toString(), resolved);

				return resolved;
			}
			
			AssertKripton.assertTrue(false, "In type hierarchy of %s '%s' there is a unresolved type variable named '%s'. Define it with @BindTypeVariables", element.getKind()==ElementKind.CLASS ? "class" :"interface", element.getQualifiedName(),
					inputType.toString());
			
			return resolved;
		}
		
	}
237991
public Class<?> lookupType(String name) throws ClassNotFoundException {
        if (name == null) {
            throw new IllegalArgumentException("name must not be null");
        }
        Class<?> type = typeRenames.get(name);
        if (type == null) {
            type = StringConvert.loadType(name);
        }
        return type;
    }
619446
public function resolveType()
    {
        $regrex = '/class=.+(?<type>dots|number).+/';

        preg_match($regrex, $this->markup, $matches);

        $this->type = $matches['type'];
    }
180147
def _resolve_type(self, env, type_ref, enforce_fully_defined=False):
        
        loc = type_ref.lineno, type_ref.path
        orig_namespace_name = env.namespace_name
        if type_ref.ns:
            # TODO(kelkabany): If a spec file imports a namespace, it is
            # available to all spec files that are part of the same namespace.
            # Might want to introduce the concept of an environment specific
            # to a file.
            if type_ref.ns not in env:
                raise InvalidSpec(
                    'Namespace %s is not imported' % quote(type_ref.ns), *loc)
            env = env[type_ref.ns]
            if not isinstance(env, Environment):
                raise InvalidSpec(
                    '%s is not a namespace.' % quote(type_ref.ns), *loc)
        if type_ref.name not in env:
            raise InvalidSpec(
                'Symbol %s is undefined.' % quote(type_ref.name), *loc)

        obj = env[type_ref.name]
        if obj is Void and type_ref.nullable:
            raise InvalidSpec('Void cannot be marked nullable.',
                              *loc)
        elif inspect.isclass(obj):
            resolved_data_type_args = self._resolve_args(env, type_ref.args)
            data_type = self._instantiate_data_type(
                obj, resolved_data_type_args, (type_ref.lineno, type_ref.path))
        elif isinstance(obj, ApiRoutesByVersion):
            raise InvalidSpec('A route cannot be referenced here.',
                              *loc)
        elif type_ref.args[0] or type_ref.args[1]:
            # An instance of a type cannot have any additional
            # attributes specified.
            raise InvalidSpec('Attributes cannot be specified for '
                              'instantiated type %s.' %
                              quote(type_ref.name),
                              *loc)
        else:
            data_type = env[type_ref.name]

        if type_ref.ns:
            # Add the source namespace as an import.
            namespace = self.api.ensure_namespace(orig_namespace_name)
            if isinstance(data_type, UserDefined):
                namespace.add_imported_namespace(
                    self.api.ensure_namespace(type_ref.ns),
                    imported_data_type=True)
            elif isinstance(data_type, Alias):
                namespace.add_imported_namespace(
                    self.api.ensure_namespace(type_ref.ns),
                    imported_alias=True)

        if (enforce_fully_defined and isinstance(data_type, UserDefined) and
                data_type._is_forward_ref):
            if data_type in self._resolution_in_progress:
                raise InvalidSpec(
                    'Unresolvable circular reference for type %s.' %
                    quote(type_ref.name), *loc)
            self._resolution_in_progress.add(data_type)
            if isinstance(data_type, Struct):
                self._populate_struct_type_attributes(env, data_type)
            elif isinstance(data_type, Union):
                self._populate_union_type_attributes(env, data_type)
            self._resolution_in_progress.remove(data_type)

        if type_ref.nullable:
            unwrapped_dt, _ = unwrap_aliases(data_type)
            if isinstance(unwrapped_dt, Nullable):
                raise InvalidSpec(
                    'Cannot mark reference to nullable type as nullable.',
                    *loc)
            data_type = Nullable(data_type)

        return data_type
677999
private void resolveTypeTemplates() {
        Collections.sort(context.getClassesAlreadyDone(), new Comparator<Java4CppType>() {

            @Override
            public int compare(Java4CppType t1, Java4CppType t2) {
                Class<?> o1 = t1.getRawClass();
                Class<?> o2 = t2.getRawClass();
                if (o1.isArray() && o2.isArray()) {
                    int idx1 = o1.getName().lastIndexOf('[');
                    int idx2 = o2.getName().lastIndexOf('[');
                    if (idx1 == idx2) {
                        return o1.getName().compareTo(o2.getName());
                    }
                    return idx1 < idx2 ? -1 : 1;
                } else if (o1.isArray() && !o2.isArray()) {
                    return 1;
                } else if (!o1.isArray() && o2.isArray()) {
                    return -1;
                }
                return o1.getName().compareTo(o2.getName());
            }
        });
        for (Java4CppType type : context.getClassesAlreadyDone()) {
            context.executeTypeTemplate(type);
        }
    }
1073799
public final int resolveClassIndex(TypeElement type)
    {
        int size = 0;
        int index = 0;
        constantReadLock.lock();
        try
        {
            size = getConstantPoolSize();
            index = getClassIndex(type);
        }
        finally
        {
            constantReadLock.unlock();
        }
        if (index == -1)
        {
            String name = El.getInternalForm(type);
            int nameIndex = resolveNameIndex(name);
            index = addConstantInfo(new Clazz(nameIndex), size);
        }
        addIndexedElement(index, type);
        return index;
    }
580345
def solve_isinstance(expr, vars):
    """"""
    lhs = solve(expr.lhs, vars)

    try:
        t = solve(expr.rhs, vars).value
    except errors.EfilterKeyError:
        t = None

    if t is None:
        raise errors.EfilterTypeError(
            root=expr.rhs, query=expr.source,
            message="Cannot find type named %r." % expr.rhs.value)

    if not isinstance(t, type):
        raise errors.EfilterTypeError(
            root=expr.rhs, query=expr.source,
            message="%r is not a type and cannot be used with 'isa'." % (t,))

    return Result(protocol.implements(lhs.value, t), ())
348376
static Class<?> resolveParameterName(String parameterName, Class<?> target) {
    Map<Type, Type> typeVariableMap = getTypeVariableMap(target);
    Set<Entry<Type, Type>> set = typeVariableMap.entrySet();
    Type type = Object.class;

    for (Entry<Type, Type> entry : set) {
      if (entry.getKey().toString().equals(parameterName)) {
        type = entry.getKey();
        break;
      }
    }
    return resolveType(type, typeVariableMap);
  }
787227
@Nullable
  private RequiredType resolveTypeFromClass(
      Type calledType, ClassSymbol clazzSymbol, String typeArgName, VisitorState state) {
    // Try on the class
    int tyargIndex = findTypeArgInList(clazzSymbol, typeArgName);
    if (tyargIndex != -1) {
      return RequiredType.create(
          extractTypeArgAsMemberOfSupertype(calledType, clazzSymbol, tyargIndex, state.getTypes()));
    }

    while (clazzSymbol.isInner()) {
      // class Foo<T> {
      //    class Bar {
      //      void something(@CW("T") Object o));
      //    }
      // }
      // new Foo<String>().new Bar().something(123); // should fail, 123 needs to match String
      ClassSymbol encloser = clazzSymbol.owner.enclClass();
      calledType = calledType.getEnclosingType();
      tyargIndex = findTypeArgInList(encloser, typeArgName);
      if (tyargIndex != -1) {
        if (calledType.getTypeArguments().isEmpty()) {
          // If the receiver is held in a reference without the enclosing class's type arguments, we
          // can't determine the required type:
          // new Foo<String>().new Bar().something(123); // Yep
          // Foo<String>.Bar bar = ...;
          // bar.something(123); // Yep
          // Foo.Bar bar = ...;
          // bar.something(123); // Nope (this call would be unchecked if arg was T)
          return null;
        }
        return RequiredType.create(calledType.getTypeArguments().get(tyargIndex));
      }
      clazzSymbol = encloser;
    }
    return null;
  }
709188
def extend(cls, name):
        
        if six.PY2 and isinstance(name, six.text_type):
            # In python2, class name must be a python2 str.
            name = name.encode('utf-8')
        return type(name, (cls,), {})
136538
int resolveNameAndTypeIndex(String name, String descriptor)
    {
        int size = 0;
        int index = 0;
        constantReadLock.lock();
        try
        {
            size = getConstantPoolSize();
            index = getNameAndTypeIndex(name, descriptor);
        }
        finally
        {
            constantReadLock.unlock();
        }
        if (index != -1)
        {
            return index;
        }
        else
        {
            int nameIndex = resolveNameIndex(name);
            int typeIndex = resolveNameIndex(descriptor);
            return addConstantInfo(new NameAndType(nameIndex, typeIndex), size);
        }
    }