Skip to content

notype when inlining pattern matching #3050

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

Closed
OlivierBlanvillain opened this issue Sep 1, 2017 · 2 comments · Fixed by #3065
Closed

notype when inlining pattern matching #3050

OlivierBlanvillain opened this issue Sep 1, 2017 · 2 comments · Fixed by #3065

Comments

@OlivierBlanvillain
Copy link
Contributor

object Test {
  inline def openImpl(n: Some[Int]): Int =
    n match { case Some(i) => i }

  def open(a: Some[Int]): Int = openImpl(a)
}
Stack trace
Exception in thread "main" java.lang.AssertionError: assertion failed:  class dotty.tools.dotc.ast.Trees$TypeTree 115
        at scala.Predef$.assert(Predef.scala:219)
        at dotty.tools.dotc.typer.ReTyper.promote(ReTyper.scala:29)
        at dotty.tools.dotc.typer.ReTyper.typedTypeTree(ReTyper.scala:52)
        at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:1652)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1679)
        at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:94)
        at dotty.tools.dotc.typer.Typer.$anonfun$typed$2(Typer.scala:1694)
        at dotty.tools.dotc.reporting.Reporting.doTraceIndented(Reporter.scala:169)
        at dotty.tools.dotc.reporting.Reporting.doTraceIndented$(Reporter.scala:154)
        at dotty.tools.dotc.core.Contexts$Context.doTraceIndented(Contexts.scala:58)
        at dotty.tools.dotc.reporting.Reporting.dotty$tools$dotc$reporting$Reporting$$doTraceIndented(Reporter.scala:151)
        at dotty.tools.dotc.reporting.Reporting.traceIndented(Reporter.scala:141)
        at dotty.tools.dotc.reporting.Reporting.traceIndented$(Reporter.scala:139)
        at dotty.tools.dotc.core.Contexts$Context.traceIndented(Contexts.scala:58)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1692)
        at dotty.tools.dotc.typer.Typer.typedType(Typer.scala:1753)
        at dotty.tools.dotc.typer.Typer.$anonfun$typedDefDef$1(Typer.scala:1294)
        at dotty.tools.dotc.util.Stats$.track(Stats.scala:35)
        at dotty.tools.dotc.typer.Typer.typedDefDef(Typer.scala:1287)
        at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:1620)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1678)
        at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:94)
        at dotty.tools.dotc.typer.Typer.$anonfun$typed$2(Typer.scala:1694)
        at dotty.tools.dotc.reporting.Reporting.doTraceIndented(Reporter.scala:169)
        at dotty.tools.dotc.reporting.Reporting.doTraceIndented$(Reporter.scala:154)
        at dotty.tools.dotc.core.Contexts$Context.doTraceIndented(Contexts.scala:58)
        at dotty.tools.dotc.reporting.Reporting.dotty$tools$dotc$reporting$Reporting$$doTraceIndented(Reporter.scala:151)
        at dotty.tools.dotc.reporting.Reporting.traceIndented(Reporter.scala:141)
        at dotty.tools.dotc.reporting.Reporting.traceIndented$(Reporter.scala:139)
        at dotty.tools.dotc.core.Contexts$Context.traceIndented(Contexts.scala:58)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1692)
        at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:1716)
        at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:1739)
        at dotty.tools.dotc.typer.Typer.typedBlockStats(Typer.scala:620)
        at dotty.tools.dotc.typer.Typer.$anonfun$typedBlock$1(Typer.scala:623)
        at dotty.tools.dotc.util.Stats$.track(Stats.scala:35)
        at dotty.tools.dotc.typer.Typer.typedBlock(Typer.scala:622)
        at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:1639)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1679)
        at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:94)
        at dotty.tools.dotc.typer.Typer.$anonfun$typed$2(Typer.scala:1694)
        at dotty.tools.dotc.reporting.Reporting.doTraceIndented(Reporter.scala:169)
        at dotty.tools.dotc.reporting.Reporting.doTraceIndented$(Reporter.scala:154)
        at dotty.tools.dotc.core.Contexts$Context.doTraceIndented(Contexts.scala:58)
        at dotty.tools.dotc.reporting.Reporting.dotty$tools$dotc$reporting$Reporting$$doTraceIndented(Reporter.scala:151)
        at dotty.tools.dotc.reporting.Reporting.traceIndented(Reporter.scala:141)
        at dotty.tools.dotc.reporting.Reporting.traceIndented$(Reporter.scala:139)
        at dotty.tools.dotc.core.Contexts$Context.traceIndented(Contexts.scala:58)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1692)
        at dotty.tools.dotc.typer.Typer.$anonfun$typedFunction$1(Typer.scala:846)
        at dotty.tools.dotc.util.Stats$.track(Stats.scala:35)
        at dotty.tools.dotc.typer.Typer.typedFunction(Typer.scala:693)
        at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:1641)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1679)
        at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:94)
        at dotty.tools.dotc.typer.Typer.$anonfun$typed$2(Typer.scala:1694)
        at dotty.tools.dotc.reporting.Reporting.doTraceIndented(Reporter.scala:169)
        at dotty.tools.dotc.reporting.Reporting.doTraceIndented$(Reporter.scala:154)
        at dotty.tools.dotc.core.Contexts$Context.doTraceIndented(Contexts.scala:58)
        at dotty.tools.dotc.reporting.Reporting.dotty$tools$dotc$reporting$Reporting$$doTraceIndented(Reporter.scala:151)
        at dotty.tools.dotc.reporting.Reporting.traceIndented(Reporter.scala:141)
        at dotty.tools.dotc.reporting.Reporting.traceIndented$(Reporter.scala:139)
        at dotty.tools.dotc.core.Contexts$Context.traceIndented(Contexts.scala:58)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1692)
        at dotty.tools.dotc.typer.Typer.adaptNoArgs$1(Typer.scala:2108)
        at dotty.tools.dotc.typer.Typer.adaptInterpolated(Typer.scala:2275)
        at dotty.tools.dotc.typer.Typer.$anonfun$adapt$3(Typer.scala:1855)
        at dotty.tools.dotc.reporting.Reporting.doTraceIndented(Reporter.scala:169)
        at dotty.tools.dotc.reporting.Reporting.doTraceIndented$(Reporter.scala:154)
        at dotty.tools.dotc.core.Contexts$Context.doTraceIndented(Contexts.scala:58)
        at dotty.tools.dotc.reporting.Reporting.dotty$tools$dotc$reporting$Reporting$$doTraceIndented(Reporter.scala:151)
        at dotty.tools.dotc.reporting.Reporting.traceIndented(Reporter.scala:141)
        at dotty.tools.dotc.reporting.Reporting.traceIndented$(Reporter.scala:139)
        at dotty.tools.dotc.core.Contexts$Context.traceIndented(Contexts.scala:58)
        at dotty.tools.dotc.typer.Typer.$anonfun$adapt$1(Typer.scala:1851)
        at dotty.tools.dotc.util.Stats$.track(Stats.scala:35)
        at dotty.tools.dotc.typer.Typer.adapt(Typer.scala:1851)
        at dotty.tools.dotc.typer.Typer.$anonfun$typed$2(Typer.scala:1694)
        at dotty.tools.dotc.reporting.Reporting.doTraceIndented(Reporter.scala:169)
        at dotty.tools.dotc.reporting.Reporting.doTraceIndented$(Reporter.scala:154)
        at dotty.tools.dotc.core.Contexts$Context.doTraceIndented(Contexts.scala:58)
        at dotty.tools.dotc.reporting.Reporting.dotty$tools$dotc$reporting$Reporting$$doTraceIndented(Reporter.scala:151)
        at dotty.tools.dotc.reporting.Reporting.traceIndented(Reporter.scala:141)
        at dotty.tools.dotc.reporting.Reporting.traceIndented$(Reporter.scala:139)
        at dotty.tools.dotc.core.Contexts$Context.traceIndented(Contexts.scala:58)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1692)
        at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:1751)
        at dotty.tools.dotc.typer.ReTyper.typedUnApply(ReTyper.scala:61)
        at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:1665)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1679)
        at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:94)
        at dotty.tools.dotc.typer.Typer.$anonfun$typed$2(Typer.scala:1694)
        at dotty.tools.dotc.reporting.Reporting.doTraceIndented(Reporter.scala:169)
        at dotty.tools.dotc.reporting.Reporting.doTraceIndented$(Reporter.scala:154)
        at dotty.tools.dotc.core.Contexts$Context.doTraceIndented(Contexts.scala:58)
        at dotty.tools.dotc.reporting.Reporting.dotty$tools$dotc$reporting$Reporting$$doTraceIndented(Reporter.scala:151)
        at dotty.tools.dotc.reporting.Reporting.traceIndented(Reporter.scala:141)
        at dotty.tools.dotc.reporting.Reporting.traceIndented$(Reporter.scala:139)
        at dotty.tools.dotc.core.Contexts$Context.traceIndented(Contexts.scala:58)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1692)
        at dotty.tools.dotc.typer.Typer.typedPattern(Typer.scala:1755)
        at dotty.tools.dotc.typer.Typer.$anonfun$typedCase$1(Typer.scala:964)
        at dotty.tools.dotc.util.Stats$.track(Stats.scala:35)
        at dotty.tools.dotc.typer.Typer.typedCase(Typer.scala:918)
        at dotty.tools.dotc.typer.Typer.$anonfun$typedCases$3(Typer.scala:912)
        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.Typer.typedCases(Typer.scala:912)
        at dotty.tools.dotc.typer.Typer.$anonfun$typedMatch$1(Typer.scala:884)
        at dotty.tools.dotc.util.Stats$.track(Stats.scala:35)
        at dotty.tools.dotc.typer.Typer.typedMatch(Typer.scala:875)
        at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:1644)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1679)
        at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:94)
        at dotty.tools.dotc.typer.Typer.$anonfun$typed$2(Typer.scala:1694)
        at dotty.tools.dotc.reporting.Reporting.doTraceIndented(Reporter.scala:169)
        at dotty.tools.dotc.reporting.Reporting.doTraceIndented$(Reporter.scala:154)
        at dotty.tools.dotc.core.Contexts$Context.doTraceIndented(Contexts.scala:58)
        at dotty.tools.dotc.reporting.Reporting.dotty$tools$dotc$reporting$Reporting$$doTraceIndented(Reporter.scala:151)
        at dotty.tools.dotc.reporting.Reporting.traceIndented(Reporter.scala:141)
        at dotty.tools.dotc.reporting.Reporting.traceIndented$(Reporter.scala:139)
        at dotty.tools.dotc.core.Contexts$Context.traceIndented(Contexts.scala:58)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1692)
        at dotty.tools.dotc.typer.Inliner.$anonfun$inlined$8(Inliner.scala:475)
        at dotty.tools.dotc.reporting.Reporting.traceIndented(Reporter.scala:140)
        at dotty.tools.dotc.reporting.Reporting.traceIndented$(Reporter.scala:139)
        at dotty.tools.dotc.core.Contexts$Context.traceIndented(Contexts.scala:58)
        at dotty.tools.dotc.typer.Inliner.inlined(Inliner.scala:472)
        at dotty.tools.dotc.typer.Inliner$.inlineCall(Inliner.scala:245)
        at dotty.tools.dotc.typer.Typer.adaptNoArgs$1(Typer.scala:2146)
        at dotty.tools.dotc.typer.Typer.adaptInterpolated(Typer.scala:2275)
        at dotty.tools.dotc.typer.Typer.$anonfun$adapt$3(Typer.scala:1855)
        at dotty.tools.dotc.reporting.Reporting.doTraceIndented(Reporter.scala:169)
        at dotty.tools.dotc.reporting.Reporting.doTraceIndented$(Reporter.scala:154)
        at dotty.tools.dotc.core.Contexts$Context.doTraceIndented(Contexts.scala:58)
        at dotty.tools.dotc.reporting.Reporting.dotty$tools$dotc$reporting$Reporting$$doTraceIndented(Reporter.scala:151)
        at dotty.tools.dotc.reporting.Reporting.traceIndented(Reporter.scala:141)
        at dotty.tools.dotc.reporting.Reporting.traceIndented$(Reporter.scala:139)
        at dotty.tools.dotc.core.Contexts$Context.traceIndented(Contexts.scala:58)
        at dotty.tools.dotc.typer.Typer.$anonfun$adapt$1(Typer.scala:1851)
        at dotty.tools.dotc.util.Stats$.track(Stats.scala:35)
        at dotty.tools.dotc.typer.Typer.adapt(Typer.scala:1851)
        at dotty.tools.dotc.typer.Typer.$anonfun$typed$2(Typer.scala:1694)
        at dotty.tools.dotc.reporting.Reporting.doTraceIndented(Reporter.scala:169)
        at dotty.tools.dotc.reporting.Reporting.doTraceIndented$(Reporter.scala:154)
        at dotty.tools.dotc.core.Contexts$Context.doTraceIndented(Contexts.scala:58)
        at dotty.tools.dotc.reporting.Reporting.dotty$tools$dotc$reporting$Reporting$$doTraceIndented(Reporter.scala:151)
        at dotty.tools.dotc.reporting.Reporting.traceIndented(Reporter.scala:141)
        at dotty.tools.dotc.reporting.Reporting.traceIndented$(Reporter.scala:139)
        at dotty.tools.dotc.core.Contexts$Context.traceIndented(Contexts.scala:58)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1692)
        at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:1751)
        at dotty.tools.dotc.typer.Typer.$anonfun$typedDefDef$1(Typer.scala:1305)
        at dotty.tools.dotc.util.Stats$.track(Stats.scala:35)
        at dotty.tools.dotc.typer.Typer.typedDefDef(Typer.scala:1287)
        at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:1620)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1678)
        at dotty.tools.dotc.typer.Typer.$anonfun$typed$2(Typer.scala:1694)
        at dotty.tools.dotc.reporting.Reporting.doTraceIndented(Reporter.scala:169)
        at dotty.tools.dotc.reporting.Reporting.doTraceIndented$(Reporter.scala:154)
        at dotty.tools.dotc.core.Contexts$Context.doTraceIndented(Contexts.scala:58)
        at dotty.tools.dotc.reporting.Reporting.dotty$tools$dotc$reporting$Reporting$$doTraceIndented(Reporter.scala:151)
        at dotty.tools.dotc.reporting.Reporting.traceIndented(Reporter.scala:141)
        at dotty.tools.dotc.reporting.Reporting.traceIndented$(Reporter.scala:139)
        at dotty.tools.dotc.core.Contexts$Context.traceIndented(Contexts.scala:58)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1692)
        at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:1716)
        at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:1739)
        at dotty.tools.dotc.typer.Typer.$anonfun$typedClassDef$1(Typer.scala:1405)
        at dotty.tools.dotc.util.Stats$.track(Stats.scala:35)
        at dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:1335)
        at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:1623)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1678)
        at dotty.tools.dotc.typer.Typer.$anonfun$typed$2(Typer.scala:1694)
        at dotty.tools.dotc.reporting.Reporting.doTraceIndented(Reporter.scala:169)
        at dotty.tools.dotc.reporting.Reporting.doTraceIndented$(Reporter.scala:154)
        at dotty.tools.dotc.core.Contexts$Context.doTraceIndented(Contexts.scala:58)
        at dotty.tools.dotc.reporting.Reporting.dotty$tools$dotc$reporting$Reporting$$doTraceIndented(Reporter.scala:151)
        at dotty.tools.dotc.reporting.Reporting.traceIndented(Reporter.scala:141)
        at dotty.tools.dotc.reporting.Reporting.traceIndented$(Reporter.scala:139)
        at dotty.tools.dotc.core.Contexts$Context.traceIndented(Contexts.scala:58)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1692)
        at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:1716)
        at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:1739)
        at dotty.tools.dotc.typer.Typer.$anonfun$typedPackageDef$1(Typer.scala:1522)
        at dotty.tools.dotc.util.Stats$.track(Stats.scala:35)
        at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:1509)
        at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:1662)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1679)
        at dotty.tools.dotc.typer.Typer.$anonfun$typed$2(Typer.scala:1694)
        at dotty.tools.dotc.reporting.Reporting.doTraceIndented(Reporter.scala:169)
        at dotty.tools.dotc.reporting.Reporting.doTraceIndented$(Reporter.scala:154)
        at dotty.tools.dotc.core.Contexts$Context.doTraceIndented(Contexts.scala:58)
        at dotty.tools.dotc.reporting.Reporting.dotty$tools$dotc$reporting$Reporting$$doTraceIndented(Reporter.scala:151)
        at dotty.tools.dotc.reporting.Reporting.traceIndented(Reporter.scala:141)
        at dotty.tools.dotc.reporting.Reporting.traceIndented$(Reporter.scala:139)
        at dotty.tools.dotc.core.Contexts$Context.traceIndented(Contexts.scala:58)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1692)
        at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:1751)
        at dotty.tools.dotc.typer.FrontEnd.$anonfun$typeCheck$1(FrontEnd.scala:64)
        at dotty.tools.dotc.typer.FrontEnd.monitor(FrontEnd.scala:32)
        at dotty.tools.dotc.typer.FrontEnd.typeCheck(FrontEnd.scala:62)
        at dotty.tools.dotc.typer.FrontEnd.$anonfun$runOn$5(FrontEnd.scala:93)
        at dotty.tools.dotc.typer.FrontEnd.$anonfun$runOn$5$adapted(FrontEnd.scala:93)
        at scala.collection.immutable.List.foreach(List.scala:389)
        at dotty.tools.dotc.typer.FrontEnd.runOn(FrontEnd.scala:93)
        at dotty.tools.dotc.Run.$anonfun$compileUnits$2(Run.scala:123)
        at dotty.tools.dotc.Run.$anonfun$compileUnits$2$adapted(Run.scala:120)
        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:191)
        at dotty.tools.dotc.Run.$anonfun$compileUnits$1(Run.scala:120)
        at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
        at dotty.tools.dotc.util.Stats$.monitorHeartBeat(Stats.scala:76)
        at dotty.tools.dotc.Run.compileUnits(Run.scala:108)
        at dotty.tools.dotc.Run.compileSources(Run.scala:95)
        at dotty.tools.dotc.Run.compile(Run.scala:79)
        at dotty.tools.dotc.Driver.doCompile(Driver.scala:26)
        at dotty.tools.dotc.Driver.process(Driver.scala:124)
        at dotty.tools.dotc.Driver.process(Driver.scala:93)
        at dotty.tools.dotc.Driver.process(Driver.scala:105)
        at dotty.tools.dotc.Driver.main(Driver.scala:132)
        at dotty.tools.dotc.Main.main(Main.scala)
java.lang.RuntimeException: Nonzero exit code returned from runner: 1
        at scala.sys.package$.error(package.scala:27)
@biboudis
Copy link
Contributor

biboudis commented Sep 4, 2017

Just a tiny bit of more info, this works:

inline def openImpl(): Int = Some(42) match { case _ => 0 }

but this not:

inline def openImpl(): Int = Some(42) match { case None => 0 }

different exception thought:

Exception in thread "main" java.lang.AssertionError: assertion failed: Select(TypedSplice(Ident(None)),==)

biboudis added a commit to biboudis/dotty that referenced this issue Sep 4, 2017
@biboudis
Copy link
Contributor

biboudis commented Sep 4, 2017

@OlivierBlanvillain we pushed our changes to 03efed4, it passes (modulo the isInstanceOf hack).
What do you think? If it looks good I can open the PR.

biboudis added a commit to biboudis/dotty that referenced this issue Sep 8, 2017
biboudis added a commit to biboudis/dotty that referenced this issue Sep 14, 2017
OlivierBlanvillain added a commit that referenced this issue Oct 3, 2017
Fix #3050: Avoid retyping synthesised code
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.

2 participants