-
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.
Merge pull request #12378 from 7mind/feature/kind-projector-underscores
Allow `_` as a type lambda placeholder in `-Ykind-projector:underscores` compatiblity mode
- Loading branch information
Showing
9 changed files
with
136 additions
and
16 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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
-- Error: tests/neg-custom-args/kind-projector-underscores.scala:7:23 -------------------------------------------------- | ||
7 |class Bar3 extends Foo[λ[List[x] => Int]] // error | ||
| ^^^^^^^^^^^^^^^^^ | ||
| λ requires a single argument of the form X => ... or (X, Y) => ... | ||
-- [E095] Syntax Error: tests/neg-custom-args/kind-projector-underscores.scala:10:8 ------------------------------------ | ||
10 | type -_ = Int // error -_ not allowed as a type def name without backticks | ||
| ^ | ||
| =, >:, or <: expected, but '_' found | ||
|
||
longer explanation available when compiling with `-explain` | ||
-- [E095] Syntax Error: tests/neg-custom-args/kind-projector-underscores.scala:11:8 ------------------------------------ | ||
11 | type +_ = Int // error +_ not allowed as a type def name without backticks | ||
| ^ | ||
| =, >:, or <: expected, but '_' found | ||
|
||
longer explanation available when compiling with `-explain` | ||
-- Error: tests/neg-custom-args/kind-projector-underscores.scala:5:23 -------------------------------------------------- | ||
5 |class Bar1 extends Foo[Either[_, _]] // error | ||
| ^^^^^^^^^^^^ | ||
| Type argument Either does not have the same kind as its bound [_$1] | ||
-- Error: tests/neg-custom-args/kind-projector-underscores.scala:6:22 -------------------------------------------------- | ||
6 |class Bar2 extends Foo[_] // error | ||
| ^ | ||
| Type argument _ does not have the same kind as its bound [_$1] |
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,12 @@ | ||
package kind_projector_neg | ||
|
||
trait Foo[F[_]] | ||
|
||
class Bar1 extends Foo[Either[_, _]] // error | ||
class Bar2 extends Foo[_] // error | ||
class Bar3 extends Foo[λ[List[x] => Int]] // error | ||
|
||
object Test { | ||
type -_ = Int // error -_ not allowed as a type def name without backticks | ||
type +_ = Int // error +_ not allowed as a type def name without backticks | ||
} |
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,59 @@ | ||
package kind_projector | ||
|
||
trait Foo[F[_]] | ||
trait Qux[F[_, _]] | ||
trait Baz[F[_], A, B] | ||
|
||
trait FooPlus[+F[+_]] | ||
trait QuxPlus[+F[+_, +_]] | ||
trait BazPlus[+F[+_], +A, +B] | ||
|
||
trait FooMinus[-F[-_]] | ||
trait QuxMinus[-F[-_, -_]] | ||
trait BazMinus[-F[-_], -A, -B] | ||
|
||
class Bar1 extends Foo[Either[Int, _]] | ||
class Bar2 extends Foo[Either[_, Int]] | ||
class Bar3 extends Foo[_ => Int] | ||
class Bar4 extends Foo[Int => _] | ||
class Bar5 extends Foo[(Int, _, Int)] | ||
class Bar6 extends Foo[λ[x => Either[Int, x]]] | ||
class Bar7 extends Qux[λ[(x, y) => Either[y, x]]] | ||
class Bar8 extends Foo[Baz[Int => _, _, Int]] | ||
class Bar9 extends Foo[λ[x => Baz[x => _, Int, x]]] | ||
|
||
class BarPlus1 extends FooPlus[Either[Int, +_]] | ||
class BarPlus2 extends FooPlus[Either[+_, Int]] | ||
class BarPlus3 extends FooPlus[Int => +_] | ||
class BarPlus4 extends FooPlus[(Int, +_, Int)] | ||
class BarPlus5 extends FooPlus[λ[`+x` => Either[Int, x]]] | ||
class BarPlus6 extends QuxPlus[λ[(`+x`, `+y`) => Either[y, x]]] | ||
class BarPlus7 extends FooPlus[BazPlus[Int => +_, +_, Int]] | ||
|
||
class BarMinus1 extends FooMinus[-_ => Int] | ||
|
||
class VarianceAnnotationIsActuallyIgnored1 extends FooPlus[Either[Int, -_]] | ||
class VarianceAnnotationIsActuallyIgnored2 extends FooPlus[Either[-_, Int]] | ||
class VarianceAnnotationIsActuallyIgnored3 extends FooMinus[+_ => Int] | ||
class VarianceAnnotationIsActuallyIgnored4 extends FooPlus[Int => -_] | ||
class VarianceAnnotationIsActuallyIgnored5 extends FooPlus[(Int, -_, Int)] | ||
class VarianceAnnotationIsActuallyIgnored6 extends FooPlus[λ[`-x` => Either[Int, x]]] | ||
class VarianceAnnotationIsActuallyIgnored7 extends QuxPlus[λ[(`-x`, `-y`) => Either[y, x]]] | ||
class VarianceAnnotationIsActuallyIgnored8 extends FooPlus[BazPlus[Int => -_, -_, Int]] | ||
class VarianceAnnotationIsActuallyIgnored9 extends Foo[λ[`-x` => BazPlus[x => -_, Int, x]]] | ||
|
||
class BackticksAreFine1 extends FooPlus[Either[Int, `-_`]] | ||
class BackticksAreFine2 extends FooPlus[Either[`-_`, Int]] | ||
class BackticksAreFine3 extends FooMinus[`+_` => Int] | ||
class BackticksAreFine4 extends FooPlus[Int => `-_`] | ||
class BackticksAreFine5 extends FooPlus[(Int, `-_`, Int)] | ||
class BackticksAreFine6 extends FooPlus[BazPlus[Int => `-_`, `-_`, Int]] | ||
class BackticksAreFine7 extends Foo[λ[`-x` => BazPlus[x => `-_`, Int, x]]] | ||
|
||
class SpacesAreFine1 extends FooPlus[Either[Int, - _ ]] | ||
class SpacesAreFine2 extends FooPlus[Either[ - _ , Int]] | ||
class SpacesAreFine3 extends FooMinus[ + _ => Int] | ||
class SpacesAreFine4 extends FooPlus[Int => - _] | ||
class SpacesAreFine5 extends FooPlus[(Int, - _, Int)] | ||
class SpacesAreFine6 extends FooPlus[BazPlus[Int => - _ , - _, Int]] | ||
class SpacesAreFine7 extends Foo[λ[`-x` => BazPlus[x => - _ , Int, x]]] |