Skip to content

Commit 3db3f1b

Browse files
committed
Replace if with case and drop extra condition
1 parent 43b6fe6 commit 3db3f1b

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

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

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -730,16 +730,11 @@ object Parsers {
730730
def typ(): Tree = {
731731
val start = in.offset
732732
val isImplicit = in.token == IMPLICIT
733-
var isImplicitFun = false
734733
if (isImplicit) in.nextToken()
735734
def functionRest(params: List[Tree]): Tree =
736735
atPos(start, accept(ARROW)) {
737736
val t = typ()
738-
if (isImplicit) {
739-
isImplicitFun = true
740-
new ImplicitFunction(params, t)
741-
}
742-
else Function(params, t)
737+
if (isImplicit) new ImplicitFunction(params, t) else Function(params, t)
743738
}
744739
val t =
745740
if (in.token == LPAREN) {
@@ -776,13 +771,13 @@ object Parsers {
776771
}
777772
else infixType()
778773

779-
if (isImplicit && !isImplicitFun && in.token != ARROW)
780-
syntaxError("Types with implicit keyword can only be function types", Position(start, start + nme.IMPLICITkw.asSimpleName.length))
781-
782774
in.token match {
783775
case ARROW => functionRest(t :: Nil)
784776
case FORSOME => syntaxError(ExistentialTypesNoLongerSupported()); t
785-
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
786781
}
787782
}
788783

0 commit comments

Comments
 (0)