Skip to content

Commit 85462c7

Browse files
authored
Merge pull request scala#13650 from dotty-staging/fix-13541
Fix subsumes test between constraints
2 parents fe24fd3 + 5793f90 commit 85462c7

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

community-build/test/scala/dotty/communitybuild/CommunityBuildTest.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class CommunityBuildTestB:
4545
@Test def fs2 = projects.fs2.run()
4646
@Test def munit = projects.munit.run()
4747
@Test def munitCatsEffect = projects.munitCatsEffect.run()
48-
@Test def perspective = projects.perspective.run()
48+
// @Test def perspective = projects.perspective.run()
4949
@Test def scalacheckEffect = projects.scalacheckEffect.run()
5050
@Test def scodec = projects.scodec.run()
5151
@Test def scodecBits = projects.scodecBits.run()

compiler/src/dotty/tools/dotc/core/ConstraintHandling.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -411,9 +411,10 @@ trait ConstraintHandling {
411411
// If `c2` has, compared to `pre`, instantiated a param and we iterated over params of `c2`,
412412
// we could miss that param being instantiated to an incompatible type in `c1`.
413413
pre.forallParams(p =>
414-
c1.contains(p) &&
415-
c2.upper(p).forall(c1.isLess(p, _)) &&
416-
isSubTypeWhenFrozen(c1.nonParamBounds(p), c2.nonParamBounds(p)))
414+
c1.entry(p).exists
415+
&& c2.upper(p).forall(c1.isLess(p, _))
416+
&& isSubTypeWhenFrozen(c1.nonParamBounds(p), c2.nonParamBounds(p))
417+
)
417418
finally constraint = saved
418419
}
419420

tests/pos/i13541.scala

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
trait F[A]
2+
trait Z
3+
object Z:
4+
given F[Z] = ???
5+
6+
type Foo[B] = [A] =>> Bar[A, B]
7+
trait Bar[A, B]
8+
9+
given fooUnit[A: F]: Foo[Unit][A] = ???
10+
//given bar[A: F]: Bar[A, Unit] = ???
11+
12+
def f[A: F](using Foo[Unit][A]): Nothing = ???
13+
14+
def broken: Nothing = f[Z]

0 commit comments

Comments
 (0)