Skip to content

Commit 8effbc4

Browse files
authored
Merge pull request #11013 from dotty-staging/fix-#8752
Disallow type lambdas as F-bounds
2 parents 9d7a17a + 5c6ecef commit 8effbc4

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

compiler/src/dotty/tools/dotc/reporting/messages.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1386,7 +1386,11 @@ import transform.SymUtils._
13861386

13871387
class TypeDoesNotTakeParameters(tpe: Type, params: List[Trees.Tree[Trees.Untyped]])(using Context)
13881388
extends TypeMsg(TypeDoesNotTakeParametersID) {
1389-
def msg = em"$tpe does not take type parameters"
1389+
private def fboundsAddendum =
1390+
if tpe.typeSymbol.isAllOf(Provisional | TypeParam) then
1391+
"\n(Note that F-bounds of type parameters may not be type lambdas)"
1392+
else ""
1393+
def msg = em"$tpe does not take type parameters$fboundsAddendum"
13901394
def explain =
13911395
val ps =
13921396
if (params.size == 1) s"a type parameter ${params.head}"

tests/neg/i8752.check

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
-- [E053] Type Error: tests/neg/i8752.scala:3:41 -----------------------------------------------------------------------
2+
3 |trait Arround1[C <:[X]=>>IterableOps[X,C,C[X]] ] // error // error
3+
| ^^^^
4+
| C does not take type parameters
5+
| (Note that F-bounds of type parameters may not be type lambdas)
6+
7+
longer explanation available when compiling with `-explain`
8+
-- Error: tests/neg/i8752.scala:3:39 -----------------------------------------------------------------------------------
9+
3 |trait Arround1[C <:[X]=>>IterableOps[X,C,C[X]] ] // error // error
10+
| ^
11+
| Type argument C does not have the same kind as its bound [_]

tests/neg/i8752.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import scala.collection.IterableOps
2+
3+
trait Arround1[C <:[X]=>>IterableOps[X,C,C[X]] ] // error // error

0 commit comments

Comments
 (0)