Skip to content

Failure when beta-reducing polymorphic function #17052

Closed
@nicolasstucki

Description

@nicolasstucki

Compiler version

3.3-RC2

Minimized code

def test[F[_]](fAny: F[Any]) =
  { [X] => (fx: F[X]) => { val fx2: F[X] = fx; () } }.apply[Any](fAny)

Output

With -Ycheck:all

exception while typing val fx2: F[X] = fAny of class class dotty.tools.dotc.ast.Trees$ValDef # -1
exception while typing {
  val fx2: F[X] = fAny
  ()
} of class class dotty.tools.dotc.ast.Trees$Block # -1
exception while typing {
  type X = Any
  {
    val fx2: F[X] = fAny
    ()
  }
} of class class dotty.tools.dotc.ast.Trees$Block # -1
exception while typing def test[F[_$1]](fAny: F[Any]): Unit =
  {
    type X = Any
    {
      val fx2: F[X] = fAny
      ()
    }
  } of class class dotty.tools.dotc.ast.Trees$DefDef # -1
exception while typing @SourceFile("t/Macro_1.scala") final module class Macro_1$package() extends Object() {
  private def writeReplace(): AnyRef = new scala.runtime.ModuleSerializationProxy(classOf[Macro_1$package.type])
  def test[F[_$1]](fAny: F[Any]): Unit =
    {
      type X = Any
      {
        val fx2: F[X] = fAny
        ()
      }
    }
} of class class dotty.tools.dotc.ast.Trees$TypeDef # -1
exception while typing package <empty> {
  final lazy module val Macro_1$package: Macro_1$package = new Macro_1$package()
  @SourceFile("t/Macro_1.scala") final module class Macro_1$package() extends Object() {
    private def writeReplace(): AnyRef = new scala.runtime.ModuleSerializationProxy(classOf[Macro_1$package.type])
    def test[F[_$1]](fAny: F[Any]): Unit =
      {
        type X = Any
        {
          val fx2: F[X] = fAny
          ()
        }
      }
  }
} of class class dotty.tools.dotc.ast.Trees$PackageDef # -1
*** error while checking t/Macro_1.scala after phase MegaPhase{firstTransform, checkReentrant, elimPackagePrefixes, cookComments, checkStatic, checkLoopingImplicits, betaReduce, inlineVals, expandSAMs, elimRepeated, refchecks} ***
java.lang.AssertionError: assertion failed: Found:    (fAny : F[Any])
Required: F[X]
found: ??
expected: ??
tree = fAny while running Ycheck on t/Macro_1.scala
exception occurred while compiling t/Macro_1.scala
java.lang.AssertionError: assertion failed: Found:    (fAny : F[Any])
Required: F[X]
found: ??
expected: ??
tree = fAny while compiling t/Macro_1.scala
Exception in thread "main" java.lang.AssertionError: assertion failed: Found:    (fAny : F[Any])
Required: F[X]
found: ??
expected: ??
tree = fAny

Expectation

Should pass -Ycheck:all.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions