Fix contextual type argument propagation when calling function expressions; Implement indirect calls to concrete functions

This commit is contained in:
dcodeIO
2018-03-21 17:17:31 +01:00
parent 49f4d3dff1
commit 4687dc2572
9 changed files with 331 additions and 57 deletions

View File

@ -4550,6 +4550,16 @@ export class Compiler extends DiagnosticEmitter {
}
return this.module.createGetGlobal((<EnumValue>element).internalName, NativeType.I32);
}
case ElementKind.FUNCTION_PROTOTYPE: {
let instance = (<FunctionPrototype>element).resolve(
null,
this.currentFunction.contextualTypeArguments
);
if (!(instance && this.compileFunction(instance))) return module.createUnreachable();
let index = this.ensureFunctionTableEntry(instance);
this.currentType = Type.u32.asFunction(instance.signature);
return this.module.createI32(index);
}
}
this.error(
DiagnosticCode.Operation_not_supported,

View File

@ -1892,7 +1892,7 @@ export class Program extends DiagnosticEmitter {
if (element && element.kind == ElementKind.FUNCTION_PROTOTYPE) {
let instance = (<FunctionPrototype>element).resolveUsingTypeArguments(
(<CallExpression>expression).typeArguments,
null,
contextualFunction.contextualTypeArguments,
expression
);
if (instance) {