Skip to content

Commit 181f40b

Browse files
committed
fixed bug with signatures
1 parent 4183a31 commit 181f40b

6 files changed

+13
-13
lines changed

src/compiler.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -6949,6 +6949,9 @@ export class Compiler extends DiagnosticEmitter {
69496949
// cannot call an instance method without a `this` argument (TODO: `.call`?)
69506950
var thisType = signature.thisType;
69516951
if (hasThis != (thisType != null)) {
6952+
console.log("signature " + signature)
6953+
console.log("hasThis " + hasThis)
6954+
assert(false);
69526955
this.error(
69536956
DiagnosticCode.The_this_types_of_each_signature_are_incompatible,
69546957
reportNode.range
@@ -8289,7 +8292,7 @@ export class Compiler extends DiagnosticEmitter {
82898292
prototype.name,
82908293
prototype,
82918294
null,
8292-
signature.toClosureSignature(),
8295+
prototype.hasNestedDefinition ? signature.toClosureSignature() : signature,
82938296
contextualTypeArguments
82948297
);
82958298
if (!this.compileFunction(instance)) return this.module.unreachable();

src/program.ts

+5
Original file line numberDiff line numberDiff line change
@@ -3388,6 +3388,11 @@ export class FunctionPrototype extends DeclaredElement {
33883388
);
33893389
}
33903390

3391+
get hasNestedDefinition(): bool {
3392+
var parent = this.parent;
3393+
return parent.kind == ElementKind.FUNCTION;
3394+
}
3395+
33913396
/** Creates a clone of this prototype that is bound to a concrete class instead. */
33923397
toBound(classInstance: Class): FunctionPrototype {
33933398
assert(this.is(CommonFlags.INSTANCE));

src/resolver.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -2781,7 +2781,8 @@ export class Resolver extends DiagnosticEmitter {
27812781
var signature = new Signature(this.program, parameterTypes, returnType, thisType);
27822782
signature.parameterNames = parameterNames;
27832783
signature.requiredParameters = requiredParameters;
2784-
signature = signature.toClosureSignature();
2784+
2785+
signature = prototype.hasNestedDefinition ? signature.toClosureSignature() : signature;
27852786

27862787
var nameInclTypeParameters = prototype.name;
27872788
if (instanceKey.length) nameInclTypeParameters += "<" + instanceKey + ">";

tests/compiler/extends-recursive.untouched.wat

-2
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,8 @@
159159
local.get $0
160160
)
161161
(func $extends-recursive/Parent#get:child (param $0 i32) (result i32)
162-
(local $1 i32)
163162
local.get $0
164163
i32.load
165-
call $~lib/rt/stub/__retain
166164
)
167165
(func $~lib/rt/stub/__release (param $0 i32)
168166
nop

tests/compiler/implicit-getter-setter.optimized.wat

+2-7
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
(type $i32_=>_none (func (param i32)))
33
(type $i32_i32_=>_none (func (param i32 i32)))
44
(type $i32_i32_=>_i32 (func (param i32 i32) (result i32)))
5-
(type $i32_=>_i32 (func (param i32) (result i32)))
65
(type $i32_i32_i32_=>_none (func (param i32 i32 i32)))
6+
(type $i32_=>_i32 (func (param i32) (result i32)))
77
(type $none_=>_none (func))
88
(type $i32_i32_i32_i32_=>_none (func (param i32 i32 i32 i32)))
99
(type $none_=>_i32 (func (result i32)))
@@ -34,7 +34,7 @@
3434
(export "Basic#set:val" (func $implicit-getter-setter/Basic#set:val))
3535
(export "Basic#constructor" (func $implicit-getter-setter/Basic#constructor))
3636
(export "Managed" (global $implicit-getter-setter/Managed))
37-
(export "Managed#get:foo" (func $implicit-getter-setter/Managed#get:foo))
37+
(export "Managed#get:foo" (func $implicit-getter-setter/Basic#get:val))
3838
(export "Managed#set:foo" (func $implicit-getter-setter/Managed#set:foo))
3939
(export "Managed#constructor" (func $implicit-getter-setter/Managed#constructor))
4040
(func $~lib/rt/tlsf/removeBlock (param $0 i32) (param $1 i32)
@@ -1153,11 +1153,6 @@
11531153
i32.store
11541154
local.get $0
11551155
)
1156-
(func $implicit-getter-setter/Managed#get:foo (param $0 i32) (result i32)
1157-
local.get $0
1158-
i32.load
1159-
call $~lib/rt/pure/__retain
1160-
)
11611156
(func $implicit-getter-setter/Managed#set:foo (param $0 i32) (param $1 i32)
11621157
(local $2 i32)
11631158
local.get $1

tests/compiler/implicit-getter-setter.untouched.wat

-2
Original file line numberDiff line numberDiff line change
@@ -1591,10 +1591,8 @@
15911591
local.get $0
15921592
)
15931593
(func $implicit-getter-setter/Managed#get:foo (param $0 i32) (result i32)
1594-
(local $1 i32)
15951594
local.get $0
15961595
i32.load
1597-
call $~lib/rt/pure/__retain
15981596
)
15991597
(func $implicit-getter-setter/Managed#set:foo (param $0 i32) (param $1 i32)
16001598
(local $2 i32)

0 commit comments

Comments
 (0)