diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/ResolveSession.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/ResolveSession.java index 2a23988d64a..e5b28f83ff5 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/ResolveSession.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/ResolveSession.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2015 JetBrains s.r.o. + * Copyright 2010-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -294,12 +294,22 @@ public class ResolveSession implements KotlinCodeAnalyzer, LazyClassContext { @Override @NotNull public DeclarationDescriptor resolveToDescriptor(@NotNull KtDeclaration declaration) { + if (!areDescriptorsCreatedForDeclaration(declaration)) { + throw new IllegalStateException( + "No descriptors are created for declarations of type " + declaration.getClass().getSimpleName() + + "\n. Change the caller accordingly" + ); + } if (!KtPsiUtil.isLocal(declaration)) { return lazyDeclarationResolver.resolveToDescriptor(declaration); } return localDescriptorResolver.resolveLocalDeclaration(declaration); } + public static boolean areDescriptorsCreatedForDeclaration(@NotNull KtDeclaration declaration) { + return !(declaration instanceof KtAnonymousInitializer || declaration instanceof KtDestructuringDeclaration); + } + @NotNull public Annotations getFileAnnotations(@NotNull KtFile file) { return fileAnnotations.invoke(file);