Skip to content

Compiler crash (null pointer exception) with implicit dispatch #5311

@yallop

Description

@yallop

The following program crashes dotc (from the dotty-0.10.0-RC1 release):

object m {
  trait Foo {
    type T[A]
    def bar : (T[Int] => T[Int]) => T[Int => Int]
  }

  def baz (implicit S: Foo, f : S.T[Int] => S.T[Int]) : S.T[Int => Int] =
    S.bar.apply(f)

  def example(implicit s:Foo) : s.T[Int => Int] = {
    baz((x : s.T[Int]) => x)
  }
}

Here's the output:

exception occurred while typechecking minimal.scala
exception occurred while compiling minimal.scala
Exception in thread "main" java.lang.NullPointerException
	at dotty.tools.dotc.typer.ProtoTypes$FunProto.typeOfArg(ProtoTypes.scala:319)
	at dotty.tools.dotc.typer.Applications$ApplyToUntyped.typeOfArg(Applications.scala:706)
	at dotty.tools.dotc.typer.Applications$ApplyToUntyped.typeOfArg(Applications.scala:706)
	at dotty.tools.dotc.typer.Applications$Application.addTyped$2$$anonfun$1(Applications.scala:477)
	at dotty.tools.dotc.core.Decorators$ListDecorator$.loop$1(Decorators.scala:62)
	at dotty.tools.dotc.core.Decorators$ListDecorator$.mapconserve$extension(Decorators.scala:78)
	at dotty.tools.dotc.typer.Applications$Application.matchArgs(Applications.scala:514)
	at dotty.tools.dotc.typer.Applications$Application.init(Applications.scala:296)
	at dotty.tools.dotc.typer.Applications$TypedApply.<init>(Applications.scala:605)
	at dotty.tools.dotc.typer.Applications$ApplyToUntyped.<init>(Applications.scala:703)
	at dotty.tools.dotc.typer.Applications.simpleApply$1(Applications.scala:763)
	at dotty.tools.dotc.typer.Applications.realApply$4$$anonfun$3(Applications.scala:788)
	at dotty.tools.dotc.typer.Typer.tryEither(Typer.scala:2058)
	at dotty.tools.dotc.typer.Applications.realApply$1(Applications.scala:799)
	at dotty.tools.dotc.typer.Applications.typedApply(Applications.scala:834)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:1882)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1936)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1967)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1979)
	at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:2050)
	at dotty.tools.dotc.typer.Typer.typedBlock(Typer.scala:669)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:1889)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1936)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1967)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1979)
	at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:2050)
	at dotty.tools.dotc.typer.Typer.typedDefDef(Typer.scala:1489)
	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:1869)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1935)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1967)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1979)
	at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:1998)
	at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:2039)
	at dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:1593)
	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:1872)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1935)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1967)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1979)
	at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:1998)
	at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:2039)
	at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:1707)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:1914)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1936)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1967)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1979)
	at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:2050)
	at dotty.tools.dotc.typer.FrontEnd.typeCheck$$anonfun$1(FrontEnd.scala:60)
	at scala.compat.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
	at dotty.tools.dotc.typer.FrontEnd.monitor(FrontEnd.scala:34)
	at dotty.tools.dotc.typer.FrontEnd.typeCheck(FrontEnd.scala:64)
	at dotty.tools.dotc.typer.FrontEnd.runOn$$anonfun$2(FrontEnd.scala:88)
	at scala.compat.java8.JProcedure1.apply(JProcedure1.java:18)
	at scala.compat.java8.JProcedure1.apply(JProcedure1.java:10)
	at scala.collection.immutable.List.foreach(List.scala:388)
	at dotty.tools.dotc.typer.FrontEnd.runOn(FrontEnd.scala:88)
	at dotty.tools.dotc.Run.runPhases$4$$anonfun$4(Run.scala:175)
	at scala.compat.java8.JProcedure1.apply(JProcedure1.java:18)
	at scala.compat.java8.JProcedure1.apply(JProcedure1.java:10)
	at scala.collection.IndexedSeqOptimized.foreach(IndexedSeqOptimized.scala:32)
	at scala.collection.IndexedSeqOptimized.foreach$(IndexedSeqOptimized.scala:29)
	at scala.collection.mutable.ArrayOps$ofRef.foreach(ArrayOps.scala:194)
	at dotty.tools.dotc.Run.runPhases$5(Run.scala:187)
	at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:195)
	at scala.compat.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
	at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:90)
	at dotty.tools.dotc.Run.compileUnits(Run.scala:202)
	at dotty.tools.dotc.Run.compileSources(Run.scala:137)
	at dotty.tools.dotc.Run.compile(Run.scala:121)
	at dotty.tools.dotc.Driver.doCompile(Driver.scala:31)
	at dotty.tools.dotc.Driver.process(Driver.scala:134)
	at dotty.tools.dotc.Driver.process(Driver.scala:103)
	at dotty.tools.dotc.Driver.process(Driver.scala:115)
	at dotty.tools.dotc.Driver.main(Driver.scala:142)
	at dotty.tools.dotc.Main.main(Main.scala)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions