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 4d1d1e8c944..5499420fbf7 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/types/TypeUtils.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/types/TypeUtils.java @@ -485,6 +485,20 @@ public class TypeUtils { return false; } + public static boolean equalsOrContainsAsArgument(@Nullable JetType type, @NotNull JetType... possibleArgumentTypes) { + return equalsOrContainsAsArgument(type, Sets.newHashSet(possibleArgumentTypes)); + } + + private static boolean equalsOrContainsAsArgument(@Nullable JetType type, @NotNull Set possibleArgumentTypes) { + if (type == null) return false; + if (possibleArgumentTypes.contains(type)) return true; + if (type instanceof NamespaceType) return false; + for (TypeProjection projection : type.getArguments()) { + if (equalsOrContainsAsArgument(projection.getType(), possibleArgumentTypes)) return true; + } + return false; + } + @NotNull public static String getTypeNameAndStarProjectionsString(@NotNull String name, int size) { StringBuilder builder = new StringBuilder(name);