Ticket #112 (closed enhancement: fixed)

Opened 4 years ago

Last modified 4 years ago

Improve signatures of some reflective methods

Reported by: stephan Owned by: stephan
Priority: major Milestone: OTDT_1.1.10
Component: language Version: 1.1.9
Keywords: Cc:

Description

Some reflective methods of class Team (defined in OTJLD §6.1.a) use Object in their signatures thus forcing clients to use casts for accessing role features.

Instead these methods should use type parameters to perform full type checking.

This is, what signatures should probably look like:

<T> T[] getAllRoles(Class<T> class_arg);
<T> T getRole(Object aBase, Class<T>);

This will allow clients to write cast-free code like this:

team class MyTeam {
   protected class R playedBy B {
      void rm() {}
   }
   void test(B b) {
      R r= getRole(b, R.class);
      if (r != null)
         r.rm();
      R[] rs= getAllRoles(R.class);
      if (rs.length > 0)
         rs[0].rm();
   }
}

Change History

Changed 4 years ago by stephan

  • status changed from new to assigned

For method getAllRoles(Class) this change is implemented in r18243.

Test 9.2.7-otjld-get-all-roles-4 has been enhanced to utilize the new signature.

Also paragraph OTJLD §6.1.a is updated in CVS, not yet transfered to OTDT svn.

"If all goes well", method getRole(Class) should be adjusted accordingly.

Changed 4 years ago by stephan

Test for <T> T getRole(Object,Class<T>) is in 9.2.3-otjld-get-role-method-2g, implemented in r18247.

The mentioned test also requires support for externalized role class literals, which are implemented in r18248. Note, that we can only support path syntax here (t.R.class) because the parametric syntax (R<@t>.class) can not be fit into the LALR(1) grammar within reasonable effort :(

Changed 4 years ago by stephan

  • status changed from assigned to closed
  • resolution set to fixed

Changed 4 years ago by stephan

  • milestone changed from OTDT_1.2.0 to OTDT_1.1.10
Note: See TracTickets for help on using tickets.