@@ -9,7 +9,7 @@ package viper.gobra.frontend.info.implementation.typing.ghost
9
9
import org .bitbucket .inkytonik .kiama .util .Messaging .noMessages
10
10
import viper .gobra .ast .frontend .{PExpression , PFieldDecl , PIdnNode , PMatchAdt }
11
11
import viper .gobra .frontend .info .base .SymbolTable .{AdtClause , AdtDestructor , AdtDiscriminator , BoundVariable , BuiltInFPredicate , BuiltInMPredicate , DomainFunction , GhostRegular , MatchVariable , Predicate }
12
- import viper .gobra .frontend .info .base .Type .{AdtClauseT , AssertionT , FunctionT , Type }
12
+ import viper .gobra .frontend .info .base .Type .{AdtClauseT , AssertionT , FunctionT , Type , UnknownType }
13
13
import viper .gobra .frontend .info .implementation .TypeInfoImpl
14
14
import viper .gobra .util .Violation .violation
15
15
@@ -46,8 +46,13 @@ trait GhostIdTyping { this: TypeInfoImpl =>
46
46
47
47
case MatchVariable (decl, p, context) => p match {
48
48
case PMatchAdt (clause, fields) =>
49
- val clauseT = context.symbType(clause).asInstanceOf [AdtClauseT ]
50
- clauseT.typeAt(fields.indexOf(decl))
49
+ val clauseT = context.symbType(clause)
50
+ clauseT match {
51
+ case clauseT : AdtClauseT => clauseT.typeAt(fields.indexOf(decl))
52
+ // the following case is possible, e.g., if the clause is not well-defined
53
+ // and, thus, `clauseT` is `UnknownType`:
54
+ case _ => UnknownType
55
+ }
51
56
52
57
case e : PExpression => context.typ(e)
53
58
case _ => violation(" untypeable" )
0 commit comments