Skip to content

Commit 08376a5

Browse files
committed
Reject capturing function type in polymorphic functions
1 parent 6dc3737 commit 08376a5

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

compiler/src/dotty/tools/dotc/parsing/Parsers.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1419,6 +1419,7 @@ object Parsers {
14191419
private def getFunction(tree: Tree): Option[Function] = tree match {
14201420
case Parens(tree1) => getFunction(tree1)
14211421
case Block(Nil, tree1) => getFunction(tree1)
1422+
case Function(_, _: CapturesAndResult) => None
14221423
case t: Function => Some(t)
14231424
case _ => None
14241425
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import language.experimental.captureChecking
2+
type Foo1 = [R] -> (x: Unit) ->{} Unit // error
3+
type Foo2 = [R] -> (x: Unit) ->{cap} Unit // error
4+
type Foo3 = (c: Int^) -> [R] -> (x: Unit) ->{c} Unit // error
5+
type Foo4 = (c: Int^) -> [R] -> (x0: Unit) -> (x: Unit) ->{c} Unit

0 commit comments

Comments
 (0)