Fix codegen in scripts during evaluation of expressions
diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java
index 1ec3123..56aecde 100644
--- a/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java
+++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java
@@ -3046,7 +3046,9 @@
             }
         }
         else if (receiverDescriptor instanceof ScriptDescriptor) {
-            return generateScriptReceiver((ScriptDescriptor) receiverDescriptor);
+            StackValue ans = generateScriptReceiver((ScriptDescriptor) receiverDescriptor);
+
+            return ans != null ? ans : StackValue.thisOrOuter(this, receiverDescriptor, isSuper, castReceiver);
         }
         else {
             return StackValue.thisOrOuter(this, receiverDescriptor, isSuper, castReceiver);
@@ -3126,7 +3128,6 @@
         return result;
     }
 
-    @NotNull
     private StackValue generateScriptReceiver(@NotNull ScriptDescriptor receiver) {
         CodegenContext cur = context;
         StackValue result = StackValue.LOCAL_0;
@@ -3150,7 +3151,7 @@
                 return StackValue.field(classType, receiverKotlinType, currentScriptType, fieldName, false, result, receiver);
             }
 
-            result = cur.getOuterExpression(result, false);
+            result = cur.getOuterExpression(result, true);
 
             if (inStartConstructorContext) {
                 cur = getNotNullParentContextForMethod(cur);
@@ -3160,7 +3161,7 @@
             cur = cur.getParentContext();
         }
 
-        throw new UnsupportedOperationException();
+        return result;
     }
 
     @NotNull