useful assertions in backend

This commit is contained in:
Stepan Koltsov
2012-04-07 06:32:17 +04:00
parent 9b120184f5
commit 157633e371
2 changed files with 25 additions and 0 deletions
@@ -81,6 +81,10 @@ public class FunctionCodegen {
JetDeclarationWithBody fun
)
{
if (functionDescriptor.getKind() == CallableMemberDescriptor.Kind.FAKE_OVERRIDE) {
throw new IllegalStateException("must not generate code for fake overrides");
}
List<ValueParameterDescriptor> paramDescrs = functionDescriptor.getValueParameters();
List<TypeParameterDescriptor> typeParameters = (functionDescriptor instanceof PropertyAccessorDescriptor ? ((PropertyAccessorDescriptor)functionDescriptor).getCorrespondingProperty(): functionDescriptor).getTypeParameters();
@@ -191,6 +195,10 @@ public class FunctionCodegen {
frameMap.enter(parameter, argTypes[i+add].getSize());
}
if ((kind instanceof OwnerKind.DelegateKind) != (functionDescriptor.getKind() == FunctionDescriptor.Kind.DELEGATION)) {
throw new IllegalStateException("mismatching kind in " + functionDescriptor);
}
if (kind instanceof OwnerKind.DelegateKind) {
OwnerKind.DelegateKind dk = (OwnerKind.DelegateKind) kind;
InstructionAdapter iv = new InstructionAdapter(mv);
@@ -147,6 +147,10 @@ public class PropertyCodegen {
}
public void generateDefaultGetter(PropertyDescriptor propertyDescriptor, int flags, PsiElement origin) {
if (propertyDescriptor.getKind() == CallableMemberDescriptor.Kind.FAKE_OVERRIDE) {
throw new IllegalStateException("must not generate code for fake overrides");
}
if (kind == OwnerKind.TRAIT_IMPL) {
return;
}
@@ -186,6 +190,11 @@ public class PropertyCodegen {
iv.load(0, JetTypeMapper.TYPE_OBJECT);
}
final Type type = state.getInjector().getJetTypeMapper().mapType(propertyDescriptor.getType());
if ((kind instanceof OwnerKind.DelegateKind) != (propertyDescriptor.getKind() == FunctionDescriptor.Kind.DELEGATION)) {
throw new IllegalStateException("mismatching kind in " + propertyDescriptor);
}
if (kind instanceof OwnerKind.DelegateKind) {
OwnerKind.DelegateKind dk = (OwnerKind.DelegateKind) kind;
dk.getDelegate().put(JetTypeMapper.TYPE_OBJECT, iv);
@@ -222,6 +231,10 @@ public class PropertyCodegen {
}
public void generateDefaultSetter(PropertyDescriptor propertyDescriptor, int flags, PsiElement origin) {
if (propertyDescriptor.getKind() == CallableMemberDescriptor.Kind.FAKE_OVERRIDE) {
throw new IllegalStateException("must not generate code for fake overrides");
}
if (kind == OwnerKind.TRAIT_IMPL) {
return;
}
@@ -263,6 +276,10 @@ public class PropertyCodegen {
paramCode = 1;
}
if ((kind instanceof OwnerKind.DelegateKind) != (propertyDescriptor.getKind() == FunctionDescriptor.Kind.DELEGATION)) {
throw new IllegalStateException("mismatching kind in " + propertyDescriptor);
}
if (kind instanceof OwnerKind.DelegateKind) {
OwnerKind.DelegateKind dk = (OwnerKind.DelegateKind) kind;
iv.load(0, JetTypeMapper.TYPE_OBJECT);