Aladdin - Scala Bugtracking
[#374] project: compiler priority: high category: bug
submitter assigned to status date submitted
Stephane _ not repro 2004-11-05 16:55:49.0
subject failure to compute least upper bound
code
object tokens extends Enumeration {
  type Token = Value;
  val BAD     = Value("<bad>");
  val IDENT   = Value("ident");
  val NAME    = Value("name");
}

object test extends Object with Application {
  import tokens._;

  val reserved = new scala.collection.mutable.HashMap[String, Token]();

  if (true) {
    reserved.get("a") match {
      case None     => IDENT
      case Some(tk) => tk
    }
  }
  else
    BAD
}
what happened
Exception in thread "main" scalac.symtab.Type$Error:
     failure to compute least upper bound of types Value[tokens.type]
     and tokens.BAD.type;
     an approximation is: Value[tokens];
     additional type annotations are needed
        at scalac.symtab.Type.lub(Type.java:2679)
        at scalac.ast.TreeGen.If(TreeGen.java:764)
        [..]
what expected Silently compiles!

Workaround 1: replace "import tokens._;" with "import tokens.Token; val BAD = tokens.BAD; ..." in main object "test".

Workaround 2: declare the object "tokens" inside the main object "test" !

[back to overview]
Changes of this bug report
Stephane  edited on  2004-11-05 16:56:47.0
Stephane  edited on  2004-11-05 16:57:12.0
Stephane  edited on  2004-11-05 16:57:31.0
Martin  edited on  2004-11-19 13:44:39.0
The lub fails on:
lub[.Value#16[.tokens#1.type],
    .Value#16[#5.this.tokens#1.type]]
The problem seems to be that explicit outer inserts a
.tokens 
whereas the rest of the system sees a
.this.tokens
The two are not compatible. That's why the lub fails.
Lex  edited on  2006-03-28 14:17:31.0
It compiles silently as of 2.1.0. I added an "extends Object" before the "with Application".
Nikolay  edited on  2006-09-13 09:14:20.0
Must have been fixed loooong time ago