Browse Source

kernel: .methodClass => .owner

Deprecation getters / setters in place.
Herbert Vojčík 6 years ago
parent
commit
ca7a3f0e0a
4 changed files with 18 additions and 8 deletions
  1. 2 2
      src/Kernel-Methods.js
  2. 1 1
      src/Kernel-Methods.st
  3. 14 4
      support/kernel-fundamentals.js
  4. 1 1
      support/kernel-language.js

+ 2 - 2
src/Kernel-Methods.js

@@ -964,14 +964,14 @@ var self=this,$self=this;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
-return $self._basicAt_("methodClass");
+return $self._basicAt_("owner");
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 }, function($ctx1) {$ctx1.fill(self,"methodClass",{},$globals.CompiledMethod)});
 //>>excludeEnd("ctx");
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: [],
-source: "methodClass\x0a\x09^ self basicAt: 'methodClass'",
+source: "methodClass\x0a\x09^ self basicAt: 'owner'",
 referencedClasses: [],
 //>>excludeEnd("ide");
 messageSends: ["basicAt:"]

+ 1 - 1
src/Kernel-Methods.st

@@ -233,7 +233,7 @@ messageSends
 !
 
 methodClass
-	^ self basicAt: 'methodClass'
+	^ self basicAt: 'owner'
 !
 
 package

+ 14 - 4
support/kernel-fundamentals.js

@@ -209,11 +209,21 @@ define(function () {
         /* Add/remove a method to/from a class */
 
         st.addMethod = function (method, traitOrBehavior) {
-            // TODO remove .methodClass, have .owner
-            if (method.methodClass != null) {
-                throw new Error("addMethod: Method " + method.selector + " already bound to " + method.methodClass);
+            if (method.owner != null) {
+                throw new Error("addMethod: Method " + method.selector + " already bound to " + method.owner);
             }
-            method.methodClass = traitOrBehavior;
+            method.owner = traitOrBehavior;
+            // TODO deprecation helper; remove
+            Object.defineProperty(method, "methodClass", {
+                get: function () {
+                    console.warn("Use of .methodClass deprecated, use .owner");
+                    return method.owner;
+                },
+                set: function (v) {
+                    console.warn("Use of .methodClass= deprecated, use .owner=");
+                    method.owner = v;
+                }
+            });
             registerNewSelectors(method);
             traitOrBehavior.localMethods[method.selector] = method;
             updateMethod(method.selector, traitOrBehavior);

+ 1 - 1
support/kernel-language.js

@@ -152,7 +152,7 @@ define(function () {
                 referencesClasses: method.referencedClasses,
                 fn: method.fn
             });
-            result.methodClass = method.methodClass;
+            result.owner = method.owner;
             return result;
         }