Skip to content

Commit

Permalink
revert: lifting globals from inflight classes defined in preflight fa…
Browse files Browse the repository at this point in the history
…ils, take 2" (#6805)

Reverts #6801
  • Loading branch information
eladcon authored Jun 29, 2024
1 parent f35b02e commit 7fe1e21
Show file tree
Hide file tree
Showing 276 changed files with 416 additions and 2,757 deletions.
1 change: 0 additions & 1 deletion apps/wing/src/commands/pack.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@ describe("wing pack", () => {
expect(mod).toBeDefined();
expect(Object.keys(mod).sort()).toMatchInlineSnapshot(`
[
"$preflightTypesMap",
"FavoriteNumbers",
"Store",
"default",
Expand Down
64 changes: 14 additions & 50 deletions examples/tests/valid/inflight_class_capture_preflight_object.test.w
Original file line number Diff line number Diff line change
@@ -1,54 +1,18 @@
bring cloud;
bring "./subdir2" as subdir;
// https://github.com/winglang/wing/issues/2730
// FAILING:

let b = new cloud.Bucket();
// bring cloud;

inflight class Foo {
pub uploadToBucket(k: str, value: str) {
b.put(k, value);
assert(b.get(k) == value);
}
// let b = new cloud.Bucket();
// let myConst = "bang bang";

static pub fooStatic() {
b.put("a", "b");
assert(b.list() == ["a"]);
}
}
// inflight class Foo {
// uploadToBucket(k: str, value: str) {
// b.put(k, value);
// }
// }

test "inflight class captures preflight resource" {
let f = new Foo();
f.uploadToBucket("hello.txt", "world");
}

test "inflight class type captures preflight resource" {
Foo.fooStatic();
}


let getFoo = inflight () => {
return new Foo();
};

test "inflight class qualified without explicit reference" {
// Get instance of Foo without mentioning the type
let foo = getFoo();
// Now Foo needs to be qualified correcly
foo.uploadToBucket("greetings.txt", "universe");
}

test "inflight class defined inflight captures preflight object" {
class Foo2 {
pub uploadToBucket() {
b.put("x", "y");
assert(b.get("x") == "y");
}
}

let f = new Foo2();
f.uploadToBucket();
}

test "bring inflight class from subdir" {
let x = new subdir.InflightClass();
assert(x.method() == "What did you expect?");
}
// test "inflight class captures preflight resource" {
// let f = new Foo();
// f.uploadToBucket("hello.txt", "world");
// }
2 changes: 0 additions & 2 deletions examples/tests/valid/subdir/bar.w
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,3 @@ pub class Bar {
return @dirname;
}
}

pub inflight class InflightBar {}
5 changes: 0 additions & 5 deletions examples/tests/valid/subdir2/inflight_class.w

This file was deleted.

13 changes: 4 additions & 9 deletions libs/wingc/src/dtsify/snapshots/declarations.snap
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ const $stdlib = require('@winglang/sdk');
const std = $stdlib.std;
const $helpers = $stdlib.helpers;
const $extern = $helpers.createExternRequire(__dirname);
const $preflightTypesMap = {};
Object.assign(module.exports, $helpers.bringJs(`${__dirname}/preflight.lib-1.cjs`, $preflightTypesMap));
module.exports = { ...module.exports, $preflightTypesMap };
module.exports = {
...require("./preflight.lib-1.cjs"),
};
//# sourceMappingURL=preflight.cjs.map
```
Expand All @@ -125,7 +125,6 @@ const $stdlib = require('@winglang/sdk');
const std = $stdlib.std;
const $helpers = $stdlib.helpers;
const $extern = $helpers.createExternRequire(__dirname);
let $preflightTypesMap = {};
class InflightClass extends $stdlib.std.Resource {
constructor($scope, $id, ) {
super($scope, $id);
Expand Down Expand Up @@ -156,8 +155,6 @@ class InflightClass extends $stdlib.std.Resource {
});
}
}
if ($preflightTypesMap[1]) { throw new Error("InflightClass is already in type map"); }
$preflightTypesMap[1] = InflightClass;
class ParentClass extends $stdlib.std.Resource {
constructor($scope, $id, ) {
super($scope, $id);
Expand Down Expand Up @@ -189,14 +186,12 @@ class ParentClass extends $stdlib.std.Resource {
"bar": [
],
"$inflight_init": [
[InflightClass, []],
],
});
}
static get _liftTypeMap() {
return ({
"static_method": [
[InflightClass, []],
],
});
}
Expand Down Expand Up @@ -230,7 +225,7 @@ class Child extends ParentClass {
});
}
}
module.exports = { $preflightTypesMap, InflightClass, ParentClass, Child };
module.exports = { InflightClass, ParentClass, Child };
//# sourceMappingURL=preflight.lib-1.cjs.map
```
Expand Down
9 changes: 4 additions & 5 deletions libs/wingc/src/dtsify/snapshots/optionals.snap
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ const $stdlib = require('@winglang/sdk');
const std = $stdlib.std;
const $helpers = $stdlib.helpers;
const $extern = $helpers.createExternRequire(__dirname);
const $preflightTypesMap = {};
Object.assign(module.exports, $helpers.bringJs(`${__dirname}/preflight.lib-1.cjs`, $preflightTypesMap));
module.exports = { ...module.exports, $preflightTypesMap };
module.exports = {
...require("./preflight.lib-1.cjs"),
};
//# sourceMappingURL=preflight.cjs.map
```
Expand All @@ -66,7 +66,6 @@ const $stdlib = require('@winglang/sdk');
const std = $stdlib.std;
const $helpers = $stdlib.helpers;
const $extern = $helpers.createExternRequire(__dirname);
let $preflightTypesMap = {};
class ParentClass extends $stdlib.std.Resource {
constructor($scope, $id, ) {
super($scope, $id);
Expand Down Expand Up @@ -97,7 +96,7 @@ class ParentClass extends $stdlib.std.Resource {
});
}
}
module.exports = { $preflightTypesMap, ParentClass };
module.exports = { ParentClass };
//# sourceMappingURL=preflight.lib-1.cjs.map
```
Expand Down
Loading

0 comments on commit 7fe1e21

Please sign in to comment.