From 02f39df7d8add54b5c01d453c34483a01b26cc44 Mon Sep 17 00:00:00 2001 From: Evan Ovadia Date: Sat, 2 Sep 2023 18:40:53 -0400 Subject: [PATCH] Added AttemptedCandidate for regions compatibility --- Frontend/.idea/scala_settings.xml | 25 +++++++++++++++ .../dev/vale/typing/OverloadResolver.scala | 31 +++++++++++-------- 2 files changed, 43 insertions(+), 13 deletions(-) create mode 100644 Frontend/.idea/scala_settings.xml diff --git a/Frontend/.idea/scala_settings.xml b/Frontend/.idea/scala_settings.xml new file mode 100644 index 000000000..c6de73e96 --- /dev/null +++ b/Frontend/.idea/scala_settings.xml @@ -0,0 +1,25 @@ + + + + + + \ No newline at end of file diff --git a/Frontend/TypingPass/src/dev/vale/typing/OverloadResolver.scala b/Frontend/TypingPass/src/dev/vale/typing/OverloadResolver.scala index 1b0a07d1d..cc162fcbc 100644 --- a/Frontend/TypingPass/src/dev/vale/typing/OverloadResolver.scala +++ b/Frontend/TypingPass/src/dev/vale/typing/OverloadResolver.scala @@ -119,7 +119,7 @@ class OverloadResolver( exact) match { case Err(e) => return Err(e) case Ok(potentialBanner) => { - Ok(StampFunctionSuccess(potentialBanner, Map())) + Ok(StampFunctionSuccess(potentialBanner.prototype, Map())) // Ok( // stampPotentialFunctionForPrototype( // coutputs, callingEnv, callRange, callLocation, potentialBanner, contextRegion, args)) @@ -221,6 +221,11 @@ class OverloadResolver( }) } + case class AttemptedCandidate( + // Pure and region will go here + prototype: PrototypeT[IFunctionNameT] + ) + private def attemptCandidateBanner( callingEnv: IInDenizenEnvironmentT, coutputs: CompilerOutputs, @@ -232,7 +237,7 @@ class OverloadResolver( args: Vector[CoordT], candidate: ICalleeCandidate, exact: Boolean): - Result[PrototypeT[IFunctionNameT], IFindFunctionFailureReason] = { + Result[AttemptedCandidate, IFindFunctionFailureReason] = { candidate match { case FunctionCalleeCandidate(ft@FunctionTemplataT(declaringEnv, function)) => { // See OFCBT. @@ -350,7 +355,7 @@ class OverloadResolver( case Err(rejectionReason) => Err(rejectionReason) case Ok(()) => { vassert(coutputs.getInstantiationBounds(prototype.prototype.id).nonEmpty) - Ok(prototype.prototype) + Ok(AttemptedCandidate(prototype.prototype)) } } } @@ -365,7 +370,7 @@ class OverloadResolver( case Err(rejectionReason) => Err(rejectionReason) case Ok(()) => { vassert(coutputs.getInstantiationBounds(prototype.prototype.id).nonEmpty) - Ok(prototype.prototype) + Ok(AttemptedCandidate(prototype.prototype)) } } } @@ -380,7 +385,7 @@ class OverloadResolver( case HeaderCalleeCandidate(header) => { paramsMatch(coutputs, callingEnv, callRange, callLocation, args, header.paramTypes, exact) match { case Ok(_) => { - Ok(header.toPrototype) + Ok(AttemptedCandidate(header.toPrototype)) } case Err(fff) => Err(fff) } @@ -412,7 +417,7 @@ class OverloadResolver( val bounds = Map[IRuneS, PrototypeTemplataT[IFunctionNameT]]() vassert(coutputs.getInstantiationBounds(prototype.id).nonEmpty) - Ok(prototype) + Ok(AttemptedCandidate(prototype)) } case Err(fff) => Err(fff) } @@ -452,7 +457,7 @@ class OverloadResolver( args: Vector[CoordT], extraEnvsToLookIn: Vector[IInDenizenEnvironmentT], exact: Boolean): - Result[PrototypeT[IFunctionNameT], FindFunctionFailure] = { + Result[AttemptedCandidate, FindFunctionFailure] = { // This is here for debugging, so when we dont find something we can see what envs we searched val searchedEnvs = new Accumulator[SearchedEnvironment]() val undedupedCandidates = new Accumulator[ICalleeCandidate]() @@ -519,12 +524,12 @@ class OverloadResolver( callingEnv: IInDenizenEnvironmentT, callRange: List[RangeS], callLocation: LocationInDenizen, - unfilteredBanners: Iterable[PrototypeT[IFunctionNameT]], + unfilteredBanners: Iterable[AttemptedCandidate], argTypes: Vector[CoordT]): ( - PrototypeT[IFunctionNameT], + AttemptedCandidate, // Rejection reason by banner - Map[PrototypeT[IFunctionNameT], IFindFunctionFailureReason]) = { + Map[AttemptedCandidate, IFindFunctionFailureReason]) = { // Sometimes a banner might come from many different environments (remember, // when we do a call, we look in the environments of all the arguments' types). @@ -544,7 +549,7 @@ class OverloadResolver( // If there are multiple overloads with the same exact parameter list, // then get rid of the templated ones; ordinary ones get priority. val banners = - dedupedBanners.groupBy(_.paramTypes).values.flatMap({ potentialBannersWithSameParamTypes => + dedupedBanners.groupBy(_.prototype.paramTypes).values.flatMap({ potentialBannersWithSameParamTypes => val ordinaryBanners = potentialBannersWithSameParamTypes if (ordinaryBanners.isEmpty) { @@ -558,7 +563,7 @@ class OverloadResolver( val bannerIndexToScore = banners.map(banner => { - vassertSome(getBannerParamScores(coutputs, callingEnv, callRange, callLocation, banner, argTypes)) + vassertSome(getBannerParamScores(coutputs, callingEnv, callRange, callLocation, banner.prototype, argTypes)) }) // For any given parameter: @@ -596,7 +601,7 @@ class OverloadResolver( .map(i => i -> banners(i)) .foldLeft((List[(Int, PrototypeT[IFunctionNameT])](), List[(Int, PrototypeT[FunctionBoundNameT])]()))({ case ((normalCandidates, boundCandidates), (index, thisCandidate)) => { - thisCandidate match { + thisCandidate.prototype match { case PrototypeT(IdT(packageCoord, initSteps, FunctionBoundNameT(tn, firstTemplateArgs, firstParameters)), firstReturnType) => { val thisBoundCandidate = PrototypeT(IdT(packageCoord, initSteps, FunctionBoundNameT(tn, firstTemplateArgs, firstParameters)), firstReturnType) (normalCandidates, (index -> thisBoundCandidate) :: boundCandidates)