Scala Programming Language
  1. Scala Programming Language
  2. SI-7185

Compiler crashes when evaluating XML element followed by "()"

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: Scala 2.10.0
    • Fix Version/s: Scala 2.10.2-RC1
    • Component/s: XML Support
    • Environment:

      Scala 2.10.0
      OpenJDK 64-Bit Server VM, Java 1.7.0_09-icedtea
      Linux 3.2

      Description

      When Scala compiler evaluates XML element followed by "()" (without quotes), it crashes with NullPointerException.

      It will be more helpful to generate a compilation error.

      Welcome to Scala version 2.10.0 (OpenJDK 64-Bit Server VM, Java 1.7.0_09-icedtea).
      Type in expressions to have them evaluated.
      Type :help for more information.
      
      scala> <e></e>()
      <console>:8: error: overloaded method value apply with alternatives:
        (f: scala.xml.Node => Boolean)scala.xml.NodeSeq <and>
        (i: Int)scala.xml.Node
       cannot be applied to ()
             <e></e>()
              ^
      error:
           while compiling: <console>
              during phase: typer
           library version: version 2.10.0
          compiler version: version 2.10.0
        reconstructed args:
      
        last tree to typer: Apply(constructor Elem)
                    symbol: constructor Elem in class Elem (flags: <method>)
         symbol definition: def <init>(prefix: String,label: String,attributes1: scala.xml.MetaData,scope: scala.xml.NamespaceBinding,minimizeEmpty: Boolean,child: scala.xml.Node*): scala.xml.Elem
                       tpe: scala.xml.Elem
             symbol owners: constructor Elem -> class Elem -> package xml
            context owners: value res0 -> object $iw -> object $iw -> object $read -> package $line3
      
      ...
      
      TypeRef(TypeSymbol(class Elem extends Node with Serializable))
      
      uncaught exception during compilation: java.lang.NullPointerException
      java.lang.NullPointerException
              at scala.reflect.internal.TreeInfo.isExprSafeToInline(TreeInfo.scala:98)
              at scala.reflect.internal.TreeInfo.isExprSafeToInline(TreeInfo.scala:102)
              at scala.tools.nsc.typechecker.Typers$Typer.typedBlock(Typers.scala:2343)
              at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5387)
              at scala.tools.nsc.typechecker.Typers$Typer.typedApply$1(Typers.scala:4507)
              at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5381)
              at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5458)
              at scala.tools.nsc.interpreter.ReplGlobal$$anon$1$$anon$2.typed(ReplGlobal.scala:29)
              at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5526)
              at scala.tools.nsc.typechecker.Typers$Typer.computeType(Typers.scala:5621)
              at scala.tools.nsc.typechecker.Namers$Namer.assignTypeToTree(Namers.scala:813)
              at scala.tools.nsc.typechecker.Namers$Namer.getSig$1(Namers.scala:1319)
              at scala.tools.nsc.typechecker.Namers$Namer.typeSig(Namers.scala:1347)
              at scala.tools.nsc.typechecker.Namers$Namer$$anonfun$monoTypeCompleter$1$$anonfun$apply$1.apply$mcV$sp(Namers.scala:709)
              at scala.tools.nsc.typechecker.Namers$Namer$$anonfun$monoTypeCompleter$1$$anonfun$apply$1.apply(Namers.scala:708)
              at scala.tools.nsc.typechecker.Namers$Namer$$anonfun$monoTypeCompleter$1$$anonfun$apply$1.apply(Namers.scala:708)
              at scala.tools.nsc.typechecker.Namers$Namer.scala$tools$nsc$typechecker$Namers$Namer$$logAndValidate(Namers.scala:1385)
              at scala.tools.nsc.typechecker.Namers$Namer$$anonfun$monoTypeCompleter$1.apply(Namers.scala:708)
              at scala.tools.nsc.typechecker.Namers$Namer$$anonfun$monoTypeCompleter$1.apply(Namers.scala:707)
              at scala.tools.nsc.typechecker.Namers$$anon$1.completeImpl(Namers.scala:1496)
              at scala.tools.nsc.typechecker.Namers$LockingTypeCompleter$class.complete(Namers.scala:1504)
              at scala.tools.nsc.typechecker.Namers$$anon$1.complete(Namers.scala:1494)
              at scala.reflect.internal.Symbols$Symbol.info(Symbols.scala:1217)
              at scala.reflect.internal.Symbols$Symbol.initialize(Symbols.scala:1352)
              at scala.tools.nsc.typechecker.MethodSynthesis$MethodSynth$class.addDerivedTrees(MethodSynthesis.scala:224)
              at scala.tools.nsc.typechecker.Namers$Namer.addDerivedTrees(Namers.scala:55)
              at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$29.apply(Typers.scala:1860)
              at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$29.apply(Typers.scala:1860)
              at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$rewrappingWrapperTrees$1.apply(Typers.scala:1798)
              at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$rewrappingWrapperTrees$1.apply(Typers.scala:1795)
              at scala.collection.TraversableLike$$anonfun$flatMap$1.apply(TraversableLike.scala:251)
              at scala.collection.TraversableLike$$anonfun$flatMap$1.apply(TraversableLike.scala:251)
              at scala.collection.immutable.List.foreach(List.scala:309)
              at scala.collection.TraversableLike$class.flatMap(TraversableLike.scala:251)
              at scala.collection.AbstractTraversable.flatMap(Traversable.scala:105)
              at scala.tools.nsc.typechecker.Typers$Typer.typedTemplate(Typers.scala:1860)
              at scala.tools.nsc.typechecker.Typers$Typer.typedModuleDef(Typers.scala:1769)
              at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5401)
              at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5458)
              at scala.tools.nsc.interpreter.ReplGlobal$$anon$1$$anon$2.typed(ReplGlobal.scala:29)
              at scala.tools.nsc.typechecker.Typers$Typer.scala$tools$nsc$typechecker$Typers$Typer$$typedStat$1(Typers.scala:2770)
              at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$55.apply(Typers.scala:2870)
              at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$55.apply(Typers.scala:2870)
              at scala.collection.immutable.List.loop$1(List.scala:164)
              at scala.collection.immutable.List.mapConserve(List.scala:180)
              at scala.tools.nsc.typechecker.Typers$Typer.typedStats(Typers.scala:2870)
              at scala.tools.nsc.typechecker.Typers$Typer.typedTemplate(Typers.scala:1862)
              at scala.tools.nsc.typechecker.Typers$Typer.typedModuleDef(Typers.scala:1769)
              at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5401)
              at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5458)
              at scala.tools.nsc.interpreter.ReplGlobal$$anon$1$$anon$2.typed(ReplGlobal.scala:29)
              at scala.tools.nsc.typechecker.Typers$Typer.scala$tools$nsc$typechecker$Typers$Typer$$typedStat$1(Typers.scala:2770)
              at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$55.apply(Typers.scala:2870)
              at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$55.apply(Typers.scala:2870)
              at scala.collection.immutable.List.loop$1(List.scala:164)
              at scala.collection.immutable.List.mapConserve(List.scala:180)
              at scala.tools.nsc.typechecker.Typers$Typer.typedStats(Typers.scala:2870)
              at scala.tools.nsc.typechecker.Typers$Typer.typedTemplate(Typers.scala:1862)
              at scala.tools.nsc.typechecker.Typers$Typer.typedModuleDef(Typers.scala:1769)
              at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5401)
              at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5458)
              at scala.tools.nsc.interpreter.ReplGlobal$$anon$1$$anon$2.typed(ReplGlobal.scala:29)
              at scala.tools.nsc.typechecker.Typers$Typer.scala$tools$nsc$typechecker$Typers$Typer$$typedStat$1(Typers.scala:2770)
              at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$55.apply(Typers.scala:2870)
              at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$55.apply(Typers.scala:2870)
              at scala.collection.immutable.List.loop$1(List.scala:164)
              at scala.collection.immutable.List.mapConserve(List.scala:180)
              at scala.tools.nsc.typechecker.Typers$Typer.typedStats(Typers.scala:2870)
              at scala.tools.nsc.typechecker.Typers$Typer.typedPackageDef$1(Typers.scala:5127)
              at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5404)
              at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5458)
              at scala.tools.nsc.interpreter.ReplGlobal$$anon$1$$anon$2.typed(ReplGlobal.scala:29)
              at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5509)
              at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3.apply(Analyzer.scala:98)
              at scala.tools.nsc.Global$GlobalPhase.applyPhase(Global.scala:461)
              at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3$$anonfun$run$1.apply(Analyzer.scala:90)
              at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3$$anonfun$run$1.apply(Analyzer.scala:90)
              at scala.collection.Iterator$class.foreach(Iterator.scala:727)
              at scala.collection.AbstractIterator.foreach(Iterator.scala:1156)
              at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3.run(Analyzer.scala:90)
              at scala.tools.nsc.Global$Run.compileUnitsInternal(Global.scala:1574)
              at scala.tools.nsc.Global$Run.compileUnits(Global.scala:1548)
              at scala.tools.nsc.Global$Run.compileSources(Global.scala:1544)
              at scala.tools.nsc.interpreter.IMain.compileSourcesKeepingRun(IMain.scala:425)
              at scala.tools.nsc.interpreter.IMain$ReadEvalPrint.compileAndSaveRun(IMain.scala:798)
              at scala.tools.nsc.interpreter.IMain$ReadEvalPrint.compile(IMain.scala:758)
              at scala.tools.nsc.interpreter.IMain$Request.compile$lzycompute(IMain.scala:933)
              at scala.tools.nsc.interpreter.IMain$Request.compile(IMain.scala:928)
              at scala.tools.nsc.interpreter.IMain.interpret(IMain.scala:600)
              at scala.tools.nsc.interpreter.IMain.interpret(IMain.scala:565)
              at scala.tools.nsc.interpreter.ILoop.reallyInterpret$1(ILoop.scala:745)
              at scala.tools.nsc.interpreter.ILoop.interpretStartingWith(ILoop.scala:790)
              at scala.tools.nsc.interpreter.ILoop.command(ILoop.scala:702)
              at scala.tools.nsc.interpreter.ILoop.processLine$1(ILoop.scala:566)
              at scala.tools.nsc.interpreter.ILoop.innerLoop$1(ILoop.scala:573)
              at scala.tools.nsc.interpreter.ILoop.loop(ILoop.scala:576)
              at scala.tools.nsc.interpreter.ILoop$$anonfun$process$1.apply$mcZ$sp(ILoop.scala:867)
              at scala.tools.nsc.interpreter.ILoop$$anonfun$process$1.apply(ILoop.scala:822)
              at scala.tools.nsc.interpreter.ILoop$$anonfun$process$1.apply(ILoop.scala:822)
              at scala.tools.nsc.util.ScalaClassLoader$.savingContextLoader(ScalaClassLoader.scala:135)
              at scala.tools.nsc.interpreter.ILoop.process(ILoop.scala:822)
              at scala.tools.nsc.MainGenericRunner.runTarget$1(MainGenericRunner.scala:83)
              at scala.tools.nsc.MainGenericRunner.process(MainGenericRunner.scala:96)
              at scala.tools.nsc.MainGenericRunner$.main(MainGenericRunner.scala:105)
              at scala.tools.nsc.MainGenericRunner.main(MainGenericRunner.scala)
      
      

        Activity

        Show
        Jason Zaugg added a comment - https://github.com/scala/scala/pull/2175

          People

          • Assignee:
            Jason Zaugg
            Reporter:
            Howard Guo
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development