@@ -1363,47 +1363,56 @@ object Parsers {
13631363 * | InfixType 
13641364 * | CaptureSet Type 
13651365 * FunType ::= (MonoFunType | PolyFunType) 
1366-  * MonoFunType ::= FunTypeArgs (‘=>’ | ‘?=>’) Type 
1367-  * PolyFunType ::= HKTypeParamClause '=>' Type 
1366+  * MonoFunType ::= FunTypeArgs (‘=>’ | ‘?=>’ | ‘->’ | ‘?->’  ) Type 
1367+  * PolyFunType ::= HKTypeParamClause ( '=>' | ‘->’_)  Type 
13681368 * FunTypeArgs ::= InfixType 
13691369 * | `(' [ [ ‘[using]’ ‘['erased'] FunArgType {`,' FunArgType } ] `)' 
13701370 * | '(' [ ‘[using]’ ‘['erased'] TypedFunParam {',' TypedFunParam } ')' 
13711371 * CaptureSet ::= `{` CaptureRef {`,` CaptureRef} `}` 
13721372 * CaptureRef ::= Ident 
13731373 */  
1374-  def  typ ():  Tree  =  { 
1374+  def  typ ():  Tree  = 
13751375 val  start  =  in.offset
13761376 var  imods  =  Modifiers ()
13771377 def  functionRest (params : List [Tree ]):  Tree  = 
13781378 val  paramSpan  =  Span (start, in.lastOffset)
13791379 atSpan(start, in.offset) {
1380-  if  in.token ==  TLARROW  then 
1380+  var  token  =  in.token
1381+  if  in.isIdent(nme.PUREARROW ) then 
1382+  token =  ARROW 
1383+  else  if  in.isIdent(nme.PURECTXARROW ) then 
1384+  token =  CTXARROW 
1385+  else  if  token ==  TLARROW  then 
13811386 if  ! imods.flags.isEmpty ||  params.isEmpty then 
13821387 syntaxError(em " illegal parameter list for type lambda " , start)
1383-  in.token =  ARROW 
1384-  else 
1385-  for  case  ValDef (_, tpt : ByNameTypeTree , _) <-  params do 
1386-  syntaxError(em " parameter of type lambda may not be call-by-name " , tpt.span)
1387-  in.nextToken()
1388-  return  TermLambdaTypeTree (params.asInstanceOf [List [ValDef ]], typ())
1388+  token =  ARROW 
1389+  else  if  ctx.settings.Ycc .value then 
1390+  //  `=>` means impure function under -Ycc whereas `->` is a regular function.
1391+  //  Without -Ycc they both mean regular function.
1392+  imods |=  Impure 
13891393
1390-  if  in. token ==  CTXARROW  then 
1394+  if  token ==  CTXARROW  then 
13911395 in.nextToken()
13921396 imods |=  Given 
1397+  else  if  token ==  ARROW  ||  token ==  TLARROW  then 
1398+  in.nextToken()
13931399 else 
13941400 accept(ARROW )
1395-  val  t  =  typ()
13961401
1397-  if  imods.isOneOf(Given  |  Erased ) then 
1402+  val  resultType  =  typ()
1403+  if  token ==  TLARROW  then 
1404+  for  case  ValDef (_, tpt : ByNameTypeTree , _) <-  params do 
1405+  syntaxError(em " parameter of type lambda may not be call-by-name " , tpt.span)
1406+  TermLambdaTypeTree (params.asInstanceOf [List [ValDef ]], resultType)
1407+  else  if  imods.isOneOf(Given  |  Erased  |  Impure ) then 
13981408 if  imods.is(Given ) &&  params.isEmpty then 
13991409 syntaxError(" context function types require at least one parameter" 
1400-  new   FunctionWithMods (params, t , imods)
1410+  FunctionWithMods (params, resultType , imods)
14011411 else  if  ! ctx.settings.YkindProjector .isDefault then 
1402-  val  (newParams :+  newT, tparams) =  replaceKindProjectorPlaceholders(params :+  t)
1403- 
1404-  lambdaAbstract(tparams, Function (newParams, newT))
1412+  val  (newParams :+  newResultType, tparams) =  replaceKindProjectorPlaceholders(params :+  resultType)
1413+  lambdaAbstract(tparams, Function (newParams, newResultType))
14051414 else 
1406-  Function (params, t )
1415+  Function (params, resultType )
14071416 }
14081417 def  funTypeArgsRest (first : Tree , following : () =>  Tree ) =  {
14091418 val  buf  =  new  ListBuffer [Tree ] +=  first
@@ -1461,7 +1470,7 @@ object Parsers {
14611470 val  tparams  =  typeParamClause(ParamOwner .TypeParam )
14621471 if  (in.token ==  TLARROW )
14631472 atSpan(start, in.skipToken())(LambdaTypeTree (tparams, toplevelTyp()))
1464-  else  if  (in.token ==  ARROW ) {
1473+  else  if  (in.token ==  ARROW   ||  in.isIdent(nme. PUREARROW ) ) {
14651474 val  arrowOffset  =  in.skipToken()
14661475 val  body  =  toplevelTyp()
14671476 atSpan(start, arrowOffset) {
@@ -1482,16 +1491,18 @@ object Parsers {
14821491 else  if  (in.token ==  INDENT ) enclosed(INDENT , typ())
14831492 else  infixType()
14841493
1485-  in.token match  { 
1494+  in.token match 
14861495 case  ARROW  |  CTXARROW  =>  functionRest(t ::  Nil )
14871496 case  MATCH  =>  matchType(t)
14881497 case  FORSOME  =>  syntaxError(ExistentialTypesNoLongerSupported ()); t
14891498 case  _ => 
1490-  if  (imods.is(Erased ) &&  ! t.isInstanceOf [FunctionWithMods ])
1491-  syntaxError(ErasedTypesCanOnlyBeFunctionTypes (), implicitKwPos(start))
1492-  t
1493-  }
1494-  }
1499+  if  isIdent(nme.PUREARROW ) ||  isIdent(nme.PURECTXARROW ) then 
1500+  functionRest(t ::  Nil )
1501+  else 
1502+  if  (imods.is(Erased ) &&  ! t.isInstanceOf [FunctionWithMods ])
1503+  syntaxError(ErasedTypesCanOnlyBeFunctionTypes (), implicitKwPos(start))
1504+  t
1505+  end  typ 
14951506
14961507 private  def  makeKindProjectorTypeDef (name : TypeName ):  TypeDef  =  {
14971508 val  isVarianceAnnotated  =  name.startsWith(" +" ||  name.startsWith(" -" 
@@ -1549,7 +1560,7 @@ object Parsers {
15491560 def  infixTypeRest (t : Tree ):  Tree  = 
15501561 infixOps(t, canStartInfixTypeTokens, refinedTypeFn, Location .ElseWhere ,
15511562 isType =  true ,
1552-  isOperator =  ! followingIsVararg())
1563+  isOperator =  ! followingIsVararg()  &&   ! isIdent(nme. PUREARROW )  &&   ! isIdent(nme. PURECTXARROW ) )
15531564
15541565 /**  RefinedType ::= WithType {[nl] Refinement} 
15551566 */  
0 commit comments