Skip to content

Disallow type lambdas as F-bounds #11013

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 1 commit into from
Jan 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion compiler/src/dotty/tools/dotc/reporting/messages.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1386,7 +1386,11 @@ import transform.SymUtils._

class TypeDoesNotTakeParameters(tpe: Type, params: List[Trees.Tree[Trees.Untyped]])(using Context)
extends TypeMsg(TypeDoesNotTakeParametersID) {
def msg = em"$tpe does not take type parameters"
private def fboundsAddendum =
if tpe.typeSymbol.isAllOf(Provisional | TypeParam) then
"\n(Note that F-bounds of type parameters may not be type lambdas)"
else ""
def msg = em"$tpe does not take type parameters$fboundsAddendum"
def explain =
val ps =
if (params.size == 1) s"a type parameter ${params.head}"
Expand Down
11 changes: 11 additions & 0 deletions tests/neg/i8752.check
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
-- [E053] Type Error: tests/neg/i8752.scala:3:41 -----------------------------------------------------------------------
3 |trait Arround1[C <:[X]=>>IterableOps[X,C,C[X]] ] // error // error
| ^^^^
| C does not take type parameters
| (Note that F-bounds of type parameters may not be type lambdas)

longer explanation available when compiling with `-explain`
-- Error: tests/neg/i8752.scala:3:39 -----------------------------------------------------------------------------------
3 |trait Arround1[C <:[X]=>>IterableOps[X,C,C[X]] ] // error // error
| ^
| Type argument C does not have the same kind as its bound [_]
3 changes: 3 additions & 0 deletions tests/neg/i8752.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import scala.collection.IterableOps

trait Arround1[C <:[X]=>>IterableOps[X,C,C[X]] ] // error // error