Buggy code:
public Nominal resolveAsType ( UnresolvedType t , List < WhileyFile . Import > imports ) throws ResolveError { } private Type resolveAsType ( UnresolvedType t , List < WhileyFile . Import > imports , boolean nominal ) throws ResolveError { } private int resolveAsType ( UnresolvedType t , List < WhileyFile . Import > imports , ArrayList < Automaton . State > states , HashMap < NameID , Integer > roots , boolean nominal ) throws ResolveError { } private int resolveAsType ( NameID key , List < WhileyFile . Import > imports , ArrayList < Automaton . State > states , HashMap < NameID , Integer > roots ) throws ResolveError { } private int resolveAsType ( UnresolvedType . Primitive t , List < WhileyFile . Import > imports , ArrayList < Automaton . State > states ) throws ResolveError { } private static int append ( Type type , ArrayList < Automaton . State > states ) { } public Value resolveAsConstant ( NameID nid ) throws ResolveError { } public Value resolveAsConstant ( Expr e , String filename , List < WhileyFile . Import > imports ) throws ResolveError { } private Value resolveAsConstant ( NameID key , HashSet < NameID > visited ) throws ResolveError { } private Value resolveAsConstant ( Expr expr , String filename , List < WhileyFile . Import > imports , HashSet < NameID > visited ) throws ResolveError { } private Value evaluate ( Expr . BinOp bop , Value v1 , Value v2 , String filename ) { } private Value evaluateBoolean ( Expr . BinOp bop , Value . Bool v1 , Value . Bool v2 , String filename ) { } private Value evaluate ( Expr . BinOp bop , Value . Rational v1 , Value . Rational v2 , String filename ) { } private Value evaluate ( Expr . BinOp bop , Value . List v1 , Value . List v2 , String filename ) { } private Value evaluate ( Expr . BinOp bop , Value . Set v1 , Value . Set v2 , String filename ) { } public Pair < NameID , Nominal . FunctionOrMethod > resolveAsFunctionOrMethod ( String name , List < WhileyFile . Import > imports ) throws ResolveError { } public Pair < NameID , Nominal . FunctionOrMethodOrMessage > resolveAsFunctionOrMethodOrMessage ( String name , List < WhileyFile . Import > imports ) throws ResolveError { } public Pair < NameID , Nominal . FunctionOrMethod > resolveAsFunctionOrMethod ( String name , List < Nominal > parameters , List < WhileyFile . Import > imports ) throws ResolveError { } public FunctionOrMethod resolveAsFunctionOrMethod ( NameID nid , List < Nominal > parameters ) throws ResolveError { } public Pair < NameID , Nominal . Message > resolveAsMessage ( String name , Type . Reference receiver , List < Nominal > parameters , List < WhileyFile . Import > imports ) throws ResolveError { } public Message resolveAsMessage ( NameID nid , Type . Reference receiver , List < Nominal > parameters ) throws ResolveError { } private boolean paramSubtypes ( Type . FunctionOrMethodOrMessage f1 , Type . FunctionOrMethodOrMessage f2 ) { } private String parameterString ( List < Nominal > paramTypes ) { } private Pair < NameID , Nominal . FunctionOrMethod > selectCandidateFunctionOrMethod ( String name , List < Nominal > parameters , ArrayList < Pair < NameID , Nominal . FunctionOrMethod > > candidates ) throws ResolveError { } private Pair < NameID , Nominal . Message > selectCandidateMessage ( String name , Type . Reference receiver , List < Nominal > parameters , ArrayList < Pair < NameID , Nominal . Message > > candidates ) throws ResolveError { } private void addCandidateFunctionsAndMethods ( NameID nid , List < ? > parameters , ArrayList < Pair < NameID , Nominal . FunctionOrMethod > > candidates ) throws ResolveError { ModuleID mid = nid . module ( ) ; int nparams = ( parameters != null ) ? parameters . size ( ) : - 1 ; WhileyFile wf = files . get ( mid ) ; if ( wf != null ) { for ( WhileyFile . FunctionOrMethod f : wf . declarations ( WhileyFile . FunctionOrMethod . class , nid . name ( ) ) ) { if ( ( nparams == ( - 1 ) ) || ( ( f . parameters . size ( ) ) == nparams ) ) { <START_BUG> Nominal . Function ft = ( ( Nominal . Function ) ( resolveAsType ( f . unresolvedType ( ) , buildImports ( wf , f ) ) ) ) ; <END_BUG> candidates . add ( new Pair ( nid , ft ) ) ; } } } else { try { Module m = loader . loadModule ( mid ) ; for ( Module . Method mm : m . methods ( ) ) { if ( ( ( ( mm . isFunction ( ) ) || ( mm . isMethod ( ) ) ) && ( mm . name ( ) . equals ( nid . name ( ) ) ) ) && ( ( nparams == ( - 1 ) ) || ( ( mm . type ( ) . params ( ) . size ( ) ) == nparams ) ) ) { Type . FunctionOrMethod t = ( ( Type . FunctionOrMethod ) ( mm . type ( ) ) ) ; Nominal . FunctionOrMethod fom ; if ( t instanceof Type . Function ) { Type . Function ft = ( ( Type . Function ) ( t ) ) ; fom = new Nominal . Function ( ft , ft ) ; } else { Type . Method mt = ( ( Type . Method ) ( t ) ) ; fom = new Nominal . Method ( mt , mt ) ; } candidates . add ( new Pair ( nid , fom ) ) ;

Fix:
Nominal . FunctionOrMethod ft = ( ( Nominal . FunctionOrMethod ) ( resolveAsType ( f . unresolvedType ( ) , buildImports ( wf , f ) ) ) ) ;