diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/types/TypeUtils.java b/compiler/frontend/src/org/jetbrains/jet/lang/types/TypeUtils.java index 424356a850b..150b8280db5 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/types/TypeUtils.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/types/TypeUtils.java @@ -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 typeParameters) { + return dependsOnTypeParameterConstructors(type, Collections2 + .transform(typeParameters, new Function() { + @Override + public TypeConstructor apply(@Nullable TypeParameterDescriptor typeParameterDescriptor) { + assert typeParameterDescriptor != null; + return typeParameterDescriptor.getTypeConstructor(); + } + })); + } + public static boolean dependsOnTypeParameterConstructors(@NotNull JetType type, @NotNull Collection typeParameterConstructors) { + if (typeParameterConstructors.contains(type.getConstructor())) return true; + for (TypeProjection typeProjection : type.getArguments()) { + if (dependsOnTypeParameterConstructors(typeProjection.getType(), typeParameterConstructors)) { + return true; + } + } + return false; + } }