2

I have a class defined like so (pseudo code):

package com.some.namespace

public class SomeClass {

    protected SomeClass() {}

    // stuff...

    public class SomeInnerClass {

        public SomeInnerClass() {}

        // more stuff (accesses instance variables from SomeClass)...

    }

}

Then in my template I use the reusable block defines like so:

@doSomething(val: com.some.namespace.SomeClass.SomeInnerClass) = {

    // even more stuff...

}

But I get the error:

type SomeInnerClass is not a member of object com.some.namespace.SomeClass

Am I not able to access inner classes within the templates or is this supposed to work? (if it is supposed to work I might need to post my actual code)

Mikesname
  • 8,781
  • 2
  • 44
  • 57
Neilos
  • 2,696
  • 4
  • 25
  • 51
  • 1
    Doesn't your inner class need to be static? If it is it should work just like any other class. – Mikesname Mar 02 '15 at 21:55
  • I don't think so, `SomeClass` is a singleton that I access in the view which has a list of the `SomeInnerClass` classes which I get via a getter and pass to the reusable block inside a for loop. In fact if I make the inner class static it will break my code as `SomeClass` is required to be an instance and therefore `SomeInnerClass` doesn't need (or want) to be static because it accesses instance variables from the `SomeClass` class, no? – Neilos Mar 02 '15 at 22:01
  • Thank you for your edit @Mikesname i totally missed that. – Neilos Mar 03 '15 at 00:26

1 Answers1

3

It should work, but because SomeInnerClass is a dependent type, i.e. dependent on your singleton outer class instance, you need to write it like:

@doSomething(value: com.some.namespace.SomeClass#SomeInnerClass) = {
    // even more stuff...
}

The SomeClass#SomeInnerClass syntax in Scala means, vaguely, a SomeInnerClass from any instance of SomeClass. See this answer for more detail.

If the inner class was static, however, your current SomeClass.SomeInnerClass syntax would be the way to go.

Community
  • 1
  • 1
Mikesname
  • 8,781
  • 2
  • 44
  • 57