Aladdin - Scala Bugtracking
[#686] project: compiler priority: low category: bug
submitter assigned to status date submitted
Burak Nikolay fixed 2006-08-01 19:09:40.0
subject NPE after erroneous attribute use
code
object gaga {
  class gugu(x:int) extends scala.Attribute

  [gugu(1,2)]
  def foo: unit = {}
}
what happened
[emir@lamppc31 xmlLibraryPush]$ scalac -d /tmp/ /tmp/gaga.scala
/tmp/gaga.scala:4 error: wrong number of arguments for constructor gugu: (scala.Int)gaga.this.gugu
  [gugu(1,2)]
   ^
Exception in thread "main" java.lang.NullPointerException
        at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$58.apply(Typers.scala:1130)
        at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$58.apply(Typers.scala:1126)
        at scala.List.map(List.scala:651)
        at scala.tools.nsc.typechecker.Typers$Typer.attributes(Typers.scala:1126)
        at scala.tools.nsc.typechecker.Typers$Typer.typedDefDef(Typers.scala:784)
        at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:1447)
        at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:1764)
        at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:1791)
        at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$46.apply(Typers.scala:1004)
        at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$46.apply(Typers.scala:994)
        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.tools.nsc.typechecker.Typers$Typer.typedStats(Typers.scala:994)
        at scala.tools.nsc.typechecker.Typers$Typer.typedTemplate(Typers.scala:709)
        at scala.tools.nsc.typechecker.Typers$Typer.typedModuleDef(Typers.scala:648)
        at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:1441)
        at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:1764)
        at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:1791)
        at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$46.apply(Typers.scala:1004)
        at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$46.apply(Typers.scala:994)
        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:994)
        at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:1434)
        at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:1764)
        at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:1791)
        at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$1.apply(Analyzer.scala:38)
        at scala.tools.nsc.Global$GlobalPhase.applyPhase(Global.scala:216)
        at scala.tools.nsc.Global$GlobalPhase$$anonfun$1.apply(Global.scala:205)
        at scala.tools.nsc.Global$GlobalPhase$$anonfun$1.apply(Global.scala:205)
        at scala.Iterator$class.foreach(Iterator.scala:304)
        at scala.collection.mutable.ListBuffer$$anon$0.foreach(ListBuffer.scala:216)
        at scala.tools.nsc.Global$GlobalPhase.run(Global.scala:205)
        at scala.tools.nsc.Global$Run.compileSources(Global.scala:467)
        at scala.tools.nsc.Global$Run.compile(Global.scala:531)
        at scala.tools.nsc.Main$.process(Main.scala:76)
        at scala.tools.nsc.Main$.main(Main.scala:98)
        at scala.tools.nsc.Main.main(Main.scala)
what expected no NPE after the error message.
[back to overview]
Changes of this bug report
Nikolay  edited on  2006-08-09 12:12:35.0
The tree for the attribute application is not attributed. Strangely, this only happens when the attribute definition is nested in a class/object. Move it out and it doesn't crash. I wonder if defining an attribute class inside another makes any sense.
Martin  edited on  2006-08-20 13:32:06.0
This might be related to the non-standard handling to atrtributes in the typer.
Nikolay  edited on  2007-02-27 16:35:17.0
I simply avoid the additional annotation checks if there's sth wrong with the annotation application.