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

Fix subsumes test between constraints #13650

Merged
merged 2 commits into from
Oct 1, 2021
Merged

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Oct 1, 2021

The test gave a false negative in the case where a parameter was
instantiated to the same value in both constraints. In that case
the parameter is not "contained" in either constraint, since it
is already instantiated, and that caused the test to fail.

Fixes #13541

The test gave a false negative in the case where a parameter was
instantiated to the same value in both constraints. In that case
the parameter is not "contained" in either constraint, since it
is already instantiated, and that caused the test to fail.

Fixes scala#13541
@smarter smarter enabled auto-merge October 1, 2021 15:32
perspective now fails with the following stack trace
```
error when pickling type Z
error when pickling type perspective.Const[List[A]][Z]
error when pickling tree perspective.Const[List[A]][Z]
error when pickling tree perspective.FoldableK.this.foldMapK[([_] =>> A), C](fa)[
  perspective.Const[List[A]][Z]
]
error when pickling tree perspective.FoldableK.this.foldMapK[([_] =>> A), C](fa)[
  perspective.Const[List[A]][Z]
](
  perspective.FunctionK.liftConst[A, List[A]](
    {
      def $anonfun(_$5: A): List[A] = List.apply[A]([_$5:A : A]*)
      closure($anonfun)
    }
  )
)
error when pickling tree perspective.FoldableK.this.foldMapK[([_] =>> A), C](fa)[
  perspective.Const[List[A]][Z]
](
  perspective.FunctionK.liftConst[A, List[A]](
    {
      def $anonfun(_$5: A): List[A] = List.apply[A]([_$5:A : A]*)
      closure($anonfun)
    }
  )
)(cats.kernel.Semigroup.catsKernelMonoidForList[A])
error when pickling tree extension [A >: Nothing <: Any, C >: Nothing <: Any](
  fa: FoldableK.this.F[perspective.Const[A], C]
) def toListK: List[A] =
  this.foldMapK[([_] =>> A), C](fa)[perspective.Const[List[A]][Z]](
    perspective.FunctionK.liftConst[A, List[A]](
      {
        def $anonfun(_$5: A): List[A] = List.apply[A]([_$5:A : A]*)
        closure($anonfun)
      }
    )
  )(cats.kernel.Semigroup.catsKernelMonoidForList[A])
error when pickling tree [
  F[_[_ >: Nothing <: Any] >: Nothing <: Any, _ >: Nothing <: Any]
     >: Nothing <: Any
]() extends Object {
  F[_$1[_$2],_$3]
  extension [A[_ >: Nothing <: Any] >: Nothing <: Any, C >: Nothing <: Any](
    fa: FoldableK.this.F[A, C]
  ) def foldLeftK[B >: Nothing <: Any](b: B)(f: B => A ~>#: B): B
  extension [A[_ >: Nothing <: Any] >: Nothing <: Any, C >: Nothing <: Any](
    fa: FoldableK.this.F[A, C]
  ) def foldMapK[B >: Nothing <: Any](f: perspective.~>#:[A, B])(using
    B: cats.Monoid[B]
  ): B =
    this.foldLeftK[A, C](fa)[B](B.empty)(
      {
        def $anonfun(b: B): A ~>#: B =
          {
            final class $anon() extends Object(), PolyFunction {
              def apply[Z >: Nothing <: Any](az: A[Z]): B =
                cats.syntax.all.catsSyntaxSemigroup[B](b)(B).combine(
                  f.apply[Z](az)
                )
            }
            new $anon():([Z] => (A[Z]) => B)
          }
        closure($anonfun)
      }
    )
  extension [A >: Nothing <: Any, C >: Nothing <: Any](
    fa: FoldableK.this.F[perspective.Const[A], C]
  ) def toListK: List[A] =
    this.foldMapK[([_] =>> A), C](fa)[perspective.Const[List[A]][Z]](
      perspective.FunctionK.liftConst[A, List[A]](
        {
          def $anonfun(_$5: A): List[A] = List.apply[A]([_$5:A : A]*)
          closure($anonfun)
        }
      )
    )(cats.kernel.Semigroup.catsKernelMonoidForList[A])
}
error when pickling tree @sourcefile("dotty/perspective/src/main/scala/perspective/FoldableK.scala")
  trait
 FoldableK[
  F[_[_ >: Nothing <: Any] >: Nothing <: Any, _ >: Nothing <: Any]
     >: Nothing <: Any
]() extends Object {
  F[_$1[_$2],_$3]
  extension [A[_ >: Nothing <: Any] >: Nothing <: Any, C >: Nothing <: Any](
    fa: FoldableK.this.F[A, C]
  ) def foldLeftK[B >: Nothing <: Any](b: B)(f: B => A ~>#: B): B
  extension [A[_ >: Nothing <: Any] >: Nothing <: Any, C >: Nothing <: Any](
    fa: FoldableK.this.F[A, C]
  ) def foldMapK[B >: Nothing <: Any](f: perspective.~>#:[A, B])(using
    B: cats.Monoid[B]
  ): B =
    this.foldLeftK[A, C](fa)[B](B.empty)(
      {
        def $anonfun(b: B): A ~>#: B =
          {
            final class $anon() extends Object(), PolyFunction {
              def apply[Z >: Nothing <: Any](az: A[Z]): B =
                cats.syntax.all.catsSyntaxSemigroup[B](b)(B).combine(
                  f.apply[Z](az)
                )
            }
            new $anon():([Z] => (A[Z]) => B)
          }
        closure($anonfun)
      }
    )
  extension [A >: Nothing <: Any, C >: Nothing <: Any](
    fa: FoldableK.this.F[perspective.Const[A], C]
  ) def toListK: List[A] =
    this.foldMapK[([_] =>> A), C](fa)[perspective.Const[List[A]][Z]](
      perspective.FunctionK.liftConst[A, List[A]](
        {
          def $anonfun(_$5: A): List[A] = List.apply[A]([_$5:A : A]*)
          closure($anonfun)
        }
      )
    )(cats.kernel.Semigroup.catsKernelMonoidForList[A])
}
error when pickling tree package perspective {
  import cats.*
  import cats.syntax.package.all.*
  import scala.language.implicitConversions
  @sourcefile("dotty/perspective/src/main/scala/perspective/FoldableK.scala")
    trait
   FoldableK[
    F[_[_ >: Nothing <: Any] >: Nothing <: Any, _ >: Nothing <: Any]
       >: Nothing <: Any
  ]() extends Object {
    F[_$1[_$2],_$3]
    extension [A[_ >: Nothing <: Any] >: Nothing <: Any, C >: Nothing <: Any](
      fa: FoldableK.this.F[A, C]
    ) def foldLeftK[B >: Nothing <: Any](b: B)(f: B => A ~>#: B): B
    extension [A[_ >: Nothing <: Any] >: Nothing <: Any, C >: Nothing <: Any](
      fa: FoldableK.this.F[A, C]
    ) def foldMapK[B >: Nothing <: Any](f: perspective.~>#:[A, B])(using
      B: cats.Monoid[B]
    ): B =
      this.foldLeftK[A, C](fa)[B](B.empty)(
        {
          def $anonfun(b: B): A ~>#: B =
            {
              final class $anon() extends Object(), PolyFunction {
                def apply[Z >: Nothing <: Any](az: A[Z]): B =
                  cats.syntax.all.catsSyntaxSemigroup[B](b)(B).combine(
                    f.apply[Z](az)
                  )
              }
              new $anon():([Z] => (A[Z]) => B)
            }
          closure($anonfun)
        }
      )
    extension [A >: Nothing <: Any, C >: Nothing <: Any](
      fa: FoldableK.this.F[perspective.Const[A], C]
    ) def toListK: List[A] =
      this.foldMapK[([_] =>> A), C](fa)[perspective.Const[List[A]][Z]](
        perspective.FunctionK.liftConst[A, List[A]](
          {
            def $anonfun(_$5: A): List[A] = List.apply[A]([_$5:A : A]*)
            closure($anonfun)
          }
        )
      )(cats.kernel.Semigroup.catsKernelMonoidForList[A])
  }
}
java.lang.AssertionError: assertion failed: orphan parameter reference: TypeParamRef(Z) while compiling /Users/odersky/workspace/dotty/community-build/community-projects/perspective/dotty/perspective/src/main/scala/perspective/ApplicativeK.scala, /Users/odersky/workspace/dotty/community-build/community-projects/perspective/dotty/perspective/src/main/scala/perspective/ApplyK.scala, /Users/odersky/workspace/dotty/community-build/community-projects/perspective/dotty/perspective/src/main/scala/perspective/Compose.scala, /Users/odersky/workspace/dotty/community-build/community-projects/perspective/dotty/perspective/src/main/scala/perspective/Const.scala, /Users/odersky/workspace/dotty/community-build/community-projects/perspective/dotty/perspective/src/main/scala/perspective/DistributiveK.scala, /Users/odersky/workspace/dotty/community-build/community-projects/perspective/dotty/perspective/src/main/scala/perspective/Finite.scala, /Users/odersky/workspace/dotty/community-build/community-projects/perspective/dotty/perspective/src/main/scala/perspective/FoldableK.scala, /Users/odersky/workspace/dotty/community-build/community-projects/perspective/dotty/perspective/src/main/scala/perspective/FunctionK.scala, /Users/odersky/workspace/dotty/community-build/community-projects/perspective/dotty/perspective/src/main/scala/perspective/FunctorK.scala, /Users/odersky/workspace/dotty/community-build/community-projects/perspective/dotty/perspective/src/main/scala/perspective/Id.scala, /Users/odersky/workspace/dotty/community-build/community-projects/perspective/dotty/perspective/src/main/scala/perspective/MonadK.scala, /Users/odersky/workspace/dotty/community-build/community-projects/perspective/dotty/perspective/src/main/scala/perspective/RepresentableK.scala, /Users/odersky/workspace/dotty/community-build/community-projects/perspective/dotty/perspective/src/main/scala/perspective/TraverseK.scala, /Users/odersky/workspace/dotty/community-build/community-projects/perspective/dotty/perspective/src/main/scala/perspective/TupleK.scala, /Users/odersky/workspace/dotty/community-build/community-projects/perspective/dotty/perspective/src/main/scala/perspective/ValueK.scala
[error] ## Exception when compiling 15 sources to /Users/odersky/workspace/dotty/community-build/community-projects/perspective/dotty/perspective/target/scala-3.1.1-RC1-bin-SNAPSHOT/classes
[error] java.lang.AssertionError: assertion failed: orphan parameter reference: TypeParamRef(Z)
[error] scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:8)
[error] dotty.tools.dotc.core.tasty.TreePickler.pickleNewType(TreePickler.scala:289)
[error] dotty.tools.dotc.core.tasty.TreePickler.pickleType(TreePickler.scala:160)
[error] dotty.tools.dotc.core.tasty.TreePickler.pickleNewType$$anonfun$11$$anonfun$1(TreePickler.scala:181)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
[error] scala.collection.immutable.List.foreach(List.scala:333)
[error] dotty.tools.dotc.core.tasty.TreePickler.pickleNewType$$anonfun$2(TreePickler.scala:181)
[error] dotty.tools.dotc.core.tasty.TreePickler.withLength(TreePickler.scala:58)
[error] dotty.tools.dotc.core.tasty.TreePickler.pickleNewType(TreePickler.scala:181)
[error] dotty.tools.dotc.core.tasty.TreePickler.pickleType(TreePickler.scala:160)
[error] dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:604)
[error] dotty.tools.dotc.core.tasty.TreePickler.pickleTpt(TreePickler.scala:316)
[error] dotty.tools.dotc.core.tasty.TreePickler.pickleTree$$anonfun$39$$anonfun$1(TreePickler.scala:435)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)

```

This looks like an unrelated problem that was exposed by the fix to `subsumes`. Unfortunately it's too large a project
for me to troubleshoot myself. So we'd need a minimization to get to the root of it.
@smarter smarter merged commit 85462c7 into scala:master Oct 1, 2021
@smarter smarter deleted the fix-13541 branch October 1, 2021 22:01
armanbilge added a commit to armanbilge/schrodinger that referenced this pull request Oct 10, 2021
Depends on scala/scala3#13650

Partially revert "Get tests compiling/passing again"

This partially reverts commit 690fb41.
@Kordyjan Kordyjan added this to the 3.1.1 milestone Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

no implicit values were found with curried type parameters
3 participants