@@ -290,10 +290,6 @@ extends Importer:
290
290
291
291
def term (tree : Tree , inAppPrefix : Bool = false , inTyAppPrefix : Bool = false ): Ctxl [Term ] =
292
292
trace[Term ](s " Elab term ${tree.showDbg}" , r => s " ~> $r" ):
293
- def maybeApp (t : Term ): Ctxl [Term ] =
294
- if ! inAppPrefix && ! inTyAppPrefix // to ensure that nested App/TyApp are only wrapped once.
295
- then maybeFunctionApp(t)
296
- else t
297
293
tree.desugared match
298
294
case unt @ Unt () => unit.withLocOf(unt)
299
295
case Bra (k, e) =>
@@ -379,13 +375,13 @@ extends Importer:
379
375
msg " Unsupported handle binding shape " ->
380
376
h.toLoc :: Nil ))
381
377
Term .Error
382
- case id @ Ident (" this" ) => maybeApp :
378
+ case id @ Ident (" this" ) =>
383
379
ctx.getOuter match
384
380
case S (sym) => sym.ref(id)
385
381
case N =>
386
382
raise(ErrorReport (msg " Cannot use 'this' outside of an object scope. " -> tree.toLoc :: Nil ))
387
383
Term .Error
388
- case id @ Ident (name) => maybeApp :
384
+ case id @ Ident (name) =>
389
385
ctx.get(name) match
390
386
case S (elem) => elem.ref(id)
391
387
case N =>
@@ -394,7 +390,7 @@ extends Importer:
394
390
case N =>
395
391
raise(ErrorReport (msg " Name not found: $name" -> tree.toLoc :: Nil ))
396
392
Term .Error
397
- case TyApp (lhs, targs) => maybeApp :
393
+ case TyApp (lhs, targs) =>
398
394
Term .TyApp (term(lhs, inTyAppPrefix = true ), targs.map {
399
395
case Modified (Keyword .`in`, inLoc, arg) => Term .WildcardTy (S (term(arg)), N )
400
396
case Modified (Keyword .`out`, outLoc, arg) => Term .WildcardTy (N , S (term(arg)))
@@ -507,13 +503,11 @@ extends Importer:
507
503
val sym = FlowSymbol (" ‹app-res›" )
508
504
val lt = term(lhs, inAppPrefix = true )
509
505
val rt = term(rhs)
510
- maybeApp :
511
- Term .App (lt, rt)(tree, sym)
506
+ Term .App (lt, rt)(tree, sym)
512
507
case SynthSel (pre, nme) =>
513
508
val preTrm = term(pre)
514
509
val sym = resolveField(nme, preTrm.symbol, nme)
515
- maybeApp :
516
- Term .SynthSel (preTrm, nme)(sym)
510
+ Term .SynthSel (preTrm, nme)(sym)
517
511
case Sel (pre, nme) =>
518
512
val preTrm = term(pre)
519
513
val sym = resolveField(nme, preTrm.symbol, nme)
@@ -535,8 +529,7 @@ extends Importer:
535
529
val loc = tree.toLoc.getOrElse(??? )
536
530
Term .Lit (Tree .StrLit (loc.origin.fileName.toString))
537
531
else
538
- maybeApp :
539
- Term .Sel (preTrm, nme)(sym)
532
+ Term .Sel (preTrm, nme)(sym)
540
533
case MemberProj (ct, nme) =>
541
534
val c = cls(ct, inAppPrefix = false )
542
535
val f = c.symbol.flatMap(_.asCls) match
@@ -711,69 +704,6 @@ extends Importer:
711
704
// case _ =>
712
705
// ???
713
706
714
- /**
715
- * Function (as opposed to method) applications
716
- * that may require further elaboration with type information.
717
- */
718
- def maybeFunctionApp (t : Term ): Ctxl [Term ] =
719
- // * Some function definitions might not be fully elaborated yet.
720
- // * We need to do some very lightweight tree parsing here.
721
- case class Param (ctx : Bool )(tree : Tree )
722
- case class ParamList (ps : Ls [Param ], ctx : Bool )(tree : Tree )
723
- def param (tree : Tree ): Param = tree match
724
- case Tree .Modified (Keyword .`using`, _, tree) => Param (true )(tree)
725
- case _ => Param (false )(tree)
726
- def paramList (tree : Tree .Tup ): ParamList =
727
- val ps = tree.fields.map(param)
728
- ParamList (ps, ps.exists(_.ctx))(tree)
729
-
730
- /**
731
- * Zips a `fun` application term along with its parameter lists,
732
- * inserting any missing contextual argument lists.
733
- *
734
- * M.foo -> M.foo(<using> ...)
735
- * M.foo(a, b) -> M.foo(<using> ...)(a, b)(<using> ...)
736
- *
737
- * Note: This *doesn't* handle explicit contextual arguments.
738
- */
739
- def zip (t : Term , paramLists : Ls [ParamList ]): Term = (t, paramLists) match
740
- case (t, ps :: pss) if ps.ctx =>
741
- val appTree = new Tree .App (Tree .Empty (), Tree .Empty ())
742
- val tupTree = new Tree .Tup (Nil )
743
- val args = Term .Tup (ps.ps.map(_ => CtxArgImpl ()))(tupTree)
744
- Term .App (zip(t, pss), args)(appTree, FlowSymbol (" ‹app-res›" ))
745
- case (t @ Term .App (lhs, rhs), ps :: pss) =>
746
- Term .App (zip(lhs, pss), rhs)(t.tree, t.resSym)
747
- case (t, params :: pRest) =>
748
- // LHS is not a app but it still expects more param lists - a partial application.
749
- // Just suppose it is legal and don't fail here.
750
- // TODO: Check in the implicit resolver.
751
- t
752
- case (_, Nil ) => t
753
-
754
- /**
755
- * An extractor that extracts the (tree) definition of a `fun`.
756
- */
757
- object FunctionTreeDef :
758
- def unapply (t : Term ): Opt [Tree .TermDef ] = t.symbol match
759
- case S (sym : BlockMemberSymbol ) => sym.trmTree match
760
- case S (tree @ Tree .TermDef (k = Fun )) => S (tree)
761
- case _ => N
762
- case _ => N
763
-
764
- t match
765
- // f[T](foo)(bar)
766
- case semantics.Apps (Term .TyApp (FunctionTreeDef (tree), _), argss) =>
767
- trace[Term ](s " Elab `fun` application ${t.showDbg}" , r => s " ~> $r" ):
768
- zip(t, tree.paramLists.map(paramList).reverse)
769
- // f(foo)(bar)
770
- case semantics.Apps (FunctionTreeDef (tree), argss) =>
771
- trace[Term ](s " Elab `fun` application ${t.showDbg}" , r => s " ~> $r" ):
772
- zip(t, tree.paramLists.map(paramList).reverse)
773
- // The definition does not exist.
774
- case _ =>
775
- t
776
-
777
707
def fld (tree : Tree ): Ctxl [Elem ] = tree match
778
708
case InfixApp (id : Ident , Keyword .`:`, rhs) =>
779
709
Fld (FldFlags .empty, Term .Lit (StrLit (id.name).withLocOf(id)), S (term(rhs)))
0 commit comments