Boo
  1. Boo
  2. BOO-763 Defining new generic types
  3. BOO-853

Internal Generic Types: Correct handling of nested types inside generic types

    Details

    • Type: Sub-task Sub-task
    • Status: In Progress In Progress
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: 0.9.5
    • Component/s: None
    • Labels:
      None
    • Number of attachments :
      0

      Issue Links

        Activity

        Hide
        Avishay Lavie added a comment -

        This affects several places. Suppose we have the following:

        public class Outer[of T]:
          public class Inner[of U]:
              pass
        
        instance as Outer[of int].Inner[of string]
        

        1. Parsing: The parser cannot even handle typereferences for this kind of things. The type reference "Outer[of int].Inner[of string]" cannot be correctly represented in the current AST model (it can be represented a a generic reference expression inside a method, but not as a type reference). The parser errors out on it.

        2. Binding: What should Outer[of int].Inner be bound to? It can't be bound to the generic type definition Outer[of T].Inner, because then we'd lose the int type argument. It can't be bound to any constructed type because it's missing its second type argument. Do we need another transient IType implementation for half-constructed generic definitions?

        3. Emitting: While Outer[of T].Inner[of U] is considered to have a generity of 1, it needs to be emitted as having a generity of 2: Outer`1.Inner`1<T, U>. The same goes for things like the non-generic nested type List[of T].Enumerator, which should actually be emitted as the generic type definition List`1.Enumerator<T>.

        Show
        Avishay Lavie added a comment - This affects several places. Suppose we have the following: public class Outer[of T]: public class Inner[of U]: pass instance as Outer[of int ].Inner[of string] 1. Parsing: The parser cannot even handle typereferences for this kind of things. The type reference "Outer [of int] .Inner [of string] " cannot be correctly represented in the current AST model (it can be represented a a generic reference expression inside a method, but not as a type reference). The parser errors out on it. 2. Binding: What should Outer [of int] .Inner be bound to? It can't be bound to the generic type definition Outer [of T] .Inner, because then we'd lose the int type argument. It can't be bound to any constructed type because it's missing its second type argument. Do we need another transient IType implementation for half-constructed generic definitions? 3. Emitting: While Outer [of T] .Inner [of U] is considered to have a generity of 1, it needs to be emitted as having a generity of 2: Outer`1.Inner`1<T, U>. The same goes for things like the non-generic nested type List [of T] .Enumerator, which should actually be emitted as the generic type definition List`1.Enumerator<T>.

          People

          • Assignee:
            Avishay Lavie
            Reporter:
            Avishay Lavie
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: