We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 399b4af + 02f775f commit e2efddcCopy full SHA for e2efddc
compiler/src/dotty/tools/dotc/core/TypeComparer.scala
@@ -756,13 +756,8 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
756
}
757
758
def tryBaseType(cls2: Symbol) = {
759
- val allowBaseType = !caseLambda.exists || (tp1 match {
760
- case tp: TypeRef if tp.symbol.isClass => true
761
- case AppliedType(tycon: TypeRef, _) if tycon.symbol.isClass => true
762
- case _ => false
763
- })
764
val base = nonExprBaseType(tp1, cls2)
765
- if (base.exists && base.ne(tp1) && allowBaseType)
+ if (base.exists && (base `ne` tp1))
766
isSubType(base, tp2, if (tp1.isRef(cls2)) approx else approx.addLow) ||
767
base.isInstanceOf[OrType] && fourthTry
768
// if base is a disjunction, this might have come from a tp1 type that
@@ -781,7 +776,7 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
781
776
|| narrowGADTBounds(tp1, tp2, approx, isUpper = true))
782
777
&& (tp2.isAny || GADTusage(tp1.symbol))
783
778
784
- !caseLambda.exists && isSubType(hi1, tp2, approx.addLow) || compareGADT || tryLiftedToThis1
779
+ isSubType(hi1, tp2, approx.addLow) || compareGADT || tryLiftedToThis1
785
780
case _ =>
786
// `Mode.RelaxedOverriding` is only enabled when checking Java overriding
787
// in explicit nulls, and `Null` becomes a bottom type, which allows
compiler/test/dotc/pos-test-pickling.blacklist
@@ -43,6 +43,7 @@ i9999.scala
43
7512.scala
44
i6505.scala
45
i15158.scala
46
+i15155.scala
47
48
# Opaque type
49
i5720.scala
compiler/test/dotty/tools/dotc/CompilationTests.scala
@@ -200,7 +200,6 @@ class CompilationTests {
200
@Test def runAll: Unit = {
201
implicit val testGroup: TestGroup = TestGroup("runAll")
202
aggregateTests(
203
- compileFile("tests/run-custom-args/typeclass-derivation1.scala", defaultOptions.without(yCheckOptions: _*)),
204
compileFile("tests/run-custom-args/tuple-cons.scala", allowDeepSubtypes),
205
compileFile("tests/run-custom-args/i5256.scala", allowDeepSubtypes),
206
compileFile("tests/run-custom-args/no-useless-forwarders.scala", defaultOptions and "-Xmixin-force-forwarders:false"),
tests/neg/11982.scala
@@ -4,8 +4,8 @@ type Head[X] = X match {
4
5
6
object Unpair {
7
- def unpair[X <: Tuple2[Any, Any]]: Head[X] = 1 // error
8
- unpair[Tuple2["msg", 42]]: "msg"
+ def unpair[X <: Tuple2[Any, Any]]: Head[X] = 1
+ unpair[Tuple2["msg", 42]]: "msg" // error
9
10
11
@@ -14,8 +14,8 @@ type Head2[X] = X match {
14
15
16
object Unpair2 {
17
- def unpair[X <: Tuple2[Tuple2[Any, Any], Tuple2[Any, Any]]]: Head2[X] = 1 // error
18
- unpair[Tuple2[Tuple2["msg", 42], Tuple2[41, 40]]]: "msg"
+ def unpair[X <: Tuple2[Tuple2[Any, Any], Tuple2[Any, Any]]]: Head2[X] = 1
+ unpair[Tuple2[Tuple2["msg", 42], Tuple2[41, 40]]]: "msg" // error
19
20
21
@@ -35,6 +35,6 @@ type Head4[X] = X match {
35
36
37
object Unpair4 {
38
- def unpair[X <: Foo[Any, Any]]: Head4[Foo[X, X]] = 1 // error
39
- unpair[Foo["msg", 42]]: "msg"
+ def unpair[X <: Foo[Any, Any]]: Head4[Foo[X, X]] = 1
+ unpair[Foo["msg", 42]]: "msg" // error
40
tests/neg/6570-1.scala
@@ -33,21 +33,7 @@ class Asploder extends Root[Cov[Box[Int & String]]] {
33
34
object Main {
- def foo[T <: Cov[Box[Int]]](c: Root[T]): Trait2 = c.thing // error
- // ^^^^^^^
- // Found: M[T]
- // Required: Trait2
- //
41
- // where: T is a type in method foo with bounds <: Cov[Box[Int]]
42
- // Note: a match type could not be fully reduced:
- // trying to reduce M[T]
- // failed since selector T
- // does not match case Cov[x] => N[x]
- // and cannot be shown to be disjoint from it either.
50
-
+ def foo[T <: Cov[Box[Int]]](c: Root[T]): Trait2 = c.thing
51
def explode = foo(new Asploder)
52
53
def main(args: Array[String]): Unit =
tests/neg/6570.scala
@@ -21,7 +21,7 @@ object UpperBoundParametricVariant {
trait Child[A <: Cov[Int]] extends Root[A]
22
23
// we reduce `M[T]` to `Trait2`, even though we cannot be certain of that
24
- def foo[T <: Cov[Int]](c: Child[T]): Trait2 = c.thing // error
+ def foo[T <: Cov[Int]](c: Child[T]): Trait2 = c.thing
25
26
class Asploder extends Child[Cov[String & Int]] {
27
def thing = new Trait1 {} // error
@@ -42,7 +42,7 @@ object InheritanceVariant {
trait Child extends Root { type B <: { type A <: Int } }
- def foo(c: Child): Trait2 = c.thing // error
+ def foo(c: Child): Trait2 = c.thing
class Asploder extends Child {
type B = { type A = String & Int }
@@ -98,7 +98,7 @@ object UpperBoundVariant {
98
99
trait Child extends Root { type A <: Cov[Int] }
100
101
102
103
104
type A = Cov[String & Int]
tests/neg/i15155.check
tests/neg/i15155.scala renamed to tests/pos/i15155.scala
@@ -7,5 +7,5 @@ type EnumValue[A <: Enumeration] = A match {
// https://github.com/json4s/json4s/blob/355d8751391773e0d79d04402a4f9fb7bfc684ec/ext/src/main/scala/org/json4s/ext/EnumSerializer.scala#L25-L26
class EnumSerializer[E <: Enumeration: ClassTag](enumeration: E) {
- val EnumerationClass = classOf[EnumValue[E]] // error
+ val EnumerationClass = classOf[EnumValue[E]]
tests/run-custom-args/typeclass-derivation1.scala renamed to tests/run/typeclass-derivation1.scala
@@ -96,15 +96,3 @@ object Test extends App {
96
assert(!eq2.equals(yss, xss))
97
assert(eq2.equals(yss, yss))
-// -Ycheck failure minimized to:
-// import scala.compiletime.*
-// object Eq {
-// inline def deriveForProduct[Elems <: Tuple](xs: Elems): Boolean = inline erasedValue[Elems] match {
-// case _: (elem *: elems1) =>
105
-// val xs1 = xs.asInstanceOf[elem *: elems1]
106
-// deriveForProduct(xs1.tail)
107
-// case _: EmptyTuple =>
108
-// true
109
-// }
110
0 commit comments