Aladdin - Scala Bugtracking
[#602] project: compiler priority: low category: bug
submitter assigned to status date submitted
Nikolay Martin fixed 2006-05-18 17:07:07.0
subject [contrib #140] NPE during type inference
code
package com.mosol.sl;

case class Span[K <: Ordered[K]](low: Option[K], high: Option[K]) extends Function1[K, boolean] {
  def apply(k: K): boolean = this match {
    case Span(Some(low), Some(high)) => (k >= low && k <= high)
    case Span(Some(low), None) => (k >= low)
    case Span(None, Some(high)) => (k <= high)
    case _ => false
  } 
}
  
what happened
[H:\work.32\SL]scalac -debug -d classes src\com\mosol\sl\Span.scala
[running phase parser on Span.scala]
[running phase namer on Span.scala]
[running phase typer on Span.scala]
exception when typing Span, pt = sl.this.Span[K]
exception when typing Span(Some((low @ _)), Some((high @ _))), pt = sl.this.Span[K]
exception when typing this match {
  case Span(Some((low @ _)), Some((high @ _))) => k.$greater$eq(low).$amp$amp(k.$less$eq(high))
  case Span(Some((low @ _)), None) => k.$greater$eq(low)
  case Span(None, Some((high @ _))) => k.$less$eq(high)
  case _ => false
}, pt = scala.this.Boolean
exception when typing  def apply(k: K): scala.this.Boolean = this match {
  case Span(Some((low @ _)), Some((high @ _))) => k.$greater$eq(low).$amp$amp(k.$less$eq(high))
  case Span(Some((low @ _)), None) => k.$greater$eq(low)
  case Span(None, Some((high @ _))) => k.$less$eq(high)
  case _ => false
}, pt = ?
exception when typing case class Span[K >: scala.this.All <: scala.this.Ordered[K]] extends Function1[K, boolean\
] with scala.ScalaObject wit
h scala.CaseClass {
  private    val low : Option[K] = _;
  private    val high : Option[K] = _;
   def this(low: Option[K], high: Option[K]): sl.this.Span[K] = Span.super.this();
   def apply(k: K): scala.this.Boolean = this match {
    case Span(Some((low @ _)), Some((high @ _))) => k.$greater$eq(low).$amp$amp(k.$less$eq(high))
    case Span(Some((low @ _)), None) => k.$greater$eq(low)
    case Span(None, Some((high @ _))) => k.$less$eq(high)
    case _ => false
  }
}, pt = ?
exception when typing package sl {
  case class Span[K >: scala.this.All <: scala.this.Ordered[K]] extends Function1[K, boolean] with scala.ScalaOb\
ject with scala.CaseClass {
    private    val low : Option[K] = _;
    private    val high : Option[K] = _;
     def this(low: Option[K], high: Option[K]): sl.this.Span[K] = Span.super.this();
     def apply(k: K): scala.this.Boolean = this match {
      case Span(Some((low @ _)), Some((high @ _))) => k.$greater$eq(low).$amp$amp(k.$less$eq(high))
      case Span(Some((low @ _)), None) => k.$greater$eq(low)
      case Span(None, Some((high @ _))) => k.$less$eq(high)
      case _ => false
    }
  }
}, pt = ?
exception when typing package mosol {
  package sl {
    case class Span[K >: scala.this.All <: scala.this.Ordered[K]] extends Function1[K, boolean] with scala.Scala\
Object with scala.CaseClass
{
      private    val low : Option[K] = _;
      private    val high : Option[K] = _;
       def this(low: Option[K], high: Option[K]): sl.this.Span[K] = Span.super.this();
       def apply(k: K): scala.this.Boolean = this match {
        case Span(Some((low @ _)), Some((high @ _))) => k.$greater$eq(low).$amp$amp(k.$less$eq(high))
        case Span(Some((low @ _)), None) => k.$greater$eq(low)
        case Span(None, Some((high @ _))) => k.$less$eq(high)
        case _ => false
      }
    }
  }
}, pt = ?
exception when typing package com {
  package mosol {
    package sl {
      case class Span[K >: scala.this.All <: scala.this.Ordered[K]] extends Function1[K, boolean] with scala.Sca\
laObject with scala.CaseClas
s {
        private    val low : Option[K] = _;
        private    val high : Option[K] = _;
         def this(low: Option[K], high: Option[K]): sl.this.Span[K] = Span.super.this();
         def apply(k: K): scala.this.Boolean = this match {
          case Span(Some((low @ _)), Some((high @ _))) => k.$greater$eq(low).$amp$amp(k.$less$eq(high))
          case Span(Some((low @ _)), None) => k.$greater$eq(low)
          case Span(None, Some((high @ _))) => k.$less$eq(high)
          case _ => false
        }
      }
    }
  }
}, pt = ?
Exception in thread "main" java.lang.NullPointerException
        at scala.tools.nsc.symtab.Types$TypeVar.toString(Types.scala:948)
        at java.lang.String.valueOf(Unknown Source)
        at java.lang.StringBuffer.append(Unknown Source)
        at scala.Seq$class.mkString(Seq.scala:196)
        at scala.List.mkString(List.scala:369)
        at scala.tools.nsc.symtab.Types$TypeRef.toString(Types.scala:861)
        at java.lang.String.valueOf(Unknown Source)
        at java.lang.StringBuffer.append(Unknown Source)
        at scala.Seq$class.mkString(Seq.scala:196)
        at scala.List.mkString(List.scala:369)
        at scala.Seq$class.toString(Seq.scala:176)
        at scala.List.toString(List.scala:369)
        at java.lang.String.valueOf(Unknown Source)
        at java.lang.StringBuffer.append(Unknown Source)
        at scala.tools.nsc.symtab.Types$class.glb(Types.scala:1974)
        at scala.tools.nsc.symtab.SymbolTable.glb(SymbolTable.scala:10)
        at scala.tools.nsc.typechecker.Infer$class.solveOne$0(Infer.scala:130)
        at scala.tools.nsc.typechecker.Infer$$anonfun$9.apply(Infer.scala:133)
        at scala.tools.nsc.typechecker.Infer$$anonfun$9.apply(Infer.scala:133)
        at scala.List.foreach(List.scala:681)
        at scala.tools.nsc.typechecker.Infer$class.scala$tools$nsc$typechecker$Infer$$solve(Infer.scala:133)
        at scala.tools.nsc.typechecker.Infer$Inferencer.computeArgs$0(Infer.scala:516)
        at scala.tools.nsc.typechecker.Infer$Inferencer.inferConstructorInstance(Infer.scala:532)
        at scala.tools.nsc.typechecker.Typers$Typer.adapt(Typers.scala:406)
        at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:1611)
        at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:1484)
        at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:1609)
        at scala.tools.nsc.typechecker.Typers$Typer.typedPattern(Typers.scala:1651)
        at scala.tools.nsc.typechecker.Typers$Typer.typedCase(Typers.scala:865)
        at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$36.apply(Typers.scala:885)
        at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$36.apply(Typers.scala:884)
        at scala.List$.loop$0(List.scala:232)
        at scala.List$.mapConserve(List.scala:249)
        at scala.tools.nsc.typechecker.Typers$Typer.typedCases(Typers.scala:884)
        at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:1405)
        at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:1609)
        at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:1639)
        at scala.tools.nsc.typechecker.Typers$Typer.transformedOrTyped(Typers.scala:1673)
        at scala.tools.nsc.typechecker.Typers$Typer.typedDefDef(Typers.scala:812)
        at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:1288)
        at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:1609)
        at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:1635)
        at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$43.apply(Typers.scala:959)
        at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$43.apply(Typers.scala:949)
        at scala.List$.loop$0(List.scala:232)
        at scala.List$.mapConserve(List.scala:249)
        at scala.List$.loop$0(List.scala:236)
        at scala.List$.mapConserve(List.scala:249)
        at scala.List$.loop$0(List.scala:236)
        at scala.List$.mapConserve(List.scala:249)
        at scala.List$.loop$0(List.scala:236)
        at scala.List$.mapConserve(List.scala:249)
        at scala.tools.nsc.typechecker.Typers$Typer.typedStats(Typers.scala:949)
        at scala.tools.nsc.typechecker.Typers$Typer.typedTemplate(Typers.scala:686)
        at scala.tools.nsc.typechecker.Typers$Typer.typedClassDef(Typers.scala:624)
        at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:1279)
        at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:1609)
        at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:1635)
        at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$43.apply(Typers.scala:959)
        at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$43.apply(Typers.scala:949)
        at scala.List$.loop$0(List.scala:232)
        at scala.List$.mapConserve(List.scala:249)
        at scala.tools.nsc.typechecker.Typers$Typer.typedStats(Typers.scala:949)
        at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:1275)
        at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:1609)
        at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:1635)
        at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$43.apply(Typers.scala:959)
        at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$43.apply(Typers.scala:949)
        at scala.List$.loop$0(List.scala:232)
        at scala.List$.mapConserve(List.scala:249)
        at scala.tools.nsc.typechecker.Typers$Typer.typedStats(Typers.scala:949)
        at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:1275)
        at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:1609)
        at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:1635)
        at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$43.apply(Typers.scala:959)
        at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$43.apply(Typers.scala:949)
        at scala.List$.loop$0(List.scala:232)
        at scala.List$.mapConserve(List.scala:249)
        at scala.tools.nsc.typechecker.Typers$Typer.typedStats(Typers.scala:949)
        at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:1275)
        at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:1609)
        at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:1635)
        at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$1.apply(Analyzer.scala:38)
        at scala.tools.nsc.Global$GlobalPhase.applyPhase(Global.scala:213)
        at scala.tools.nsc.Global$GlobalPhase$$anonfun$1.apply(Global.scala:202)
        at scala.tools.nsc.Global$GlobalPhase$$anonfun$1.apply(Global.scala:202)
        at scala.Iterator$class.foreach(Iterator.scala:285)
        at scala.collection.mutable.ListBuffer$$anon$0.foreach(ListBuffer.scala:216)
        at scala.tools.nsc.Global$GlobalPhase.run(Global.scala:202)
        at scala.tools.nsc.Global$Run.compileSources(Global.scala:432)
        at scala.tools.nsc.Global$Run.compile(Global.scala:490)
        at scala.tools.nsc.Main$.process(Main.scala:60)
        at scala.tools.nsc.Main$.main(Main.scala:82)
        at scala.tools.nsc.Main.main(Main.scala)

[H:\work.32\SL]
what expected I don't think there is an error is this code fragment (but perhaps there is). I would expect compilation.
[back to overview]
Changes of this bug report
Nikolay  edited on  2006-05-18 17:13:48.0
Nikolay  edited on  2006-05-18 17:36:08.0
Martin  edited on  2006-05-19 15:23:45.0