Skip to content

Commit

Permalink
add support for static class mixed for mixins
Browse files Browse the repository at this point in the history
  • Loading branch information
haikyuu committed Apr 18, 2024
1 parent af60811 commit 901ffcb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 3 additions & 0 deletions packages/imba/src/imba/runtime.mjs
Expand Up @@ -179,6 +179,9 @@ export function augment$(klass,mixin){
Object.defineProperties(klass.prototype,descs);
// TODO Should also run a method / trigger a hook
try { meta.top.version++; } catch(e) { }

if(mixin?.mixed instanceof Function) mixin.mixed(klass)

return klass;
};

Expand Down
5 changes: 4 additions & 1 deletion packages/imba/test/apps/mixins/isa.imba
@@ -1,9 +1,11 @@
import 'imba/spec'
# test do
let val = 0
let val

# Should this only be run once?
class Base
static def mixed
val = 'mixed'

class Action < Base

Expand All @@ -19,3 +21,4 @@ test do
ok (new Widget) !isa Action
ok (new Widget) isa Base
ok (new User) isa Base
ok val, 'mixed'

0 comments on commit 901ffcb

Please sign in to comment.