added 'dependsOnTypeParameters' method

to filter value parameters dependent on type parameters
This commit is contained in:
Svetlana Isakova
2012-07-08 15:31:56 +04:00
parent b60bb9eb29
commit 95634f3307
@@ -16,6 +16,8 @@
package org.jetbrains.jet.lang.types;
import com.google.common.base.Function;
import com.google.common.collect.Collections2;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
@@ -450,5 +452,24 @@ public class TypeUtils {
return false;
}
public static boolean dependsOnTypeParameters(@NotNull JetType type, @NotNull Collection<TypeParameterDescriptor> typeParameters) {
return dependsOnTypeParameterConstructors(type, Collections2
.transform(typeParameters, new Function<TypeParameterDescriptor, TypeConstructor>() {
@Override
public TypeConstructor apply(@Nullable TypeParameterDescriptor typeParameterDescriptor) {
assert typeParameterDescriptor != null;
return typeParameterDescriptor.getTypeConstructor();
}
}));
}
public static boolean dependsOnTypeParameterConstructors(@NotNull JetType type, @NotNull Collection<TypeConstructor> typeParameterConstructors) {
if (typeParameterConstructors.contains(type.getConstructor())) return true;
for (TypeProjection typeProjection : type.getArguments()) {
if (dependsOnTypeParameterConstructors(typeProjection.getType(), typeParameterConstructors)) {
return true;
}
}
return false;
}
}