diff --git a/packages/@winglang/wingc/src/lib.rs b/packages/@winglang/wingc/src/lib.rs index e76eef6e816..0044a110178 100644 --- a/packages/@winglang/wingc/src/lib.rs +++ b/packages/@winglang/wingc/src/lib.rs @@ -22,7 +22,7 @@ use indexmap::IndexMap; use jsify::JSifier; use lifting::LiftVisitor; -use parser::{as_wing_library, parse_wing_project}; +use parser::{as_wing_library, is_entrypoint_file, parse_wing_project}; use serde::Serialize; use serde_json::Value; use struct_schema::StructSchemaVisitor; diff --git a/packages/@winglang/wingc/src/type_check.rs b/packages/@winglang/wingc/src/type_check.rs index fe2a523ad9f..62fe866f65f 100644 --- a/packages/@winglang/wingc/src/type_check.rs +++ b/packages/@winglang/wingc/src/type_check.rs @@ -2138,6 +2138,18 @@ impl<'a> TypeChecker<'a> { } } + pub fn add_this(&mut self, env: &mut SymbolEnv) { + let sym = Symbol::global("this"); + env + .define( + &sym, + SymbolKind::make_free_variable(sym.clone(), self.types.construct_base_type(), false, Phase::Preflight), + AccessModifier::Private, + StatementIdx::Top, + ) + .expect("Failed to add this"); + } + pub fn add_builtins(&mut self, scope: &mut Scope) { let optional_string = self.types.make_option(self.types.string()); self.add_builtin( diff --git a/tests/valid/inflight_closure_as_super_param.test.w b/tests/valid/inflight_closure_as_super_param.test.w index b2ca8008966..a1b40feeb5a 100644 --- a/tests/valid/inflight_closure_as_super_param.test.w +++ b/tests/valid/inflight_closure_as_super_param.test.w @@ -27,9 +27,9 @@ let c = new Derived() as "derived"; assert(nodeof(c.f).path.endsWith("derived/in_derived")); // Make sure the instance created in the super call is scoped to the parent (root) assert(!nodeof(c.f_base).path.endsWith("derived/in_root")); -let appPath = nodeof(this).path; -assert(nodeof(c.f_base).path == "{appPath}/in_root"); +let appPath = nodeof(this).path; +assert(nodeof(c.f_base).path == "{appPath}/in_root"); -test "boom!" { - assert(c.h() == "boom!"); +test "boom!" { + assert(c.h() == "boom!"); }