diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/BindingContextUtils.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/BindingContextUtils.java index 78bfc7e0cf4..e363cef7ebb 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/BindingContextUtils.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/BindingContextUtils.java @@ -194,4 +194,27 @@ public class BindingContextUtils { trace.record(BindingContext.FUNCTION, psiElement, function); } + + @NotNull + public static V getNotNull( + @NotNull BindingContext bindingContext, + @NotNull ReadOnlySlice slice, + @NotNull K key + ) { + return getNotNull(bindingContext, slice, key, "Value at " + slice + " must not be null for " + key); + } + + @NotNull + public static V getNotNull( + @NotNull BindingContext bindingContext, + @NotNull ReadOnlySlice slice, + @NotNull K key, + @NotNull String messageIfNull + ) { + V value = bindingContext.get(slice, key); + if (value == null) { + throw new IllegalStateException(messageIfNull); + } + return value; + } }