Skip to content
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

Fix i18518 #18520

Merged
merged 2 commits into from
Oct 1, 2023
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
5 changes: 5 additions & 0 deletions compiler/src/dotty/tools/dotc/parsing/Parsers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1419,6 +1419,11 @@ object Parsers {
private def getFunction(tree: Tree): Option[Function] = tree match {
case Parens(tree1) => getFunction(tree1)
case Block(Nil, tree1) => getFunction(tree1)
case Function(_, _: CapturesAndResult) =>
// A function tree like this will be desugared
// into a capturing type in the typer,
// so None is returned.
None
case t: Function => Some(t)
case _ => None
}
Expand Down
5 changes: 5 additions & 0 deletions tests/neg-custom-args/captures/i18518.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import language.experimental.captureChecking
type Foo1 = [R] -> (x: Unit) ->{} Unit // error
type Foo2 = [R] -> (x: Unit) ->{cap} Unit // error
type Foo3 = (c: Int^) -> [R] -> (x: Unit) ->{c} Unit // error
type Foo4 = (c: Int^) -> [R] -> (x0: Unit) -> (x: Unit) ->{c} Unit
Loading