File tree Expand file tree Collapse file tree
main/scala/viper/silver/parser Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ package viper.silver.parser
99import viper .silver .FastMessaging
1010import viper .silver .ast .utility ._
1111import viper .silver .ast .{SourcePosition , _ }
12+ import viper .silver .plugin .standard .adt .{Adt , AdtType }
1213
1314import scala .language .implicitConversions
1415
@@ -582,12 +583,16 @@ case class Translator(program: PProgram) {
582583 MapType (ttyp(keyType), ttyp(valueType))
583584 case PDomainType (name, args) =>
584585 members.get(name.name) match {
585- case Some (d) =>
586- val domain = d.asInstanceOf [Domain ]
586+ case Some (domain : Domain ) =>
587587 val typVarMapping = domain.typVars zip (args map ttyp)
588588 DomainType (domain, typVarMapping /* .filter {
589589 case (tv, tt) => tv!=tt //!tt.isInstanceOf[TypeVar]
590590 }*/ .toMap)
591+ case Some (adt : Adt ) =>
592+ val typVarMapping = adt.typVars zip (args map ttyp)
593+ AdtType (adt, typVarMapping.toMap)
594+ case Some (other) =>
595+ sys.error(s " Did not expect member ${other}" )
591596 case None =>
592597 assert(args.isEmpty)
593598 TypeVar (name.name) // not a domain, i.e. it must be a type variable
Original file line number Diff line number Diff line change 1+ adt Wrap {
2+ WrappedInt(
3+ data: Int
4+ )
5+ }
6+
7+ function wrap(
8+ data: Int
9+ ): Wrap
10+ ensures result.data == data
11+
12+ function wrapNot(
13+ data: Int
14+ ): Wrap
15+ ensures result.data != data
16+
17+ method wrapTest() {
18+ var x: Wrap := wrap(1)
19+ assert(x.data == 1)
20+ var y: Wrap := wrapNot(1)
21+ //:: ExpectedOutput(assert.failed:assertion.false)
22+ assert(y.data == 1)
23+ }
You can’t perform that action at this time.
0 commit comments