Search code examples
oopinheritancemethodssmalltalkvisualworks

VisualWorks Smalltalk - can't access parent's methods


I have a problem with class inheritage - I have two classes defined like this:

Smalltalk defineClass: #Field
superclass: #{Core.Object}
indexedType: #none
private: false
instanceVariableNames: 'name type '
classInstanceVariableNames: ''
imports: ''
category: ''

and

Smalltalk defineClass: #CheckBox
superclass: #{Smalltalk.Field}
indexedType: #none
private: false
instanceVariableNames: 'checked '
classInstanceVariableNames: ''
imports: ''
category: ''

in class 'Field' I have a method setName:

setName: n
name := n.
^n

It works perfectly fine for something like this:

|tmp|
tmp := Field new.
tmp setName: 'fancy name'.

, but when I change 'Field' to 'CheckBox' in the above example I always get "Unhandled Exception: MessageNotUnderstood: #setName: ". Do you guys know how am I supposed to make my subclass inherit a setName: method from it's parent? I'm trying to find an answer everywhere, but no luck so far.

EDIT: Full error message is: Error message #1 Error message #2


Solution

  • Ok here's anwser to my question: I'm stupid. I was messing around with my CheckBox initialize method and accidently deleted ^self line at the end. After putting it back there everything works fine. Thanks for your help, David, and sorry for taking your time.