Skip to content

Commit 39acd47

Browse files
authored
Merge pull request #2523 from biboudis/fix-2512
Fix #2512: Implicit keyword not allowed on return types
2 parents b377235 + 3db3f1b commit 39acd47

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -774,7 +774,10 @@ object Parsers {
774774
in.token match {
775775
case ARROW => functionRest(t :: Nil)
776776
case FORSOME => syntaxError(ExistentialTypesNoLongerSupported()); t
777-
case _ => t
777+
case _ =>
778+
if (isImplicit && !t.isInstanceOf[ImplicitFunction])
779+
syntaxError("Types with implicit keyword can only be function types", Position(start, start + nme.IMPLICITkw.asSimpleName.length))
780+
t
778781
}
779782
}
780783

tests/neg/i2512.scala

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
object Test {
3+
4+
def foo0(): implicit Int => Int = ???
5+
val foo01: implicit (String, Int) => Int = ???
6+
7+
def foo1(f: Int => implicit Int): Int = ??? // error
8+
def foo2(): implicit Int = ??? // error
9+
def foo3(): Int => implicit Int = ??? // error
10+
}

0 commit comments

Comments
 (0)