Monday, August 30, 2010

New Mint Release: r15716

As mentioned before, Eddy and I discovered a problem with type variables in code generated by the Mint compiler. We have now fixed this problem in the new release of Mint and DrJava with Mint: August 30, 2010 (r15716). The latest release is, as always, available from the Mint implementation page:
The problem occurred when the programmer used a type variable inside a bracket. An example of this would be a generic method like this:
public separable <X> Code<X> fun(Code<X> c1, Code<X> c2) {
return <| ( `(lfTest.eval(e,f).booleanCodeValue()) ?
`c2 : `c1 ) |>;
}
This caused Mint to generate 2nd stage code that contained the type variable X unbound. Unfortunately, the types are erased, and there is no way to find out what type X actually refers to at runtime, e.g. by writing something like X.class (this generates the Java compiler error "cannot select from a type variable").

To get around this problem, we now require a final instance of type Class<X> to be in scope for every type variable X. For example, in the generic method above, there is a type variable X that is being used in the bracket. Therefore, we now have to have a final instance of Class<X>somewhere in scope, for example as a method parameter.
public separable <X> Code<X> fun(Code<X> c1, Code<X> c2,
final Class<X> xc) {
return <| ( `(lfTest.eval(e,f).booleanCodeValue()) ?
`c2 : `c1 ) |>;
}
That's all that is necessary. The variable xc is not actually used in the code, it just needs to be in scope.

9 comments:

  1. Adidas produce il nuovo Chelsea 16-17 casa, lontano e kit terzo per l’ultima volta dopo che il contratto che hanno deciso di tagliare il loro kit di sponsorizzazione a lungo termine sul 11 maggio Chelsea camicia sponsor Yokohama è di nuovo sulle nuove Chelsea 2016-17 camicie .maglie calcio,
    poco prezzo Maglia Barcelona vendita
    Maglia Deportivo shop

    ReplyDelete
  2. Our Green Bay Packers Banner measures a huge 2x8 feet, is constructed of thick weather resistant nylon, and is embroidered with the Green Bay Packers NFL team logo as shown. Our Green Bay Packers Banner includes ten (10) reinforced metal grommets around the perimeter for easy hanging at your next tailgate party, in your sports room, or as an interior or exterior "gameday" decoration.
    nfl house flags
    nfl flags wholesaleRavens american flags
    Bills stars and stripes flags

    ReplyDelete