Try/typer reorg #47

Merged
merged 9 commits into from Mar 8, 2014
Commits on Mar 7, 2014
  1. First step towards Typer Reorganization.

    odersky committed Mar 5, 2014
    Goal is better modularization and avoiding code duplication and divergence between Typer and tpd. As a first step, we split Inferencing into Inferencing, Checking, and ProtoTypes. Inferencing and Checking become Typer traits, while ProtoTypes remains a global object.
    
    Eventually:
    
     - we want to have a SimpleTyper, which does the main stuff in tpd, and can mixin either full checking or no checking. Each method in SimpleTyper takes an untyped tree (which is assumed to have typed arguments) and adds a toplevel type to that tree. The methods subsume the type-checking parts in Typers, except for
    (1) simplifications and expansions (2) computing prototypes and recursing with them into childtrees (3) adaptation. The method calls the necessary checking operations, which may however be stubbed out.
    
    The idea is already exercised in the typechecking code for Literal and New, except that for now it calls methods in tpd (they will become methods in SimpleTyper instead).
    
     - Typer should inherit from SimpleTyper, and forward all logic except for (1) - (3) to it.
    
     - tpd should call the simple typer it gets from ctx.typer
    
     - ctx.typer should be a SimpleTyper, not a complete one.
  2. Fix problem in TermRef.alternatives

    odersky committed Mar 6, 2014
    Rewrap needs to produce alternatives with signatures. Otgerwise the new denotation will simply overwrite the old because both the overloaded TermRef and the alternative will hash to the same unique TermRef.
  3. Fix problem comparing overloaded TermRefs

    odersky committed Mar 6, 2014
    Overloaded TermRefs do not have an info, and consequently do not support =:=. Yet in Typer#checkNewOrShadowed we compared termrefs with =:=. This gives an exception if the termrefs are overloaded. The fix is to provide a new method isSameRef in TypeComparer which is called instead of =:= in Typer#checkNewOrShadowed.
  4. Scond step to typer reorg: Introduce TypeAssigners.

    odersky committed Mar 6, 2014
    TypeAssigners assign a toplevel type to a node. They are mixed into Typer, and can be accessed from tpd using
    ctx.typeAssigner.
  5. Main Typer reorg.

    odersky committed Mar 6, 2014
    Common code between tpd and Typer has been factored out into class TypeAssigner.