mirror of
https://github.com/facebookarchive/prepack.git
synced 2024-09-11 14:46:37 +03:00
Propagate functionResultType when resolving an abstract template property access. (#2527)
Summary: Release notes: None Added regression test. This fix gets rid of a spurious internal RecoverableError. Pull Request resolved: https://github.com/facebook/prepack/pull/2527 Reviewed By: trueadm Differential Revision: D9622296 Pulled By: NTillmann fbshipit-source-id: 0d0b7927f6c6f97d7ec43d4109dc52eda9ee7d13
This commit is contained in:
parent
e845131e03
commit
067a378227
@ -1580,6 +1580,7 @@ export class PropertiesImplementation {
|
||||
let realmGenerator = realm.generator;
|
||||
invariant(realmGenerator);
|
||||
invariant(value.operationDescriptor);
|
||||
const functionResultType = value instanceof AbstractObjectValue ? value.functionResultType : undefined;
|
||||
value = realmGenerator.deriveAbstract(value.types, value.values, value.args, value.operationDescriptor, {
|
||||
isPure: true,
|
||||
kind: "resolved",
|
||||
@ -1592,6 +1593,10 @@ export class PropertiesImplementation {
|
||||
args[savedIndex] = value;
|
||||
value = AbstractValue.createAbstractConcreteUnion(realm, ...args);
|
||||
}
|
||||
if (functionResultType !== undefined) {
|
||||
invariant(value instanceof AbstractObjectValue);
|
||||
value.functionResultType = functionResultType;
|
||||
}
|
||||
if (realm.invariantLevel >= 1 && typeof P === "string" && !realm.hasBindingBeenChecked(O, P)) {
|
||||
realm.markPropertyAsChecked(O, P);
|
||||
realmGenerator.emitFullInvariant(O, P, value);
|
||||
|
12
test/serializer/abstract/PropagateFunctionResultType.js
Normal file
12
test/serializer/abstract/PropagateFunctionResultType.js
Normal file
@ -0,0 +1,12 @@
|
||||
// add at runtime: let __obj = {f: function() { return 19; }};
|
||||
let obj = global.__abstract
|
||||
? __abstract({ f: __abstract(":number") }, "__obj")
|
||||
: {
|
||||
f: function() {
|
||||
return 19;
|
||||
},
|
||||
};
|
||||
let result = obj.f() + 23;
|
||||
global.inspect = function() {
|
||||
return 42;
|
||||
};
|
Loading…
Reference in New Issue
Block a user