KT-6751 References to type arguments of a type argument not resolved when wrong number of them

#KT-6751 Fixed
This commit is contained in:
Svetlana Isakova
2015-02-16 19:01:58 +03:00
parent f1774bd6fb
commit 204e9a0c34
17 changed files with 117 additions and 21 deletions
@@ -36,6 +36,8 @@ import java.util.Collections;
import java.util.List;
import java.util.Set;
import static kotlin.KotlinPackage.joinToString;
public class ErrorUtils {
private static final ModuleDescriptor ERROR_MODULE;
@@ -346,7 +348,7 @@ public class ErrorUtils {
@NotNull
public static JetType createErrorType(@NotNull String debugMessage) {
return new ErrorTypeImpl(createErrorTypeConstructor(debugMessage), createErrorScope(debugMessage));
return createErrorTypeWithArguments(debugMessage, Collections.<TypeProjection>emptyList());
}
@NotNull
@@ -354,6 +356,11 @@ public class ErrorUtils {
return new ErrorTypeImpl(createErrorTypeConstructorWithCustomDebugName(debugName), createErrorScope(debugName));
}
@NotNull
public static JetType createErrorTypeWithArguments(@NotNull String debugMessage, @NotNull List<TypeProjection> arguments) {
return new ErrorTypeImpl(createErrorTypeConstructor(debugMessage), createErrorScope(debugMessage), arguments);
}
@NotNull
public static TypeConstructor createErrorTypeConstructor(@NotNull String debugMessage) {
return createErrorTypeConstructorWithCustomDebugName("[ERROR : " + debugMessage + "]");
@@ -398,10 +405,20 @@ public class ErrorUtils {
private static class ErrorTypeImpl implements JetType {
private final TypeConstructor constructor;
private final JetScope memberScope;
private final List<TypeProjection> arguments;
private ErrorTypeImpl(@NotNull TypeConstructor constructor, @NotNull JetScope memberScope) {
private ErrorTypeImpl(
@NotNull TypeConstructor constructor,
@NotNull JetScope memberScope,
@NotNull List<TypeProjection> arguments
) {
this.constructor = constructor;
this.memberScope = memberScope;
this.arguments = arguments;
}
private ErrorTypeImpl(@NotNull TypeConstructor constructor, @NotNull JetScope memberScope) {
this(constructor, memberScope, Collections.<TypeProjection>emptyList());
}
@NotNull
@@ -413,7 +430,7 @@ public class ErrorUtils {
@NotNull
@Override
public List<TypeProjection> getArguments() {
return Collections.emptyList();
return arguments;
}
@Override
@@ -446,7 +463,7 @@ public class ErrorUtils {
@Override
public String toString() {
return constructor.toString();
return constructor.toString() + (arguments.isEmpty() ? "" : joinToString(arguments, ", ", "<", ">", -1, "..."));
}
}