Details

      Description

      The following code:

      trait T1

      { this: App => println("arguments in T1: "+ args) }

      trait T2 { this: App =>
      delayedInit

      { println("arguments in T2: "+ args) }

      }

      trait T3 extends DelayedInit

      { this: App => println("arguments in T3: "+ args) }

      object Main extends App with T1 with T2 with T3

      { println("arguments in Main: "+ args) }

      generates the following output:

      arguments in T1: null
      arguments in T3: null
      arguments in T2: [Ljava.lang.String;@7bccf12f
      arguments in Main: [Ljava.lang.String;@7bccf12f

      I understand why T1 gives null and why T2 gives non-null. But I'm confused by T3. The DelayedInit documentation says:

      Classes and traits inheriting the `DelayedInit` marker trait will have their initialization code rewritten as follows.
      <code> becomes delayedInit(<code>)

      Note that it explicitly says that traits are rewritten, so I would expect that T3 would work just like T2?

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              paulbutcher Paul Butcher
            • Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: