summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpooryorick <com.digitalsmarties@pooryorick.com>2018-01-27 18:17:09 (GMT)
committerpooryorick <com.digitalsmarties@pooryorick.com>2018-01-27 18:17:09 (GMT)
commitfa7659336ca6c01fbed7cf8497b29e9191b0cb42 (patch)
treedb44fd6a57ada6677bbe542902d70134e97e0647
parent175fe8c23f5d96a8cb4ecde93e7407e48c49da6d (diff)
downloadtcl-fa7659336ca6c01fbed7cf8497b29e9191b0cb42.zip
tcl-fa7659336ca6c01fbed7cf8497b29e9191b0cb42.tar.gz
tcl-fa7659336ca6c01fbed7cf8497b29e9191b0cb42.tar.bz2
Remove restriction on defining the class of a TclOO object not explicitly
instantiated from ::oo::class.
-rw-r--r--generic/tclOODefineCmds.c15
-rw-r--r--tests/oo.test4
2 files changed, 2 insertions, 17 deletions
diff --git a/generic/tclOODefineCmds.c b/generic/tclOODefineCmds.c
index c08b350..7c2a641 100644
--- a/generic/tclOODefineCmds.c
+++ b/generic/tclOODefineCmds.c
@@ -1143,7 +1143,6 @@ TclOODefineClassObjCmd(
{
Object *oPtr;
Class *clsPtr;
- Foundation *fPtr = TclOOGetFoundation(interp);
/*
* Parse the context to get the object to operate on.
@@ -1180,20 +1179,6 @@ TclOODefineClassObjCmd(
return TCL_ERROR;
}
- /*
- * Apply semantic checks. In particular, classes and non-classes are not
- * interchangable (too complicated to do the conversion!) so we must
- * produce an error if any attempt is made to swap from one to the other.
- */
-
- if ((oPtr->classPtr==NULL) == TclOOIsReachable(fPtr->classCls, clsPtr)) {
- Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "may not change a %sclass object into a %sclass object",
- (oPtr->classPtr==NULL ? "non-" : ""),
- (oPtr->classPtr==NULL ? "" : "non-")));
- Tcl_SetErrorCode(interp, "TCL", "OO", "TRANSMUTATION", NULL);
- return TCL_ERROR;
- }
/*
* Set the object's class.
diff --git a/tests/oo.test b/tests/oo.test
index 3be5f79..4f9490b 100644
--- a/tests/oo.test
+++ b/tests/oo.test
@@ -1707,13 +1707,13 @@ test oo-13.2 {OO: changing an object's class} -body {
oo::objdefine foo class oo::class
} -cleanup {
foo destroy
-} -returnCodes 1 -result {may not change a non-class object into a class object}
+} -result {}
test oo-13.3 {OO: changing an object's class} -body {
oo::class create foo
oo::objdefine foo class oo::object
} -cleanup {
foo destroy
-} -returnCodes 1 -result {may not change a class object into a non-class object}
+} -result {}
test oo-13.4 {OO: changing an object's class} -body {
oo::class create foo {
method m {} {