Skip to content

Opaque type failing Ycheck when compiling from TASTy #7159

Closed
@nicolasstucki

Description

@nicolasstucki

minimized code

trait CompilerInterface {
  type Tree
}

class Reflect(val internal: CompilerInterface) {
  opaque type Tree = internal.Tree
  def show(t: Tree): String = ???
}

object App {
  val refl: Reflect = ???
  import refl._

  show(??? : Tree)
}

This code fails to Ycheck when compiling from TASTy.

It can be reproduced using the following command from sbt

dotc -Ythrough-tasty -Ycheck:all XYZ.scala
checking /Users/nicolasstucki/GitHub/dotty/out/from-tasty-tmp7774217330379414850/from-source/App.class after phase MegaPhase{elimOpaque, tryCatchPatterns, patternMatcher, explicitOuter, explicitSelf, stringInterpolatorOpt, crossCast}
exception while typing App.refl.show(??? :App.refl.Tree) of class class dotty.tools.dotc.ast.Trees$Apply # 2116
exception while typing @scala.annotation.internal.SourceFile(
  "tests/pos/tasty-reflect-opaque-api-proto.scala"
) final module class App$() extends Object(), Serializable {
  private def writeReplace(): AnyRef = 
    new runtime.ModuleSerializationProxy(classOf[App.type])
  val refl: Reflect = ???
  App.refl.show(??? :App.refl.Tree)
} of class class dotty.tools.dotc.ast.Trees$TypeDef # 2232
exception while typing package <empty> {
  final lazy module val App: App$ = new App$()
  @scala.annotation.internal.SourceFile(
    "tests/pos/tasty-reflect-opaque-api-proto.scala"
  ) final module class App$() extends Object(), Serializable {
    private def writeReplace(): AnyRef = 
      new runtime.ModuleSerializationProxy(classOf[App.type])
    val refl: Reflect = ???
    App.refl.show(??? :App.refl.Tree)
  }
} of class class dotty.tools.dotc.ast.Trees$PackageDef # 2233
*** error while checking /Users/nicolasstucki/GitHub/dotty/out/from-tasty-tmp7774217330379414850/from-source/App.class after phase crossCast ***
java.lang.AssertionError: assertion failed: Found:    App.refl.Tree
Required: App.refl.Tree
tree = ??? :App.refl.Tree whileException in thread "main"  compiling Reflect, App, CompilerInterfacejava.lang.AssertionError: assertion failed: Found:    App.refl.Tree
Required: App.refl.Tree
tree = ??? :App.refl.Tree
        at dotty.DottyPredef$.assertFail(DottyPredef.scala:16)
        at dotty.tools.dotc.transform.TreeChecker$Checker.adapt(TreeChecker.scala:508)
        at dotty.tools.dotc.typer.ProtoTypes$FunProto.typedArg(ProtoTypes.scala:328)
        at dotty.tools.dotc.typer.Applications$ApplyToUntyped.typedArg(Applications.scala:795)
        at dotty.tools.dotc.typer.Applications$ApplyToUntyped.typedArg(Applications.scala:795)
        at dotty.tools.dotc.typer.Applications$Application.addTyped$1(Applications.scala:532)
        at dotty.tools.dotc.typer.Applications$Application.matchArgs(Applications.scala:601)
        at dotty.tools.dotc.typer.Applications$Application.init(Applications.scala:353)
        at dotty.tools.dotc.typer.Applications$TypedApply.<init>(Applications.scala:692)
        at dotty.tools.dotc.typer.Applications$ApplyToUntyped.<init>(Applications.scala:794)
        at dotty.tools.dotc.typer.Applications.simpleApply$1(Applications.scala:867)
        at dotty.tools.dotc.typer.Applications.realApply$4$$anonfun$3(Applications.scala:896)
        at dotty.tools.dotc.typer.Typer.tryEither(Typer.scala:2251)
        at dotty.tools.dotc.typer.Applications.realApply$1(Applications.scala:907)
        at dotty.tools.dotc.typer.Applications.typedApply(Applications.scala:942)
        at dotty.tools.dotc.typer.Typer.typedApply(Typer.scala:83)
        at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2063)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2119)
        at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:123)
        at dotty.tools.dotc.transform.TreeChecker$Checker.typedUnadapted(TreeChecker.scala:302)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2155)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2167)
        at dotty.tools.dotc.transform.TreeChecker$Checker.typed(TreeChecker.scala:287)
        at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:2208)
        at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:2230)
        at dotty.tools.dotc.transform.TreeChecker$Checker.typedStats(TreeChecker.scala:476)
        at dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:1730)
        at dotty.tools.dotc.transform.TreeChecker$Checker.typedClassDef(TreeChecker.scala:416)
        at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2053)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2118)
        at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:123)
        at dotty.tools.dotc.transform.TreeChecker$Checker.typedUnadapted(TreeChecker.scala:302)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2155)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2167)
        at dotty.tools.dotc.transform.TreeChecker$Checker.typed(TreeChecker.scala:287)
        at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:2186)
        at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:2230)
        at dotty.tools.dotc.transform.TreeChecker$Checker.typedStats(TreeChecker.scala:476)
        at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:1854)
        at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2094)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2119)
        at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:123)
        at dotty.tools.dotc.transform.TreeChecker$Checker.typedUnadapted(TreeChecker.scala:302)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2155)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2153)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2167)
        at dotty.tools.dotc.transform.TreeChecker$Checker.typed(TreeChecker.scala:287)
        at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:2243)
        at dotty.tools.dotc.transform.TreeChecker.check(TreeChecker.scala:122)
        at dotty.tools.dotc.transform.TreeChecker.run(TreeChecker.scala:94)
        at dotty.tools.dotc.core.Phases$Phase.runOn$$anonfun$1(Phases.scala:315)
        at scala.collection.immutable.List.map(List.scala:226)
        at dotty.tools.dotc.core.Phases$Phase.runOn(Phases.scala:316)
        at dotty.tools.dotc.Run.runPhases$4$$anonfun$4(Run.scala:159)
        at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:15)
        at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:10)
        at scala.collection.ArrayOps$.foreach$extension(ArrayOps.scala:1350)
        at dotty.tools.dotc.Run.runPhases$5(Run.scala:169)
        at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:177)
        at dotty.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
        at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:67)
        at dotty.tools.dotc.Run.compileUnits(Run.scala:184)
        at dotty.tools.dotc.Run.compileUnits(Run.scala:126)
        at dotty.tools.dotc.fromtasty.TASTYRun.compile(TASTYRun.scala:10)
        at dotty.tools.dotc.Driver.doCompile(Driver.scala:35)
        at dotty.tools.dotc.Driver.process(Driver.scala:179)
        at dotty.tools.dotc.Driver.process(Driver.scala:148)
        at dotty.tools.dotc.Driver.process(Driver.scala:160)
        at dotty.tools.dotc.fromtasty.Debug$.main(Debug.scala:53)
        at dotty.tools.dotc.fromtasty.Debug.main(Debug.scala)

expectation

Ycheck should pass.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions