[BUG] not calling Morph>>initialize is too tempting & dangerous

Brian Keefer mgomes21 at cox.net
Tue Jun 11 19:36:51 UTC 2002


This is a bug that I came across while trying to learn Morph, and left me
piecing things together from my changes log. 

CrashMe makes an EvilMorph that forgot to call super initialize. Dumping
into the fallback debugging Paragraph is too mean for such a simple, naive
mistake.

DontCrashMe does it again with a simple hack in Morph>>bounds, because
that seems to be the first stop on the way to crashing. Isn't there some
exception it could throw to stop drawing (red rectangle with yellow X)?

How about having a compiler hint hold together such method chains?
Something like putting <compileHint: shouldChainSuper> at the start of a
method, and making a subclass override the method without calling "super
thisMethod." would pop up a warning.
-------------- next part --------------
'From Squeak3.2gamma of 15 January 2002 [latest update: #4881] on 11 June 2002 at 2:32:04 pm'!
Morph subclass: #CrashMorph
	instanceVariableNames: ''
	classVariableNames: ''
	poolDictionaries: ''
	category: 'Experimental-Silly'!

!CrashMorph methodsFor: 'as yet unclassified' stamp: 'bmk 6/11/2002 14:30'!
initialize
"oops, forgot to call super"! !

"Postscript:
"
CrashMorph new openInWorld "and let the world burn!!"
!

-------------- next part --------------
'From Squeak3.2gamma of 15 January 2002 [latest update: #4881] on 11 June 2002 at 2:34:55 pm'!
Morph subclass: #CrashMorph
	instanceVariableNames: ''
	classVariableNames: ''
	poolDictionaries: ''
	category: 'Experimental-Silly'!

!Morph methodsFor: 'geometry' stamp: 'bmk 6/11/2002 14:34'!
bounds
	"Return the bounds of this morph."
	"Note: It is best not to override this method because many methods in Morph and its subclasses use the instance variable directly rather than 'self bounds'. Instead, subclasses should be sure that the bounds instance variable is correct."
bounds ifNil:[bounds_0 at 0 corner:50 at 40. submorphs_EmptyArray]. "give just enough of Morph>>initialize to avoid flaming death"
	^ bounds
! !


!CrashMorph methodsFor: 'as yet unclassified' stamp: 'bmk 6/11/2002 14:30'!
initialize
"oops, forgot to call super"! !

"Postscript:
"
CrashMorph new openInWorld "and let the world burn!!"
!



More information about the Squeak-dev mailing list