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

NullPointerException in typer involving named arguments #9818

Closed
scabug opened this issue Jun 14, 2016 · 1 comment · Fixed by scala/scala#7058
Closed

NullPointerException in typer involving named arguments #9818

scabug opened this issue Jun 14, 2016 · 1 comment · Fixed by scala/scala#7058

Comments

@scabug
Copy link

scabug commented Jun 14, 2016

The following code crashes the scala compiler:

trait A {
  def g( x: Int = 0, y: Int = 1) = x + y

  def x: Int = ???

  def ref: A
}

trait B {
  def f(a: Int, b: Int = 0) = a + b

  def foo(in: A) {
    import in._

    ref.g(x = f(0))
  }
}

The error seems to be similar to #9291 but is triggered by different statements (for example the import statement is needed).

Exception stacktrace:

error: java.lang.NullPointerException
        at scala.tools.nsc.typechecker.Typers$Typer.noExpectedType$1(Typers.scala:3464)
        at scala.tools.nsc.typechecker.Typers$Typer.scala$tools$nsc$typechecker$Typers$Typer$$handleMonomorphicCall$1(Typers.scala:3467)
        at scala.tools.nsc.typechecker.Typers$Typer.doTypedApply(Typers.scala:3495)
        at scala.tools.nsc.typechecker.Typers$Typer.tryNamesDefaults$1(Typers.scala:3381)
        at scala.tools.nsc.typechecker.Typers$Typer.doTypedApply(Typers.scala:3453)
        at scala.tools.nsc.typechecker.Typers$Typer.tryNamesDefaults$1(Typers.scala:3439)
        at scala.tools.nsc.typechecker.Typers$Typer.doTypedApply(Typers.scala:3453)
        at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$98.apply(Typers.scala:4496)
        at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$98.apply(Typers.scala:4496)
        at scala.tools.nsc.typechecker.Typers$Typer.silent(Typers.scala:680)
        at scala.tools.nsc.typechecker.Typers$Typer.tryTypedApply$1(Typers.scala:4496)
        at scala.tools.nsc.typechecker.Typers$Typer.normalTypedApply$1(Typers.scala:4544)
        at scala.tools.nsc.typechecker.Typers$Typer.typedApply$1(Typers.scala:4580)
        at scala.tools.nsc.typechecker.Typers$Typer.typedInAnyMode$1(Typers.scala:5343)
        at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5360)
        at scala.tools.nsc.typechecker.Typers$Typer.runTyper$1(Typers.scala:5396)
        at scala.tools.nsc.typechecker.Typers$Typer.scala$tools$nsc$typechecker$Typers$Typer$$typedInternal(Typers.scala:5423)
        at scala.tools.nsc.typechecker.Typers$Typer.body$2(Typers.scala:5370)
        at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5374)
        at scala.tools.nsc.typechecker.Typers$Typer.typedBlock(Typers.scala:2382)
        at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$typedOutsidePatternMode$1$1.apply(Typers.scala:5318)
        at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$typedOutsidePatternMode$1$1.apply(Typers.scala:5318)
        at scala.tools.nsc.typechecker.Typers$Typer.typedOutsidePatternMode$1(Typers.scala:5317)
        at scala.tools.nsc.typechecker.Typers$Typer.typedInAnyMode$1(Typers.scala:5353)
        at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5360)
        at scala.tools.nsc.typechecker.Typers$Typer.runTyper$1(Typers.scala:5396)
        at scala.tools.nsc.typechecker.Typers$Typer.scala$tools$nsc$typechecker$Typers$Typer$$typedInternal(Typers.scala:5423)
        at scala.tools.nsc.typechecker.Typers$Typer.body$2(Typers.scala:5370)
        at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5374)
        at scala.tools.nsc.typechecker.Typers$Typer.transformedOrTyped(Typers.scala:5605)
        at scala.tools.nsc.typechecker.Typers$Typer.typedDefDef(Typers.scala:2208)
        at scala.tools.nsc.typechecker.Typers$Typer.typedMemberDef$1(Typers.scala:5308)
        at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5359)
        at scala.tools.nsc.typechecker.Typers$Typer.runTyper$1(Typers.scala:5396)
        at scala.tools.nsc.typechecker.Typers$Typer.scala$tools$nsc$typechecker$Typers$Typer$$typedInternal(Typers.scala:5423)
        at scala.tools.nsc.typechecker.Typers$Typer.body$2(Typers.scala:5370)
        at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5374)
        at scala.tools.nsc.typechecker.Typers$Typer.typedByValueExpr(Typers.scala:5452)
        at scala.tools.nsc.typechecker.Typers$Typer.scala$tools$nsc$typechecker$Typers$Typer$$typedStat$1(Typers.scala:3047)
        at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$65.apply(Typers.scala:3151)
        at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$65.apply(Typers.scala:3151)
        at scala.collection.immutable.List.loop$1(List.scala:173)
        at scala.collection.immutable.List.mapConserve(List.scala:189)
        at scala.tools.nsc.typechecker.Typers$Typer.typedStats(Typers.scala:3151)
        at scala.tools.nsc.typechecker.Typers$Typer.typedTemplate(Typers.scala:1921)
        at scala.tools.nsc.typechecker.Typers$Typer.typedClassDef(Typers.scala:1762)
        at scala.tools.nsc.typechecker.Typers$Typer.typedMemberDef$1(Typers.scala:5309)
        at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5359)
        at scala.tools.nsc.typechecker.Typers$Typer.runTyper$1(Typers.scala:5396)
        at scala.tools.nsc.typechecker.Typers$Typer.scala$tools$nsc$typechecker$Typers$Typer$$typedInternal(Typers.scala:5423)
        at scala.tools.nsc.typechecker.Typers$Typer.body$2(Typers.scala:5370)
        at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5374)
        at scala.tools.nsc.typechecker.Typers$Typer.typedByValueExpr(Typers.scala:5452)
        at scala.tools.nsc.typechecker.Typers$Typer.scala$tools$nsc$typechecker$Typers$Typer$$typedStat$1(Typers.scala:3047)
        at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$65.apply(Typers.scala:3151)
        at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$65.apply(Typers.scala:3151)
        at scala.collection.immutable.List.loop$1(List.scala:173)
        at scala.collection.immutable.List.mapConserve(List.scala:189)
        at scala.tools.nsc.typechecker.Typers$Typer.typedStats(Typers.scala:3151)
        at scala.tools.nsc.typechecker.Typers$Typer.typedPackageDef$1(Typers.scala:5015)
        at scala.tools.nsc.typechecker.Typers$Typer.typedMemberDef$1(Typers.scala:5312)
        at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5359)
        at scala.tools.nsc.typechecker.Typers$Typer.runTyper$1(Typers.scala:5396)
        at scala.tools.nsc.typechecker.Typers$Typer.scala$tools$nsc$typechecker$Typers$Typer$$typedInternal(Typers.scala:5423)
        at scala.tools.nsc.typechecker.Typers$Typer.body$2(Typers.scala:5370)
        at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5374)
        at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5448)
        at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3.apply(Analyzer.scala:102)
        at scala.tools.nsc.Global$GlobalPhase$$anonfun$applyPhase$1.apply$mcV$sp(Global.scala:440)
        at scala.tools.nsc.Global$GlobalPhase.withCurrentUnit(Global.scala:431)
        at scala.tools.nsc.Global$GlobalPhase.applyPhase(Global.scala:440)
        at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3$$anonfun$run$1.apply(Analyzer.scala:94)
        at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3$$anonfun$run$1.apply(Analyzer.scala:93)
        at scala.collection.Iterator$class.foreach(Iterator.scala:893)
        at scala.collection.AbstractIterator.foreach(Iterator.scala:1336)
        at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3.run(Analyzer.scala:93)
        at scala.tools.nsc.Global$Run.compileUnitsInternal(Global.scala:1501)
        at scala.tools.nsc.Global$Run.compileUnits(Global.scala:1486)
        at scala.tools.nsc.Global$Run.compileSources(Global.scala:1481)
        at scala.tools.nsc.Global$Run.compile(Global.scala:1582)
        at scala.tools.nsc.Driver.doCompile(Driver.scala:32)
        at scala.tools.nsc.MainClass.doCompile(Main.scala:23)
        at scala.tools.nsc.Driver.process(Driver.scala:51)
        at scala.tools.nsc.Driver.main(Driver.scala:64)
        at scala.tools.nsc.Main.main(Main.scala)
Exception in thread "main" java.lang.NullPointerException
        at scala.tools.nsc.typechecker.Typers$Typer.noExpectedType$1(Typers.scala:3464)
        at scala.tools.nsc.typechecker.Typers$Typer.scala$tools$nsc$typechecker$Typers$Typer$$handleMonomorphicCall$1(Typers.scala:3467)
        at scala.tools.nsc.typechecker.Typers$Typer.doTypedApply(Typers.scala:3495)
        at scala.tools.nsc.typechecker.Typers$Typer.tryNamesDefaults$1(Typers.scala:3381)
        at scala.tools.nsc.typechecker.Typers$Typer.doTypedApply(Typers.scala:3453)
        at scala.tools.nsc.typechecker.Typers$Typer.tryNamesDefaults$1(Typers.scala:3439)
        at scala.tools.nsc.typechecker.Typers$Typer.doTypedApply(Typers.scala:3453)
        at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$98.apply(Typers.scala:4496)
        at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$98.apply(Typers.scala:4496)
        at scala.tools.nsc.typechecker.Typers$Typer.silent(Typers.scala:680)
        at scala.tools.nsc.typechecker.Typers$Typer.tryTypedApply$1(Typers.scala:4496)
        at scala.tools.nsc.typechecker.Typers$Typer.normalTypedApply$1(Typers.scala:4544)
        at scala.tools.nsc.typechecker.Typers$Typer.typedApply$1(Typers.scala:4580)
        at scala.tools.nsc.typechecker.Typers$Typer.typedInAnyMode$1(Typers.scala:5343)
        at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5360)
        at scala.tools.nsc.typechecker.Typers$Typer.runTyper$1(Typers.scala:5396)
        at scala.tools.nsc.typechecker.Typers$Typer.scala$tools$nsc$typechecker$Typers$Typer$$typedInternal(Typers.scala:5423)
        at scala.tools.nsc.typechecker.Typers$Typer.body$2(Typers.scala:5370)
        at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5374)
        at scala.tools.nsc.typechecker.Typers$Typer.typedBlock(Typers.scala:2382)
        at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$typedOutsidePatternMode$1$1.apply(Typers.scala:5318)
        at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$typedOutsidePatternMode$1$1.apply(Typers.scala:5318)
        at scala.tools.nsc.typechecker.Typers$Typer.typedOutsidePatternMode$1(Typers.scala:5317)
        at scala.tools.nsc.typechecker.Typers$Typer.typedInAnyMode$1(Typers.scala:5353)
        at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5360)
        at scala.tools.nsc.typechecker.Typers$Typer.runTyper$1(Typers.scala:5396)
        at scala.tools.nsc.typechecker.Typers$Typer.scala$tools$nsc$typechecker$Typers$Typer$$typedInternal(Typers.scala:5423)
        at scala.tools.nsc.typechecker.Typers$Typer.body$2(Typers.scala:5370)
        at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5374)
        at scala.tools.nsc.typechecker.Typers$Typer.transformedOrTyped(Typers.scala:5605)
        at scala.tools.nsc.typechecker.Typers$Typer.typedDefDef(Typers.scala:2208)
        at scala.tools.nsc.typechecker.Typers$Typer.typedMemberDef$1(Typers.scala:5308)
        at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5359)
        at scala.tools.nsc.typechecker.Typers$Typer.runTyper$1(Typers.scala:5396)
        at scala.tools.nsc.typechecker.Typers$Typer.scala$tools$nsc$typechecker$Typers$Typer$$typedInternal(Typers.scala:5423)
        at scala.tools.nsc.typechecker.Typers$Typer.body$2(Typers.scala:5370)
        at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5374)
        at scala.tools.nsc.typechecker.Typers$Typer.typedByValueExpr(Typers.scala:5452)
        at scala.tools.nsc.typechecker.Typers$Typer.scala$tools$nsc$typechecker$Typers$Typer$$typedStat$1(Typers.scala:3047)
        at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$65.apply(Typers.scala:3151)
        at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$65.apply(Typers.scala:3151)
        at scala.collection.immutable.List.loop$1(List.scala:173)
        at scala.collection.immutable.List.mapConserve(List.scala:189)
        at scala.tools.nsc.typechecker.Typers$Typer.typedStats(Typers.scala:3151)
        at scala.tools.nsc.typechecker.Typers$Typer.typedTemplate(Typers.scala:1921)
        at scala.tools.nsc.typechecker.Typers$Typer.typedClassDef(Typers.scala:1762)
        at scala.tools.nsc.typechecker.Typers$Typer.typedMemberDef$1(Typers.scala:5309)
        at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5359)
        at scala.tools.nsc.typechecker.Typers$Typer.runTyper$1(Typers.scala:5396)
        at scala.tools.nsc.typechecker.Typers$Typer.scala$tools$nsc$typechecker$Typers$Typer$$typedInternal(Typers.scala:5423)
        at scala.tools.nsc.typechecker.Typers$Typer.body$2(Typers.scala:5370)
        at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5374)
        at scala.tools.nsc.typechecker.Typers$Typer.typedByValueExpr(Typers.scala:5452)
        at scala.tools.nsc.typechecker.Typers$Typer.scala$tools$nsc$typechecker$Typers$Typer$$typedStat$1(Typers.scala:3047)
        at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$65.apply(Typers.scala:3151)
        at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$65.apply(Typers.scala:3151)
        at scala.collection.immutable.List.loop$1(List.scala:173)
        at scala.collection.immutable.List.mapConserve(List.scala:189)
        at scala.tools.nsc.typechecker.Typers$Typer.typedStats(Typers.scala:3151)
        at scala.tools.nsc.typechecker.Typers$Typer.typedPackageDef$1(Typers.scala:5015)
        at scala.tools.nsc.typechecker.Typers$Typer.typedMemberDef$1(Typers.scala:5312)
        at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5359)
        at scala.tools.nsc.typechecker.Typers$Typer.runTyper$1(Typers.scala:5396)
        at scala.tools.nsc.typechecker.Typers$Typer.scala$tools$nsc$typechecker$Typers$Typer$$typedInternal(Typers.scala:5423)
        at scala.tools.nsc.typechecker.Typers$Typer.body$2(Typers.scala:5370)
        at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5374)
        at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5448)
        at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3.apply(Analyzer.scala:102)
        at scala.tools.nsc.Global$GlobalPhase$$anonfun$applyPhase$1.apply$mcV$sp(Global.scala:440)
        at scala.tools.nsc.Global$GlobalPhase.withCurrentUnit(Global.scala:431)
        at scala.tools.nsc.Global$GlobalPhase.applyPhase(Global.scala:440)
        at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3$$anonfun$run$1.apply(Analyzer.scala:94)
        at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3$$anonfun$run$1.apply(Analyzer.scala:93)
        at scala.collection.Iterator$class.foreach(Iterator.scala:893)
        at scala.collection.AbstractIterator.foreach(Iterator.scala:1336)
        at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3.run(Analyzer.scala:93)
        at scala.tools.nsc.Global$Run.compileUnitsInternal(Global.scala:1501)
        at scala.tools.nsc.Global$Run.compileUnits(Global.scala:1486)
        at scala.tools.nsc.Global$Run.compileSources(Global.scala:1481)
        at scala.tools.nsc.Global$Run.compile(Global.scala:1582)
        at scala.tools.nsc.Driver.doCompile(Driver.scala:32)
        at scala.tools.nsc.MainClass.doCompile(Main.scala:23)
        at scala.tools.nsc.Driver.process(Driver.scala:51)
        at scala.tools.nsc.Driver.main(Driver.scala:64)
        at scala.tools.nsc.Main.main(Main.scala)
@scabug
Copy link
Author

scabug commented Jun 14, 2016

Imported From: https://issues.scala-lang.org/browse/SI-9818?orig=1
Reporter: Martin Großmann (mgrossmann)
Affected Versions: 2.11.8, 2.12.0-M5
See #9291

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

Successfully merging a pull request may close this issue.

3 participants