More exact return type.

This commit is contained in:
Evgeny Gerashchenko
2014-01-10 00:39:32 +04:00
parent 4239f5bb18
commit 25c65173f2
@@ -101,16 +101,17 @@ public abstract class CodegenContext<T extends DeclarationDescriptor> {
return thisDescriptor != null; return thisDescriptor != null;
} }
public DeclarationDescriptor getClassOrPackageDescriptor() { @NotNull
public ClassOrPackageFragmentDescriptor getClassOrPackageDescriptor() {
CodegenContext c = this; CodegenContext c = this;
while (true) { while (true) {
assert c != null; assert c != null;
DeclarationDescriptor contextDescriptor = c.getContextDescriptor(); DeclarationDescriptor contextDescriptor = c.getContextDescriptor();
if (!(contextDescriptor instanceof ClassDescriptor) && !(contextDescriptor instanceof PackageFragmentDescriptor)) { if (contextDescriptor instanceof ClassOrPackageFragmentDescriptor) {
c = c.getParentContext(); return (ClassOrPackageFragmentDescriptor) contextDescriptor;
} }
else { else {
return contextDescriptor; c = c.getParentContext();
} }
} }
} }