@@ -9,7 +9,7 @@ package viper.silver.plugin.standard.adt
99import viper .silver .ast ._
1010import viper .silver .ast .pretty .FastPrettyPrinter .{ContOps , braces , brackets , char , defaultIndent , line , nest , nil , parens , show , showType , showVars , space , ssep , text }
1111import viper .silver .ast .pretty .PrettyPrintPrimitives
12- import viper .silver .ast .utility .Consistency
12+ import viper .silver .ast .utility .{ Consistency , Expressions }
1313import viper .silver .verifier .{ConsistencyError , Failure , VerificationResult }
1414
1515/**
@@ -206,6 +206,10 @@ case class AdtConstructorApp(name: String, args: Seq[Exp], typVarMap: Map[TypeVa
206206 AdtConstructorApp (first, second, third)(this .pos, this .info, this .typ, this .adtName, this .errT).asInstanceOf [this .type ]
207207 }
208208 }
209+
210+ override def extensionIsValidTrigger (): Boolean = args.forall(a => ! a.exists(Expressions .isForbiddenInTrigger))
211+
212+ override def extensionIsForbiddenInTrigger (): Boolean = false
209213}
210214
211215object AdtConstructorApp {
@@ -253,6 +257,10 @@ case class AdtDestructorApp(name: String, rcv: Exp, typVarMap: Map[TypeVar, Type
253257 AdtDestructorApp (first, second, third)(this .pos, this .info, this .typ, this .adtName, this .errT).asInstanceOf [this .type ]
254258 }
255259 }
260+
261+ override def extensionIsValidTrigger (): Boolean = ! rcv.exists(Expressions .isForbiddenInTrigger)
262+
263+ override def extensionIsForbiddenInTrigger (): Boolean = false
256264}
257265
258266object AdtDestructorApp {
@@ -306,6 +314,11 @@ case class AdtDiscriminatorApp(name: String, rcv: Exp, typVarMap: Map[TypeVar, T
306314 }
307315 }
308316
317+ // Since a discriminator desugars to ADT_tag(rcv) == name_tag, which contains an equality,
318+ // it cannot be used anywhere inside a trigger.
319+ override def extensionIsValidTrigger (): Boolean = false
320+
321+ override def extensionIsForbiddenInTrigger (): Boolean = true
309322}
310323
311324object AdtDiscriminatorApp {
0 commit comments