Boo
  1. Boo
  2. BOO-417

Casting self as duck removes visibility level. ;(

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 0.5.6
    • Fix Version/s: 0.6
    • Component/s: Runtime (Boo.Lang)
    • Labels:
      None
    • Number of attachments :
      1

      Description

      Test attached, contents inline:

      """hello, world!"""
      class test:
      def foo():
      (self as duck).bar()
      protected def bar():
      print 'hello, world!'

      t = test()
      t.foo()

      Even though "bar" is visible to test, casting the current class to duck makes bar inaccessible.

        Activity

        Hide
        Doug H added a comment -

        Add "BindingFlags.NonPublic" to the DefaultBindingFlags field in src/boo.lang/runtime/runtimeservices.cs and your sample will work.

        I'll leave it up to Rodrigo and others though to decide if this should be added or not. It means you can invoke private or protected methods on objects. But hey, if system.reflection allows it...

        Show
        Doug H added a comment - Add "BindingFlags.NonPublic" to the DefaultBindingFlags field in src/boo.lang/runtime/runtimeservices.cs and your sample will work. I'll leave it up to Rodrigo and others though to decide if this should be added or not. It means you can invoke private or protected methods on objects. But hey, if system.reflection allows it...
        Hide
        Bill Wood added a comment -

        This was a design decision made for ducks because otherwise a duck would be able to access any protected member, even ones which otherwise it would have no business accessing.

        Show
        Bill Wood added a comment - This was a design decision made for ducks because otherwise a duck would be able to access any protected member, even ones which otherwise it would have no business accessing.
        Hide
        Arron Washington added a comment -

        I don't suppose its somehow possible to examine the call stack to make sure the originator of the request is actually from inside a class, then, is there?

        Show
        Arron Washington added a comment - I don't suppose its somehow possible to examine the call stack to make sure the originator of the request is actually from inside a class, then, is there?

          People

          • Assignee:
            Unassigned
            Reporter:
            Arron Washington
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: