Skip to content

Commit 1f76bb8

Browse files
committed
Fix lualib
1 parent c0a6918 commit 1f76bb8

4 files changed

Lines changed: 4 additions & 14 deletions

File tree

src/lualib/Await.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export function __TS__AsyncAwaiter(this: void, generator: (this: void) => void)
5252
return __TS__Promise.resolve(result).addCallbacks(fulfilled, reject);
5353
}
5454

55-
const [success, resultOrError] = coresume(asyncCoroutine, function(v: unknown) {
55+
const [success, resultOrError] = coresume(asyncCoroutine, function (v: unknown) {
5656
resolved = true;
5757
return __TS__Promise.resolve(v).addCallbacks(resolve, reject);
5858
});

src/lualib/Promise.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,7 @@ export class __TS__Promise<T> implements Promise<T> {
7373

7474
constructor(executor: PromiseExecutor<T>) {
7575
// Avoid unnecessary local functions allocations by using `pcall` explicitly
76-
const [success, error] = pcall(
77-
executor,
78-
undefined,
79-
this.resolve.bind(this),
80-
this.reject.bind(this)
81-
);
76+
const [success, error] = pcall(executor, undefined, this.resolve.bind(this), this.reject.bind(this));
8277
if (!success) {
8378
// When a promise executor throws, the promise should be rejected with the thrown object as reason
8479
this.reject(error);

src/lualib/Using.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export function __TS__Using<TArgs extends Disposable[], TReturn>(
55
): TReturn {
66
let thrownError;
77
const [ok, result] = xpcall(
8-
() => cb.call(this, ...args),
8+
() => cb(...args),
99
err => (thrownError = err)
1010
);
1111

src/transformation/builtins/function.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as ts from "typescript";
22
import { LuaTarget } from "../../CompilerOptions";
33
import * as lua from "../../LuaAST";
44
import { TransformationContext } from "../context";
5-
import { unsupportedForTarget, unsupportedProperty, unsupportedSelfFunctionConversion } from "../utils/diagnostics";
5+
import { unsupportedForTarget, unsupportedProperty } from "../utils/diagnostics";
66
import { ContextType, getFunctionContextType } from "../utils/function-context";
77
import { LuaLibFeature, transformLuaLibFunction } from "../utils/lualib";
88
import { transformCallAndArguments } from "../visitors/call";
@@ -13,11 +13,6 @@ export function transformFunctionPrototypeCall(
1313
node: ts.CallExpression,
1414
calledMethod: ts.PropertyAccessExpression
1515
): lua.CallExpression | undefined {
16-
const callerType = context.checker.getTypeAtLocation(calledMethod.expression);
17-
if (getFunctionContextType(context, callerType) === ContextType.Void) {
18-
context.diagnostics.push(unsupportedSelfFunctionConversion(node));
19-
}
20-
2116
const signature = context.checker.getResolvedSignature(node);
2217
const [caller, params] = transformCallAndArguments(context, calledMethod.expression, node.arguments, signature);
2318
const expressionName = calledMethod.name.text;

0 commit comments

Comments
 (0)