@@ -9,7 +9,7 @@ package viper.silver.plugin.standard.adt
9
9
import viper .silver .ast ._
10
10
import viper .silver .ast .pretty .FastPrettyPrinter .{ContOps , braces , brackets , char , defaultIndent , line , nest , nil , parens , show , showType , showVars , space , ssep , text }
11
11
import viper .silver .ast .pretty .PrettyPrintPrimitives
12
- import viper .silver .ast .utility .Consistency
12
+ import viper .silver .ast .utility .{ Consistency , Expressions }
13
13
import viper .silver .verifier .{ConsistencyError , Failure , VerificationResult }
14
14
15
15
/**
@@ -206,6 +206,10 @@ case class AdtConstructorApp(name: String, args: Seq[Exp], typVarMap: Map[TypeVa
206
206
AdtConstructorApp (first, second, third)(this .pos, this .info, this .typ, this .adtName, this .errT).asInstanceOf [this .type ]
207
207
}
208
208
}
209
+
210
+ override def extensionIsValidTrigger (): Boolean = args.forall(a => ! a.exists(Expressions .isForbiddenInTrigger))
211
+
212
+ override def extensionIsForbiddenInTrigger (): Boolean = false
209
213
}
210
214
211
215
object AdtConstructorApp {
@@ -253,6 +257,10 @@ case class AdtDestructorApp(name: String, rcv: Exp, typVarMap: Map[TypeVar, Type
253
257
AdtDestructorApp (first, second, third)(this .pos, this .info, this .typ, this .adtName, this .errT).asInstanceOf [this .type ]
254
258
}
255
259
}
260
+
261
+ override def extensionIsValidTrigger (): Boolean = ! rcv.exists(Expressions .isForbiddenInTrigger)
262
+
263
+ override def extensionIsForbiddenInTrigger (): Boolean = false
256
264
}
257
265
258
266
object AdtDestructorApp {
@@ -306,6 +314,11 @@ case class AdtDiscriminatorApp(name: String, rcv: Exp, typVarMap: Map[TypeVar, T
306
314
}
307
315
}
308
316
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
309
322
}
310
323
311
324
object AdtDiscriminatorApp {
0 commit comments