mirror of
https://github.com/digital-asset/daml.git
synced 2024-09-20 01:07:18 +03:00
ifaces: preconditions, proto changes (#11448)
This adds a precondition expression to the protobuf and the encoders/decoders on the haskell side. CHANGELOG_BEGIN CHANGELOG_END
This commit is contained in:
parent
73718a22fa
commit
d3b9c84908
@ -930,6 +930,7 @@ data DefInterface = DefInterface
|
||||
, intVirtualChoices :: !(NM.NameMap InterfaceChoice)
|
||||
, intFixedChoices :: !(NM.NameMap TemplateChoice)
|
||||
, intMethods :: !(NM.NameMap InterfaceMethod)
|
||||
, intPrecondition :: !Expr
|
||||
}
|
||||
deriving (Eq, Data, Generic, NFData, Show)
|
||||
|
||||
|
@ -241,6 +241,7 @@ decodeDefInterface LF1.DefInterface {..} = do
|
||||
throwError $ ParseError $ unwords
|
||||
[ "Interface", T.unpack (T.intercalate "." (unTypeConName intName))
|
||||
, "has collision between fixed choice and virtual choice." ]
|
||||
intPrecondition <- mayDecode "defInterfacePrecond" defInterfacePrecond decodeExpr
|
||||
pure DefInterface {..}
|
||||
|
||||
decodeInterfaceChoice :: LF1.InterfaceChoice -> Decode InterfaceChoice
|
||||
|
@ -1002,6 +1002,7 @@ encodeDefInterface DefInterface{..} = do
|
||||
defInterfaceChoices <- encodeNameMap encodeInterfaceChoice intVirtualChoices
|
||||
defInterfaceFixedChoices <- encodeNameMap encodeTemplateChoice intFixedChoices
|
||||
defInterfaceMethods <- encodeNameMap encodeInterfaceMethod intMethods
|
||||
defInterfacePrecond <- encodeExpr intPrecondition
|
||||
pure $ P.DefInterface{..}
|
||||
|
||||
encodeInterfaceChoice :: InterfaceChoice -> Encode P.InterfaceChoice
|
||||
|
@ -444,6 +444,7 @@ convertInterfaces env tyThings = interfaceClasses
|
||||
intVirtualChoices <- NM.fromList <$> mapM convertVirtualChoice
|
||||
(MS.findWithDefault [] intName (envInterfaceChoiceData env))
|
||||
intFixedChoices <- convertChoices env intName emptyTemplateBinds
|
||||
let intPrecondition = EUnit -- TODO (drsk) #11397 Implement interface preconditions
|
||||
pure DefInterface {..}
|
||||
|
||||
convertVirtualChoice :: ChoiceData -> ConvertM InterfaceChoice
|
||||
|
@ -1532,6 +1532,7 @@ message DefInterface {
|
||||
// Binder for interface value ("this") in fixed choices.
|
||||
int32 param_interned_str = 5;
|
||||
repeated TemplateChoice fixed_choices = 6;
|
||||
Expr precond = 7;
|
||||
}
|
||||
|
||||
// Exception definition
|
||||
|
Loading…
Reference in New Issue
Block a user