-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix a bundle of patmat issues #21000
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
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
4f22672
Re-fix skipping match analysis & inlining
dwijnand 3ba51a6
Fix PrefixSetting
dwijnand 5994ea7
Childless
dwijnand b56da91
Fix a bundle of patmat issues
dwijnand 7183bb2
Detail why not baseType
dwijnand 8df91fa
Strip null in exhaustivityCheckable
dwijnand e160de7
Fix SeqFactoryClass#unapplySeq
dwijnand 5fd810e
Strip null on the scrutinee
dwijnand 4dd8e8a
Maximise once more
dwijnand 5b425ee
Detail the second-pass maximizeType in Space.signature
dwijnand ab240f1
Only strip under unsafeNulls
dwijnand File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
sealed trait NatT | ||
case class Zero() extends NatT | ||
case class Succ[+N <: NatT](n: N) extends NatT | ||
|
||
type Mod2[N <: NatT] <: NatT = N match | ||
case Zero => Zero | ||
case Succ[Zero] => Succ[Zero] | ||
case Succ[Succ[predPredN]] => Mod2[predPredN] | ||
|
||
def dependentlyTypedMod2[N <: NatT](n: N): Mod2[N] = n match | ||
case Zero(): Zero => Zero() // warn | ||
case Succ(Zero()): Succ[Zero] => Succ(Zero()) // warn | ||
case Succ(Succ(predPredN)): Succ[Succ[?]] => dependentlyTypedMod2(predPredN) // warn |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
sealed trait T_A[A, B] | ||
type X = T_A[Byte, Byte] | ||
|
||
case class CC_B[A](a: A) extends T_A[A, X] | ||
|
||
val v_a: T_A[X, X] = CC_B(null) | ||
val v_b = v_a match | ||
case CC_B(_) => 0 // warn: unreachable | ||
case _ => 1 | ||
// for CC_B[A] to match T_A[X, X] | ||
// A := X | ||
// so require X, aka T_A[Byte, Byte] | ||
// which isn't instantiable, outside of null |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
sealed trait T_B[C, D] | ||
|
||
case class CC_A() | ||
case class CC_B[A, C](a: A) extends T_B[C, CC_A] | ||
case class CC_C[C, D](a: T_B[C, D]) extends T_B[Int, CC_A] | ||
case class CC_E(a: CC_C[Char, Byte]) | ||
|
||
val v_a: T_B[Int, CC_A] = CC_B(CC_E(CC_C(null))) | ||
val v_b = v_a match | ||
case CC_B(CC_E(CC_C(_))) => 0 // warn: unreachable | ||
case _ => 1 | ||
// for CC_B[A, C] to match T_B[C, CC_A] | ||
// C <: Int, ok | ||
// A <: CC_E, ok | ||
// but you need a CC_C[Char, Byte] | ||
// which requires a T_B[Char, Byte] | ||
// which isn't instantiable, outside of null |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
sealed trait T_A[A, B] | ||
sealed trait T_B[C] | ||
|
||
case class CC_D[A, C]() extends T_A[A, C] | ||
case class CC_E() extends T_B[Nothing] | ||
case class CC_G[A, C](c: C) extends T_A[A, C] | ||
|
||
val v_a: T_A[Boolean, T_B[Boolean]] = CC_G(null) | ||
val v_b = v_a match { | ||
case CC_D() => 0 | ||
case CC_G(_) => 1 // warn: unreachable | ||
// for CC_G[A, C] to match T_A[Boolean, T_B[Boolean]] | ||
// A := Boolean, which is ok | ||
// C := T_B[Boolean], | ||
// which isn't instantiable, outside of null | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
sealed trait T_A[A] | ||
case class CC_B[A](a: T_A[A]) extends T_A[Byte] | ||
case class CC_E[A](b: T_A[A]) extends T_A[Byte] | ||
|
||
val v_a: T_A[Byte] = CC_E(CC_B(null)) | ||
val v_b: Int = v_a match { // warn: not exhaustive | ||
case CC_E(CC_E(_)) => 0 | ||
case CC_B(_) => 1 | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
sealed trait T_A[A] | ||
case class CC_B[A](a: T_A[A], c: T_A[A]) extends T_A[Char] | ||
case class CC_C[A]() extends T_A[A] | ||
case class CC_G() extends T_A[Char] | ||
|
||
val v_a: T_A[Char] = CC_B(CC_G(), CC_C()) | ||
val v_b: Int = v_a match { // warn: not exhaustive | ||
case CC_C() => 0 | ||
case CC_G() => 1 | ||
case CC_B(CC_B(_, _), CC_C()) => 2 | ||
case CC_B(CC_C(), CC_C()) => 3 | ||
case CC_B(_, CC_G()) => 4 | ||
case CC_B(_, CC_B(_, _)) => 5 | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
sealed trait T_A[B] | ||
sealed trait T_B[C] | ||
case class CC_B[C]() extends T_A[T_B[C]] | ||
case class CC_C[B, C](c: T_A[B], d: T_B[C]) extends T_B[C] | ||
case class CC_E[C]() extends T_B[C] | ||
|
||
val v_a: T_B[Int] = CC_C(null, CC_E()) | ||
val v_b: Int = v_a match { // warn: not exhaustive | ||
case CC_C(_, CC_C(_, _)) => 0 | ||
case CC_E() => 5 | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
sealed trait Foo | ||
case class Foo1() extends Foo | ||
case class Foo2[A, B]() extends Foo | ||
|
||
sealed trait Bar[A, B] | ||
case class Bar1[A, C, D](a: Bar[C, D]) extends Bar[A, Bar[C, D]] | ||
case class Bar2[ C, D](b: Bar[C, D], c: Foo) extends Bar[Bar1[Int, Byte, Int], Bar[C, D]] | ||
|
||
class Test: | ||
def m1(bar: Bar[Bar1[Int, Byte, Int], Bar[Char, Char]]): Int = bar match | ||
case Bar1(_) => 0 | ||
case Bar2(_, Foo2()) => 1 | ||
def t1 = m1(Bar2(null, Foo1())) | ||
// for Bar2[C, D] to match the scrutinee | ||
// C := Char and D := Char | ||
// which requires a Bar[Char, Char] | ||
// which isn't instantiable, outside of null |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
sealed trait Foo[A] | ||
case class Bar[C](x: Foo[C]) extends Foo[C] | ||
case class End[B]() extends Foo[B] | ||
class Test: | ||
def m1[M](foo: Foo[M]): Int = foo match // warn: not exhaustive | ||
case End() => 0 | ||
case Bar(End()) => 1 | ||
def t1 = m1[Int](Bar[Int](Bar[Int](End[Int]()))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
//> using options -Yexplicit-nulls -Yno-flexible-types | ||
|
||
import scala.language.unsafeNulls | ||
|
||
import java.util.concurrent.CompletableFuture | ||
import scala.jdk.CollectionConverters._ | ||
|
||
class Test1: | ||
def m1 = | ||
val fut: CompletableFuture[Either[String, List[String]]] = ??? | ||
fut.thenApply: | ||
case Right(edits: List[String]) => edits.asJava | ||
case Left(error: String) => throw new Exception(error) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class D1 | ||
class D2 | ||
|
||
class Test1: | ||
type Ds = List[D1] | List[D2] | ||
def m1(dss: List[Ds]) = | ||
dss.flatMap: | ||
case Seq(d) => Some(1) | ||
case Seq(head, tail*) => Some(2) | ||
case Seq() => None |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
sealed trait Foo[A] | ||
case class Bar[C](x: Foo[C]) extends Foo[Int] | ||
case class End[B]() extends Foo[B] | ||
class Test: | ||
def m1[M](foo: Foo[M]): Int = foo match // warn: not exhaustive | ||
case End() => 0 | ||
case Bar(End()) => 1 | ||
def t1 = m1[Int](Bar[Int](Bar[Int](End[Int]()))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
-- [E029] Pattern Match Exhaustivity Warning: tests/warn/i20132.stream-Tuple2.safeNulls.scala:8:24 --------------------- | ||
8 | xs.asJava.forEach { case (a, b) => // warn | ||
| ^ | ||
| match may not be exhaustive. | ||
| | ||
| It would fail on pattern case: _: Null | ||
| | ||
| longer explanation available when compiling with `-explain` |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.