CONFLICTING_UPPER_BOUNDS reported in LAZY mode

This commit is contained in:
Andrey Breslav
2014-03-07 20:34:26 +04:00
parent db6a6470f9
commit 66b4c8d1a9
2 changed files with 29 additions and 16 deletions
@@ -35,6 +35,7 @@ import java.util.*;
import static org.jetbrains.jet.lang.diagnostics.Errors.*;
import static org.jetbrains.jet.lang.resolve.BindingContext.TYPE;
import static org.jetbrains.jet.lang.resolve.BindingContext.TYPE_PARAMETER;
public class DeclarationsChecker {
@NotNull
@@ -276,8 +277,13 @@ public class DeclarationsChecker {
private void checkTypeParameters(JetTypeParameterListOwner typeParameterListOwner) {
// TODO: Support annotation for type parameters
for (JetTypeParameter typeParameter : typeParameterListOwner.getTypeParameters()) {
AnnotationResolver.reportUnsupportedAnnotationForTypeParameter(typeParameter, trace);
for (JetTypeParameter jetTypeParameter : typeParameterListOwner.getTypeParameters()) {
AnnotationResolver.reportUnsupportedAnnotationForTypeParameter(jetTypeParameter, trace);
TypeParameterDescriptor typeParameter = trace.get(TYPE_PARAMETER, jetTypeParameter);
if (typeParameter != null) {
DescriptorResolver.checkConflictingUpperBounds(trace, typeParameter, jetTypeParameter);
}
}
}
@@ -685,20 +685,7 @@ public class DescriptorResolver {
parameter.setInitialized();
if (KotlinBuiltIns.getInstance().isNothing(parameter.getUpperBoundsAsType())) {
PsiElement nameIdentifier = typeParameters.get(parameter.getIndex()).getNameIdentifier();
if (nameIdentifier != null) {
trace.report(CONFLICTING_UPPER_BOUNDS.on(nameIdentifier, parameter));
}
}
JetType classObjectType = parameter.getClassObjectType();
if (classObjectType != null && KotlinBuiltIns.getInstance().isNothing(classObjectType)) {
PsiElement nameIdentifier = typeParameters.get(parameter.getIndex()).getNameIdentifier();
if (nameIdentifier != null) {
trace.report(CONFLICTING_CLASS_OBJECT_UPPER_BOUNDS.on(nameIdentifier, parameter));
}
}
checkConflictingUpperBounds(trace, parameter, typeParameters.get(parameter.getIndex()));
}
if (!(declaration instanceof JetClass)) {
@@ -710,6 +697,26 @@ public class DescriptorResolver {
}
}
public static void checkConflictingUpperBounds(
@NotNull BindingTrace trace,
@NotNull TypeParameterDescriptor parameter,
@NotNull JetTypeParameter typeParameter
) {
PsiElement nameIdentifier = typeParameter.getNameIdentifier();
if (KotlinBuiltIns.getInstance().isNothing(parameter.getUpperBoundsAsType())) {
if (nameIdentifier != null) {
trace.report(CONFLICTING_UPPER_BOUNDS.on(nameIdentifier, parameter));
}
}
JetType classObjectType = parameter.getClassObjectType();
if (classObjectType != null && KotlinBuiltIns.getInstance().isNothing(classObjectType)) {
if (nameIdentifier != null) {
trace.report(CONFLICTING_CLASS_OBJECT_UPPER_BOUNDS.on(nameIdentifier, parameter));
}
}
}
public void checkNamesInConstraints(
@NotNull JetTypeParameterListOwner declaration,
@NotNull DeclarationDescriptor descriptor,