-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make sure in CI that we do not unexpectedly fall back on legacy match…
… type reduction. We introduce a new flag `-Yno-legacy-match-types`, which forbids the reduction of "legacy" match types. Like `-Yno-deep-subtypes`, it is meant to be used in our CI. With it, we check that we do not unexpectedly fall back on legacy match types in tests for which the specced match types are enough. Later, we should consider integrating that behavior with the source level so that it reaches users.
- Loading branch information
Showing
21 changed files
with
119 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
// scalac: -Yno-legacy-match-types:false | ||
|
||
object Base { | ||
trait Trait1 | ||
trait Trait2 | ||
|
This file contains 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,30 @@ | ||
-- [E189] Type Error: tests/neg/legacy-match-types.scala:7:23 ---------------------------------------------------------- | ||
7 |type InvNesting[X] = X match // error | ||
| ^ | ||
| Illegal match type because it contains the legacy, unspecifed case | ||
| case Inv[Cov[t]] => t | ||
8 | case Inv[Cov[t]] => t | ||
-- [E189] Type Error: tests/neg/legacy-match-types.scala:10:26 --------------------------------------------------------- | ||
10 |type ContraNesting[X] = X match // error | ||
| ^ | ||
| Illegal match type because it contains the legacy, unspecifed case | ||
| case Contra[Cov[t]] => t | ||
11 | case Contra[Cov[t]] => t | ||
-- [E189] Type Error: tests/neg/legacy-match-types.scala:15:22 --------------------------------------------------------- | ||
15 |type AndTypeMT[X] = X match // error | ||
| ^ | ||
| Illegal match type because it contains the legacy, unspecifed case | ||
| case t & Seq[Any] => t | ||
16 | case t & Seq[Any] => t | ||
-- [E189] Type Error: tests/neg/legacy-match-types.scala:22:33 --------------------------------------------------------- | ||
22 |type TypeAliasWithBoundMT[X] = X match // error | ||
| ^ | ||
| Illegal match type because it contains the legacy, unspecifed case | ||
| case IsSeq[t] => t | ||
23 | case IsSeq[t] => t | ||
-- [E189] Type Error: tests/neg/legacy-match-types.scala:33:34 --------------------------------------------------------- | ||
33 |type TypeMemberExtractorMT[X] = X match // error | ||
| ^ | ||
| Illegal match type because it contains the legacy, unspecifed case | ||
| case TypeMemberAux[t] => t | ||
34 | case TypeMemberAux[t] => t |
This file contains 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,34 @@ | ||
class Inv[T] | ||
class Cov[+T] | ||
class Contra[-T] | ||
|
||
// Nesting captures in non-covariant position | ||
|
||
type InvNesting[X] = X match // error | ||
case Inv[Cov[t]] => t | ||
|
||
type ContraNesting[X] = X match // error | ||
case Contra[Cov[t]] => t | ||
|
||
// Intersection type to type-test and capture at the same time | ||
|
||
type AndTypeMT[X] = X match // error | ||
case t & Seq[Any] => t | ||
|
||
// Poly type alias with a bound to type-test and capture at the same time | ||
|
||
type IsSeq[X <: Seq[Any]] = X | ||
|
||
type TypeAliasWithBoundMT[X] = X match // error | ||
case IsSeq[t] => t | ||
|
||
// Poly type alias with a type member refinement to extract the type member | ||
|
||
class Base { | ||
type TypeMember | ||
} | ||
|
||
type TypeMemberAux[X] = Base { type TypeMember = X } | ||
|
||
type TypeMemberExtractorMT[X] = X match // error | ||
case TypeMemberAux[t] => t |
This file contains 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 @@ | ||
trait Monoidal { | ||
type to[_] <: Tuple | ||
} | ||
|
||
object eithers extends Monoidal { | ||
class Wrap[T] | ||
|
||
type to[t] <: Tuple = Wrap[t] match { | ||
case Wrap[Nothing] => EmptyTuple | ||
case Wrap[other] => other match | ||
case Either[hd, tl] => hd *: to[tl] | ||
} | ||
} |
This file contains 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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
// scalac: -Yno-legacy-match-types:false | ||
|
||
trait Monoidal { | ||
type to[_] <: Tuple | ||
} | ||
|
This file contains 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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
// scalac: -Yno-legacy-match-types:false | ||
|
||
final class Two[A, B]() | ||
|
||
final class Blaaa | ||
|
This file contains 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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
// scalac: -Yno-legacy-match-types:false | ||
|
||
type RemoveFrom[R, A] = R match { | ||
case A & newType => newType | ||
} | ||
|
This file contains 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 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 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 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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
// scalac: -Yno-legacy-match-types:false | ||
|
||
import scala.util.Try | ||
|
||
trait RDF: | ||
|
This file contains 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 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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
// scalac: -Yno-legacy-match-types:false | ||
|
||
trait TC[T] | ||
|
||
object TC { | ||
|
This file contains 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 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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
// scalac: -Yno-legacy-match-types:false | ||
|
||
import Macros.simplified | ||
|
||
object Test { | ||
|