#1486 js: 'is' doesn't work for nested mixins

Yuri Strot Fri 8 Apr 2011

Following example:

@Js
mixin A {}

@Js
mixin B : A {}

@Js
class C : B {}

@Js
class Test
{
  static Void main(Str[] args)
  {
    echo(C() is A)
  }
}

prints true in Java and wrong false in JS.

This issue occures in sys::Type.checkMixin method because List was confused with array. The fix is simple:

diff -r 1529d274645e src/sys/js/fan/Type.js
--- a/src/sys/js/fan/Type.js	Mon Apr 04 09:00:12 2011 -0400
+++ b/src/sys/js/fan/Type.js	Fri Apr 08 14:58:20 2011 +0700
@@ -293,8 +293,8 @@
 {
   if (mixin.equals(that)) return true;
   var m = mixin.m_mixins;
-  for (var i=0; i<m.length; i++)
-    if (fan.sys.Type.checkMixin(m[i], that))
+  for (var i=0; i<m.size(); i++)
+    if (fan.sys.Type.checkMixin(m.get(i), that))
       return true;
   return false;
 }

andy Fri 8 Apr 2011

Thanks Yuri - pushed your fix.

Login or Signup to reply.