Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ill-typed code crashes hard in adaptToImplicitMethod #5803

Closed
scabug opened this issue May 17, 2012 · 5 comments
Closed

Ill-typed code crashes hard in adaptToImplicitMethod #5803

scabug opened this issue May 17, 2012 · 5 comments

Comments

@scabug
Copy link

scabug commented May 17, 2012

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)
@scabug
Copy link
Author

scabug commented May 17, 2012

Imported From: https://issues.scala-lang.org/browse/SI-5803?orig=1
Reporter: @retronym
Affected Versions: 2.10.0
Other Milestones: 2.10.0

@scabug
Copy link
Author

scabug commented May 17, 2012

@retronym said:

  ~/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:

scala/scala@cfd0372...58f6a13

@scabug
Copy link
Author

scabug commented May 17, 2012

@retronym said:
Looks like this one:

scala/scala@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

@scabug
Copy link
Author

scabug commented May 17, 2012

@retronym said:

  // 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

@scabug
Copy link
Author

scabug commented May 17, 2012

@retronym said:
Temporary solution:

scala/scala#562

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants