If an object creates another object, the second object has access to the first object's protected and private methods. This behavior was not allowed in Itcl 3.4. For example:
package require Itcl
itcl::class A {
constructor {} {
B #auto $this
}
protected method protectedMethod {} {
puts protectedMethod
}
private method privateMethod {} {
puts privateMethod
}
}
itcl::class B {
constructor {a} {
$a protectedMethod
$a privateMethod
}
}
A #auto
Object A passes itself to Object B, which is then able to call protected and private methods in A:
protectedMethod
privateMethod
In Itcl 3.4, the result is:
bad option "protectedMethod": should be one of...
a0 cget -option
a0 configure ?-option? ?value -option value...?
a0 isa className
while executing
"$a protectedMethod"
while constructing object "::A::b0" in ::B::constructor (body line 2)
invoked from within
"B #auto $this"
while constructing object "::a0" in ::A::constructor (body line 2)
invoked from within
"A #auto"