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

Ill-typed code crashes hard in adaptToImplicitMethod

    Details

      Description

      object Test {
        class Foo()(implicit ev: Any)
        new Foo(): String
      }
      

      Regression occurred after 2.10.0-M3, I'm trying to pinpoint it now.

      Error:

        ~/code/scratch scalac210 /Users/jason/code/scratch/either.scala 
      error: 
           while compiling:  /Users/jason/code/scratch/either.scala
             current phase:  typer
           library version:  version 2.10.0-20120504-065643-e52be82eef
          compiler version:  version 2.10.0-20120504-065643-e52be82eef
        reconstructed args:  
      
      uncaught exception during compilation: java.lang.AssertionError
      error: java.lang.AssertionError: assertion failed: 
           while compiling:  /Users/jason/code/scratch/either.scala
             current phase:  typer
           library version:  version 2.10.0-20120504-065643-e52be82eef
          compiler version:  version 2.10.0-20120504-065643-e52be82eef
        reconstructed args:  
      
      class scala.reflect.api.Trees$Apply
      	at scala.tools.nsc.ast.Trees$ResetAttrs.transform(Trees.scala:365)
      	at scala.tools.nsc.ast.Trees$class.resetAllAttrs(Trees.scala:267)
      	at scala.tools.nsc.Global.resetAllAttrs(Global.scala:34)
      	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$adaptToImplicitMethod$1$1.apply(Typers.scala:857)
      	at scala.tools.nsc.typechecker.Typers$Typer.adaptToImplicitMethod$1(Typers.scala:846)
      	at scala.tools.nsc.typechecker.Typers$Typer.adapt(Typers.scala:1070)
      	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5014)
      	at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:4788)
      	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5005)
      	at scala.tools.nsc.typechecker.Typers$Typer.typedStat$1(Typers.scala:2558)
      	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$59$$anonfun$60.apply(Typers.scala:2654)
      	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$59$$anonfun$60.apply(Typers.scala:2654)
      	at scala.collection.immutable.List.loop$1(List.scala:163)
      	at scala.collection.immutable.List.mapConserve(List.scala:179)
      	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$59.apply(Typers.scala:2654)
      	at scala.tools.nsc.typechecker.Typers$Typer.typedStats(Typers.scala:2653)
      	at scala.tools.nsc.typechecker.Typers$Typer.typedTemplate(Typers.scala:1718)
      	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$40.apply(Typers.scala:1626)
      	at scala.tools.nsc.typechecker.Typers$Typer.typedModuleDef(Typers.scala:1625)
      	at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:4646)
      	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5005)
      	at scala.tools.nsc.typechecker.Typers$Typer.typedStat$1(Typers.scala:2558)
      	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$59$$anonfun$60.apply(Typers.scala:2654)
      	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$59$$anonfun$60.apply(Typers.scala:2654)
      	at scala.collection.immutable.List.loop$1(List.scala:163)
      	at scala.collection.immutable.List.mapConserve(List.scala:179)
      	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$59.apply(Typers.scala:2654)
      	at scala.tools.nsc.typechecker.Typers$Typer.typedStats(Typers.scala:2653)
      	at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:4639)
      	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5005)
      	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5063)
      	at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3.apply(Analyzer.scala:97)
      	at scala.tools.nsc.Global$GlobalPhase.applyPhase(Global.scala:430)
      	at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3$$anonfun$run$1.apply(Analyzer.scala:89)
      	at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3$$anonfun$run$1.apply(Analyzer.scala:89)
      	at scala.collection.Iterator$class.foreach(Iterator.scala:706)
      	at scala.collection.AbstractIterator.foreach(Iterator.scala:1133)
      	at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3.run(Analyzer.scala:89)
      	at scala.tools.nsc.Global$Run.compileUnitsInternal(Global.scala:1344)
      	at scala.tools.nsc.Global$Run.compileUnits(Global.scala:1317)
      	at scala.tools.nsc.Global$Run.compileSources(Global.scala:1311)
      	at scala.tools.nsc.Global$Run.compile(Global.scala:1444)
      	at scala.tools.nsc.Driver.doCompile(Driver.scala:31)
      	at scala.tools.nsc.Main$.doCompile(Main.scala:81)
      	at scala.tools.nsc.Driver.process(Driver.scala:52)
      	at scala.tools.nsc.Driver.main(Driver.scala:65)
      	at scala.tools.nsc.Main.main(Main.scala)
      
      Exception in thread "main" java.lang.AssertionError: assertion failed: 
           while compiling:  /Users/jason/code/scratch/either.scala
             current phase:  typer
           library version:  version 2.10.0-20120504-065643-e52be82eef
          compiler version:  version 2.10.0-20120504-065643-e52be82eef
        reconstructed args:  
      
      class scala.reflect.api.Trees$Apply
      	at scala.tools.nsc.ast.Trees$ResetAttrs.transform(Trees.scala:365)
      	at scala.tools.nsc.ast.Trees$class.resetAllAttrs(Trees.scala:267)
      	at scala.tools.nsc.Global.resetAllAttrs(Global.scala:34)
      	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$adaptToImplicitMethod$1$1.apply(Typers.scala:857)
      	at scala.tools.nsc.typechecker.Typers$Typer.adaptToImplicitMethod$1(Typers.scala:846)
      	at scala.tools.nsc.typechecker.Typers$Typer.adapt(Typers.scala:1070)
      	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5014)
      	at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:4788)
      	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5005)
      	at scala.tools.nsc.typechecker.Typers$Typer.typedStat$1(Typers.scala:2558)
      	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$59$$anonfun$60.apply(Typers.scala:2654)
      	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$59$$anonfun$60.apply(Typers.scala:2654)
      	at scala.collection.immutable.List.loop$1(List.scala:163)
      	at scala.collection.immutable.List.mapConserve(List.scala:179)
      	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$59.apply(Typers.scala:2654)
      	at scala.tools.nsc.typechecker.Typers$Typer.typedStats(Typers.scala:2653)
      	at scala.tools.nsc.typechecker.Typers$Typer.typedTemplate(Typers.scala:1718)
      	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$40.apply(Typers.scala:1626)
      	at scala.tools.nsc.typechecker.Typers$Typer.typedModuleDef(Typers.scala:1625)
      	at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:4646)
      	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5005)
      	at scala.tools.nsc.typechecker.Typers$Typer.typedStat$1(Typers.scala:2558)
      	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$59$$anonfun$60.apply(Typers.scala:2654)
      	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$59$$anonfun$60.apply(Typers.scala:2654)
      	at scala.collection.immutable.List.loop$1(List.scala:163)
      	at scala.collection.immutable.List.mapConserve(List.scala:179)
      	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$59.apply(Typers.scala:2654)
      	at scala.tools.nsc.typechecker.Typers$Typer.typedStats(Typers.scala:2653)
      	at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:4639)
      	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5005)
      	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5063)
      	at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3.apply(Analyzer.scala:97)
      	at scala.tools.nsc.Global$GlobalPhase.applyPhase(Global.scala:430)
      	at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3$$anonfun$run$1.apply(Analyzer.scala:89)
      	at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3$$anonfun$run$1.apply(Analyzer.scala:89)
      	at scala.collection.Iterator$class.foreach(Iterator.scala:706)
      	at scala.collection.AbstractIterator.foreach(Iterator.scala:1133)
      	at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3.run(Analyzer.scala:89)
      	at scala.tools.nsc.Global$Run.compileUnitsInternal(Global.scala:1344)
      	at scala.tools.nsc.Global$Run.compileUnits(Global.scala:1317)
      	at scala.tools.nsc.Global$Run.compileSources(Global.scala:1311)
      	at scala.tools.nsc.Global$Run.compile(Global.scala:1444)
      	at scala.tools.nsc.Driver.doCompile(Driver.scala:31)
      	at scala.tools.nsc.Main$.doCompile(Main.scala:81)
      	at scala.tools.nsc.Driver.process(Driver.scala:52)
      	at scala.tools.nsc.Driver.main(Driver.scala:65)
      	at scala.tools.nsc.Main.main(Main.scala)
      

        Activity

        Hide
        Jason Zaugg added a comment -
          ~/code/scratch for f in ~/usr/scala*; do echo $f; $f/bin/scalac either.scala 2>&1 | grep -i "exception"; done
        /Users/jason/usr/scala-2.10.0-20120425-140228-8f3f0724f9
        /Users/jason/usr/scala-2.10.0-20120427-100603-399ab16c29
        /Users/jason/usr/scala-2.10.0-20120428-143539-774cd4f87b
        /Users/jason/usr/scala-2.10.0-20120428-232041-e6d5d22d28
        /Users/jason/usr/scala-2.10.0-20120430-094203-cfd037271e
        /Users/jason/usr/scala-2.10.0-20120503-160535-58f6a13460
        uncaught exception during compilation: java.lang.AssertionError
        Exception in thread "main" java.lang.AssertionError: assertion failed: 
        /Users/jason/usr/scala-2.10.0-20120504-065643-e52be82eef
        uncaught exception during compilation: java.lang.AssertionError
        Exception in thread "main" java.lang.AssertionError: assertion failed: 
        

        There was a short gap in the nightly builds at the beginning of May, Murphy's law dictates that the regression lies therein:

        https://github.com/scala/scala/compare/cfd037271e...58f6a13460

        Show
        Jason Zaugg added a comment - ~/code/scratch for f in ~/usr/scala*; do echo $f; $f/bin/scalac either.scala 2>&1 | grep -i "exception"; done /Users/jason/usr/scala-2.10.0-20120425-140228-8f3f0724f9 /Users/jason/usr/scala-2.10.0-20120427-100603-399ab16c29 /Users/jason/usr/scala-2.10.0-20120428-143539-774cd4f87b /Users/jason/usr/scala-2.10.0-20120428-232041-e6d5d22d28 /Users/jason/usr/scala-2.10.0-20120430-094203-cfd037271e /Users/jason/usr/scala-2.10.0-20120503-160535-58f6a13460 uncaught exception during compilation: java.lang.AssertionError Exception in thread "main" java.lang.AssertionError: assertion failed: /Users/jason/usr/scala-2.10.0-20120504-065643-e52be82eef uncaught exception during compilation: java.lang.AssertionError Exception in thread "main" java.lang.AssertionError: assertion failed: There was a short gap in the nightly builds at the beginning of May, Murphy's law dictates that the regression lies therein: https://github.com/scala/scala/compare/cfd037271e...58f6a13460
        Hide
        Jason Zaugg added a comment -

        Looks like this one:

        https://github.com/scala/scala/commit/ae5ff66

        (bisect/bad) ~/code/scala git bisect log
        # bad: [58f6a1346093db2f407879246884d480ff8d7904] Fix for SI-3718.
        # good: [cfd037271ebf96b977d4ef06dbcd7814cfcc20a0] Merge branch 'apr30-checkin' of /scala/trunk into develop
        git bisect start '58f6a13460' 'cfd037271e'
        # bad: [4b8c54cd9e52dbacc239d05c8149d7f249bbebab] Merge commit 'refs/pull/457/head'; commit 'refs/pull/458/head'; commit 'refs/pull/459/head'; commit 'refs/pull/460/head'; commit 'refs/pull/461/head'; commit 'refs/pull/462/head'; commit 'refs/pull/463/head'; commit 'refs/pull/464/head'; commit 'refs/pull/465/head' into develop
        git bisect bad 4b8c54cd9e52dbacc239d05c8149d7f249bbebab
        # bad: [89d069792717c206da21abecf3f825756182f465] un-cps expected type in translateMatch
        git bisect bad 89d069792717c206da21abecf3f825756182f465
        # good: [15e05a400be378b012903411179f2a4114f890ef] A little clarity for AddInterfaces.
        git bisect good 15e05a400be378b012903411179f2a4114f890ef
        # bad: [b27abca41a2503747b3aeeecf8b8cb355159265f] tpe -> tpeHK here and there.
        git bisect bad b27abca41a2503747b3aeeecf8b8cb355159265f
        # bad: [e69ee3676dec6023a0d552a6dbabf9ffd29a7111] Hackaround for people who like to instantiate the uninstantiable.
        git bisect bad e69ee3676dec6023a0d552a6dbabf9ffd29a7111
        # bad: [ae5ff6628bb74c16d871a2ada0664cdd5d2399a5] Fixes #SI-5578. ResetAttrs shouldn't be side-effecting on the original tree, since it can lead to NPEs in erroneous trees (or maybe even for valid ones?). Review by @odersky
        git bisect bad ae5ff6628bb74c16d871a2ada0664cdd5d2399a5
        
        Show
        Jason Zaugg added a comment - Looks like this one: https://github.com/scala/scala/commit/ae5ff66 (bisect/bad) ~/code/scala git bisect log # bad: [58f6a1346093db2f407879246884d480ff8d7904] Fix for SI-3718. # good: [cfd037271ebf96b977d4ef06dbcd7814cfcc20a0] Merge branch 'apr30-checkin' of /scala/trunk into develop git bisect start '58f6a13460' 'cfd037271e' # bad: [4b8c54cd9e52dbacc239d05c8149d7f249bbebab] Merge commit 'refs/pull/457/head'; commit 'refs/pull/458/head'; commit 'refs/pull/459/head'; commit 'refs/pull/460/head'; commit 'refs/pull/461/head'; commit 'refs/pull/462/head'; commit 'refs/pull/463/head'; commit 'refs/pull/464/head'; commit 'refs/pull/465/head' into develop git bisect bad 4b8c54cd9e52dbacc239d05c8149d7f249bbebab # bad: [89d069792717c206da21abecf3f825756182f465] un-cps expected type in translateMatch git bisect bad 89d069792717c206da21abecf3f825756182f465 # good: [15e05a400be378b012903411179f2a4114f890ef] A little clarity for AddInterfaces. git bisect good 15e05a400be378b012903411179f2a4114f890ef # bad: [b27abca41a2503747b3aeeecf8b8cb355159265f] tpe -> tpeHK here and there. git bisect bad b27abca41a2503747b3aeeecf8b8cb355159265f # bad: [e69ee3676dec6023a0d552a6dbabf9ffd29a7111] Hackaround for people who like to instantiate the uninstantiable. git bisect bad e69ee3676dec6023a0d552a6dbabf9ffd29a7111 # bad: [ae5ff6628bb74c16d871a2ada0664cdd5d2399a5] Fixes #SI-5578. ResetAttrs shouldn't be side-effecting on the original tree, since it can lead to NPEs in erroneous trees (or maybe even for valid ones?). Review by @odersky git bisect bad ae5ff6628bb74c16d871a2ada0664cdd5d2399a5
        Hide
        Jason Zaugg added a comment -
          // TODO: use a factory method, not a class (???)
          // as a case in point of the comment that should go here by similarity to ApplyToImplicitArgs,
          // this tree is considered in importers, but not in treecopier
          class ApplyConstructor(tpt: Tree, args: List[Tree]) extends Apply(Select(New(tpt), nme.CONSTRUCTOR), args) {
        

        https://github.com/scala/scala/blob/ae5ff662/src/library/scala/reflect/api/Trees.scala#L650

        Show
        Jason Zaugg added a comment - // TODO: use a factory method, not a class (???) // as a case in point of the comment that should go here by similarity to ApplyToImplicitArgs, // this tree is considered in importers, but not in treecopier class ApplyConstructor(tpt: Tree, args: List[Tree]) extends Apply(Select(New(tpt), nme.CONSTRUCTOR), args) { https://github.com/scala/scala/blob/ae5ff662/src/library/scala/reflect/api/Trees.scala#L650
        Hide
        Jason Zaugg added a comment -
        Show
        Jason Zaugg added a comment - Temporary solution: https://github.com/scala/scala/pull/562

          People

          • Assignee:
            Jason Zaugg
            Reporter:
            Jason Zaugg
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development