temp hack against KT-1214

This commit is contained in:
Stepan Koltsov
2012-02-09 16:34:30 +04:00
parent df3abbfbb6
commit d69739a3d2
4 changed files with 46 additions and 1 deletions
@@ -1367,6 +1367,22 @@ public class JavaDescriptorResolver {
throw new IllegalStateException("unresolved PsiTypeParameter " + psiTypeParameter.getName() + " in method " + method.getName() + " in class " + psiClass.getQualifiedName()); // TODO: report properly
}
@NotNull
@Override
public TypeParameterDescriptor getTypeVariableByPsiByName(@NotNull String name) {
for (TypeParameterDescriptorInitialization typeParameter : methodTypeParametersInitialization) {
if (typeParameter.psiTypeParameter.getName().equals(name)) {
return typeParameter.descriptor;
}
}
for (TypeParameterDescriptorInitialization typeParameter : classTypeParameterDescriptorsInitialization) {
if (typeParameter.psiTypeParameter.getName().equals(name)) {
return typeParameter.descriptor;
}
}
throw new IllegalStateException("unresolved PsiTypeParameter " + name + " in method " + method.getName() + " in class " + psiClass.getQualifiedName()); // TODO: report properly
}
@NotNull
@Override
public TypeParameterDescriptor getTypeVariable(@NotNull String name) {
@@ -142,13 +142,25 @@ public class JavaTypeTransformer {
return typeParameter;
}
}
throw new IllegalStateException();
return typeVariableByPsiResolver.getTypeVariableByPsiByName(psiTypeParameter.getName());
} else if (classData instanceof JavaDescriptorResolver.ResolverBinaryClassData) {
return new TypeVariableByPsiResolverImpl(((JavaDescriptorResolver.ResolverBinaryClassData) classData).typeParameters, typeVariableByPsiResolver).getTypeVariable(psiTypeParameter);
} else {
throw new IllegalStateException();
}
}
@NotNull
@Override
public TypeParameterDescriptor getTypeVariableByPsiByName(@NotNull String name) {
for (TypeParameterDescriptor typeParameter : classData.getClassDescriptor().getTypeConstructor().getParameters()) {
if (typeParameter.getName().equals(name)) {
// TODO?
return typeParameter;
}
}
throw new IllegalStateException();
}
};
arguments.add(transformToTypeProjection(psiArgument, typeParameterDescriptor, typeVariableByPsiResolver2));
}
@@ -12,4 +12,8 @@ import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptor;
public interface TypeVariableByPsiResolver {
@NotNull
TypeParameterDescriptor getTypeVariable(@NotNull PsiTypeParameter psiTypeParameter);
/** @deprecated */
@NotNull
TypeParameterDescriptor getTypeVariableByPsiByName(@NotNull String name);
}
@@ -36,4 +36,17 @@ public class TypeVariableByPsiResolverImpl implements TypeVariableByPsiResolver
throw new RuntimeException("type parameter not found by PsiTypeParameter " + psiTypeParameter.getName()); // TODO report properly
}
@NotNull
@Override
public TypeParameterDescriptor getTypeVariableByPsiByName(@NotNull String name) {
for (JavaDescriptorResolver.TypeParameterDescriptorInitialization typeParameter : typeParameters) {
if (typeParameter.psiTypeParameter.getName().equals(name)) {
return typeParameter.descriptor;
}
}
if (parent != null) {
return parent.getTypeVariableByPsiByName(name);
}
throw new RuntimeException("type parameter not found by PsiTypeParameter " + name); // TODO report properly
}
}