patch 9.1.1128: patch 9.1.1119 caused a regression with imports

Problem:  patch 9.1.1119 caused a regression with imports
          (girishji)
Solution: revert the script ID change for the class script variable for
          now (Yegappan Lakshmanan)

fixes: #16664
closes: #16670

Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/src/testdir/test_vim9_import.vim b/src/testdir/test_vim9_import.vim
index 8d81697..6937fb3 100644
--- a/src/testdir/test_vim9_import.vim
+++ b/src/testdir/test_vim9_import.vim
@@ -3494,75 +3494,105 @@
   &rtp = save_rtp
 enddef
 
-" Test for using an autoloaded class from another autoloaded script
-def Test_class_from_auloaded_script()
+" Test for using an imported class as a type
+def Test_use_imported_class_as_type()
   mkdir('Xdir', 'R')
-  var save_rtp = &rtp
-  &rtp = getcwd()
-  exe 'set rtp^=' .. getcwd() .. '/Xdir'
-
-  mkdir('Xdir/autoload/SomeClass/bar', 'p')
-
+  mkdir('Xdir/autoload', 'D')
+  mkdir('Xdir/import', 'D')
   var lines =<< trim END
     vim9script
-
-    export class Baz
-      static var v1: string = "v1"
-      var v2: string = "v2"
-      def GetName(): string
-        return "baz"
+    export class B
+      var foo: string
+      def new()
+        this.foo = 'bar'
       enddef
     endclass
   END
-  writefile(lines, 'Xdir/autoload/SomeClass/bar/baz.vim', 'D')
+  writefile(lines, 'Xdir/autoload/b.vim')
 
   lines =<< trim END
     vim9script
-
-    import autoload './bar/baz.vim'
-
-    export def MyTestFoo(): string
-      assert_fails('var x = baz.Baz.NonExisting()', 'E1325: Method "NonExisting" not found in class "Baz"')
-      assert_fails('var x = baz.Baz.foobar', 'E1337: Class variable "foobar" not found in class "Baz"')
-
-      const instance = baz.Baz.new()
-      return $'{instance.GetName()} {baz.Baz.v1} {instance.v2}'
-    enddef
+    import autoload '../autoload/b.vim'
+    export class A
+      final AO: b.B = b.B.new()
+    endclass
+    var a = A.new()
+    assert_equal('bar', a.AO.foo)
   END
-  writefile(lines, 'Xdir/autoload/SomeClass/foo.vim', 'D')
-
-  lines =<< trim END
-    vim9script
-
-    import autoload 'SomeClass/foo.vim'
-    import autoload 'SomeClass/bar/baz.vim'
-
-    def NotInAutoload()
-      # Use non-existing class method and variable
-      assert_fails('var x = baz.Baz.NonExisting()', 'E1325: Method "NonExisting" not found in class "Baz"')
-
-      var caught_exception = false
-      try
-        var x = baz.Baz.foobar
-      catch /E1337: Class variable "foobar" not found in class "Baz"/
-        caught_exception = true
-      endtry
-      assert_true(caught_exception)
-
-      const instance = baz.Baz.new()
-      assert_equal("baz v1 v2", $'{instance.GetName()} {baz.Baz.v1} {instance.v2}')
-    enddef
-
-    def InAutoload()
-      assert_equal("baz v1 v2", foo.MyTestFoo())
-    enddef
-
-    NotInAutoload()
-    InAutoload()
-  END
-  v9.CheckScriptSuccess(lines)
-
-  &rtp = save_rtp
+  writefile(lines, 'Xdir/import/a.vim')
+  source Xdir/import/a.vim
 enddef
 
+" FIXME: The following test currently fails.
+" " Test for using an autoloaded class from another autoloaded script
+" def Test_class_from_auloaded_script()
+"   mkdir('Xdir', 'R')
+"   var save_rtp = &rtp
+"   &rtp = getcwd()
+"   exe 'set rtp^=' .. getcwd() .. '/Xdir'
+"
+"   mkdir('Xdir/autoload/SomeClass/bar', 'p')
+"
+"   var lines =<< trim END
+"     vim9script
+"
+"     export class Baz
+"       static var v1: string = "v1"
+"       var v2: string = "v2"
+"       def GetName(): string
+"         return "baz"
+"       enddef
+"     endclass
+"   END
+"   writefile(lines, 'Xdir/autoload/SomeClass/bar/baz.vim', 'D')
+"
+"   lines =<< trim END
+"     vim9script
+"
+"     import autoload './bar/baz.vim'
+"
+"     export def MyTestFoo(): string
+"       assert_fails('var x = baz.Baz.NonExisting()', 'E1325: Method "NonExisting" not found in class "Baz"')
+"       assert_fails('var x = baz.Baz.foobar', 'E1337: Class variable "foobar" not found in class "Baz"')
+"
+"       const instance = baz.Baz.new()
+"       return $'{instance.GetName()} {baz.Baz.v1} {instance.v2}'
+"     enddef
+"   END
+"   writefile(lines, 'Xdir/autoload/SomeClass/foo.vim', 'D')
+"
+"   lines =<< trim END
+"     vim9script
+"
+"     import autoload 'SomeClass/foo.vim'
+"     import autoload 'SomeClass/bar/baz.vim'
+"
+"     def NotInAutoload()
+"       # Use non-existing class method and variable
+"       assert_fails('var x = baz.Baz.NonExisting()', 'E1325: Method "NonExisting" not found in class "Baz"')
+"
+"       var caught_exception = false
+"       try
+"         var x = baz.Baz.foobar
+"       catch /E1337: Class variable "foobar" not found in class "Baz"/
+"         caught_exception = true
+"       endtry
+"       assert_true(caught_exception)
+"
+"       const instance = baz.Baz.new()
+"       assert_equal("baz v1 v2", $'{instance.GetName()} {baz.Baz.v1} {instance.v2}')
+"     enddef
+"
+"     def InAutoload()
+"       assert_equal("baz v1 v2", foo.MyTestFoo())
+"     enddef
+"
+"     NotInAutoload()
+"     InAutoload()
+"   END
+"   v9.CheckScriptSuccess(lines)
+"
+"   &rtp = save_rtp
+" enddef
+
 " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker
diff --git a/src/version.c b/src/version.c
index fad08ac..fc31646 100644
--- a/src/version.c
+++ b/src/version.c
@@ -705,6 +705,8 @@
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    1128,
+/**/
     1127,
 /**/
     1126,
diff --git a/src/vim9class.c b/src/vim9class.c
index f041342..dc13c4b 100644
--- a/src/vim9class.c
+++ b/src/vim9class.c
@@ -2053,7 +2053,7 @@
     tv.v_type = VAR_CLASS;
     tv.vval.v_class = cl;
     SOURCING_LNUM = start_lnum;
-    int rc = set_var_const(cl->class_name, 0, NULL, &tv, FALSE, 0, 0);
+    int rc = set_var_const(cl->class_name, current_sctx.sc_sid, NULL, &tv, FALSE, 0, 0);
     if (rc == FAIL)
 	goto cleanup;
 
@@ -2873,7 +2873,7 @@
 	tv.vval.v_class = type->tt_class;
 	++tv.vval.v_class->class_refcount;
     }
-    set_var_const(name_start, 0, NULL, &tv, FALSE,
+    set_var_const(name_start, current_sctx.sc_sid, NULL, &tv, FALSE,
 						ASSIGN_CONST | ASSIGN_FINAL, 0);
 
 done: