@Nullable
	public T waitForResult() throws InterruptedException {
		if(!set) {
			synchronized (waitLock) {
				if(!set) {
					waitLock.wait();
				}
			}
		}
		if(!set) {
			throw new IllegalStateException("Notified but never set: " + this);
		}

		try {
			//noinspection unchecked
			return (T)result;
		} catch (ClassCastException e) {
			throw new UnexpectedResultException("Return type was not what was expected. Received: " + result);
		}
	}