Aladdin - Scala Bugtracking
[#729] project: compiler priority: low category: bug
submitter assigned to status date submitted
Sean Martin fixed 2006-09-05 10:45:19.0
subject confusing error message and implicit view lookup confusion
code
trait Parser {
  type Node <: NodeImpl;
  implicit def coerce(n : NodeImpl) = n.self;
  trait NodeImpl {
    def self : Node;
  }
  trait Link {
    def from : NodeImpl;
  }
}

trait ScalaParserAutoEdit extends Parser {
  type Node <: NodeImpl;
  implicit def coerce(node : NodeImpl) = node.self;
  trait NodeImpl extends super[Parser].NodeImpl {
    def self : Node;
    def foo = {
      var link : Link = null;
      val xxx : NodeImpl = coerce(link.from);
      val yyy : NodeImpl = link.from;
    }
  }
}
what happened
On last line (assign to yyy), Parser.coerce is not used to convert link.from into a NodeImpl:

type mismatch;
found   : ScalaParserAutoEdit.this.NodeImpl
required: ScalaParserAutoEdit.this.NodeImpl	
On second last line (assign to xxx), explicit call to coerce can perform the conversion. Confusion: I thought im\ plicit view parameter types, not just their names, were considered on lookup so that overloaded views were diffe\ rent. It seems like this is not the case.
what expected At least a better error message. At best an alternative to manual name mangling of view names to accommodate different types.
[back to overview]
Changes of this bug report
Martin  edited on  2006-10-31 11:32:18.0
You now get:
bug729.scala:20 error: type mismatch;
 found   : ScalaParserAutoEdit.this.NodeImpl(in trait Parser)
 required: ScalaParserAutoEdit.this.NodeImpl(in trait ScalaParserAutoEdit)
      val yyy : NodeImpl = link.from;
                               ^
one error found