Skip to content

Commit 11076e3

Browse files
authored
Merge pull request #556 from NativeScript/plamen5kov/fix_interface_ctor_cache
fixed jsobject cache for interface creation
2 parents f147b7c + 741b9a0 commit 11076e3

File tree

8 files changed

+50
-1
lines changed

8 files changed

+50
-1
lines changed

runtime/src/main/jni/MetadataNode.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -922,7 +922,7 @@ void MetadataNode::InterfaceConstructorCallback(const v8::FunctionCallbackInfo<v
922922
}
923923

924924
auto className = node->m_implType;
925-
SetInstanceMetadata(isolate, implementationObject, node);
925+
SetInstanceMetadata(isolate, thiz, node);
926926

927927
//@@@ Refactor
928928
thiz->SetInternalField(static_cast<int>(ObjectManager::MetadataNodeKeys::CallSuper), True(isolate));

test-app/app/src/main/assets/app/tests/testMethodResolution.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,30 @@ describe("Test Method Resolution", function () {
5252
expect(exceptionCaught).toBe(false);
5353
expect(d).not.toEqual(null);
5454
});
55+
56+
it("Should call correct base method overload", function () {
57+
58+
var d = new com.tns.tests.DerivedClass();
59+
var i1 = new com.tns.tests.InterfaceOne({});
60+
var i2 = new com.tns.tests.InterfaceTwo({});
61+
62+
var res1 = d.overloadMethod(i1)
63+
var res2 = d.overloadMethod(i2)
64+
65+
expect(res1).toBe(1);
66+
expect(res2).toBe(2);
67+
});
68+
69+
it("Should call correct method overloads", function () {
70+
71+
var d = new com.tns.tests.BaseClass();
72+
var i1 = new com.tns.tests.InterfaceOne({});
73+
var i2 = new com.tns.tests.InterfaceTwo({});
74+
75+
var res1 = d.overloadMethod(i1)
76+
var res2 = d.overloadMethod(i2)
77+
78+
expect(res1).toBe(1);
79+
expect(res2).toBe(2);
80+
});
5581
});
Binary file not shown.
Binary file not shown.
Binary file not shown.

test-app/app/src/main/java/com/tns/tests/BaseClass.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22

33
public class BaseClass
44
{
5+
public int overloadMethod(InterfaceOne ione) {
6+
return 1;
7+
}
8+
9+
public int overloadMethod(InterfaceTwo itwo) {
10+
return 2;
11+
}
12+
513
public int sum(int x, int y)
614
{
715
return x + y;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package com.tns.tests;
2+
3+
/**
4+
* Created by plamen5kov on 9/13/16.
5+
*/
6+
public interface InterfaceOne {
7+
8+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.tns.tests;
2+
3+
/**
4+
* Created by plamen5kov on 9/13/16.
5+
*/
6+
public interface InterfaceTwo {
7+
}

0 commit comments

Comments
 (0)