Ejemplo n.º 1
0
 @NotNull
 public static TypeSubstitutor createSubstitutorForTypeParameters(
     @NotNull
         Map<TypeParameterDescriptor, TypeParameterDescriptorImpl> originalToAltTypeParameters) {
   Map<TypeConstructor, TypeProjection> typeSubstitutionContext =
       new HashMap<TypeConstructor, TypeProjection>();
   for (Map.Entry<TypeParameterDescriptor, TypeParameterDescriptorImpl>
       originalToAltTypeParameter : originalToAltTypeParameters.entrySet()) {
     typeSubstitutionContext.put(
         originalToAltTypeParameter.getKey().getTypeConstructor(),
         new TypeProjectionImpl(originalToAltTypeParameter.getValue().getDefaultType()));
   }
   // TODO: Use IndexedParametersSubstitution here instead of map creation
   return TypeSubstitutor.create(typeSubstitutionContext);
 }
Ejemplo n.º 2
0
 public static Map<TypeParameterDescriptor, TypeParameterDescriptorImpl>
     recreateTypeParametersAndReturnMapping(
         @NotNull List<TypeParameterDescriptor> originalParameters,
         @Nullable DeclarationDescriptor newOwner) {
   // LinkedHashMap to save the order of type parameters
   Map<TypeParameterDescriptor, TypeParameterDescriptorImpl> result =
       new LinkedHashMap<TypeParameterDescriptor, TypeParameterDescriptorImpl>();
   for (TypeParameterDescriptor typeParameter : originalParameters) {
     result.put(
         typeParameter,
         TypeParameterDescriptorImpl.createForFurtherModification(
             newOwner == null ? typeParameter.getContainingDeclaration() : newOwner,
             typeParameter.getAnnotations(),
             typeParameter.isReified(),
             typeParameter.getVariance(),
             typeParameter.getName(),
             typeParameter.getIndex(),
             SourceElement.NO_SOURCE));
   }
   return result;
 }