Source:
private List<DeclType> getDeclTypes(TypeContext ctx) { if (declTypes == null) { declTypes = new LinkedList<DeclType>(); base.checkWellFormed(ctx); StructuralType st = base.getStructuralType(ctx, null); if (st == null) { base.checkWellFormed(ctx); ToolError.reportError(ErrorMessage.CANNOT_APPLY_GENERIC_ARGUMENTS, getLocation(), base.toString()); } final List<DeclType> stDeclTypes = st.getDeclTypes(); final Iterator<GenericArgument> genericArgumentIterator = genericArguments.iterator(); for (DeclType dt : stDeclTypes) { if (!genericArgumentIterator.hasNext()) { break; } final GenericArgument ga = genericArgumentIterator.next(); final DeclType declTypeToAdd; if (dt instanceof AbstractTypeMember) { if (ga.getKind() != GenericKind.TYPE) { ToolError.reportError(ErrorMessage.NON_TYPE_ARGUMENT, getLocation(), ga.getKind().toString()); } declTypeToAdd = new ConcreteTypeMember(dt.getName(), ga.getType()); } else if (dt instanceof EffectDeclType) { if (ga.getKind() != GenericKind.EFFECT) { ToolError.reportError(ErrorMessage.NON_EFFECT_ARGUMENT, getLocation(), ga.getKind().toString()); } declTypeToAdd = new EffectDeclType(dt.getName(), ga.getEffect(), dt.getLocation()); } else { continue; } declTypes.add(declTypeToAdd); } if (genericArgumentIterator.hasNext()) { final GenericArgument ga = genericArgumentIterator.next(); switch (ga.getKind()) { case TYPE: ToolError.reportError(ErrorMessage.NO_TYPE_MEMBER, getLocation(), ga.getType().toString()); break; case EFFECT: ToolError.reportError(ErrorMessage.NO_EFFECT_MEMBER, getLocation(), ga.getEffect().toString()); break; default: throw new RuntimeException("Unhandled corewyvernIL generic argument kind: " + ga.getKind()); } } } return declTypes; }

Target:
private List<DeclType> getDeclTypes(TypeContext ctx) { if (declTypes == null) { declTypes = new LinkedList<DeclType>(); base.checkWellFormed(ctx); StructuralType st = base.getStructuralType(ctx, null); if (st == null) { ToolError.reportError(ErrorMessage.CANNOT_APPLY_GENERIC_ARGUMENTS, getLocation(), base.toString()); } final List<DeclType> stDeclTypes = st.getDeclTypes(); final Iterator<GenericArgument> genericArgumentIterator = genericArguments == null ? Collections.emptyIterator() : genericArguments.iterator(); for (DeclType dt : stDeclTypes) { if (!genericArgumentIterator.hasNext()) { break; } final GenericArgument ga = genericArgumentIterator.next(); final DeclType declTypeToAdd; if (dt instanceof AbstractTypeMember) { if (ga.getKind() != GenericKind.TYPE) { ToolError.reportError(ErrorMessage.NON_TYPE_ARGUMENT, getLocation(), ga.getKind().toString()); } declTypeToAdd = new ConcreteTypeMember(dt.getName(), ga.getType()); } else if (dt instanceof EffectDeclType) { if (ga.getKind() != GenericKind.EFFECT) { ToolError.reportError(ErrorMessage.NON_EFFECT_ARGUMENT, getLocation(), ga.getKind().toString()); } declTypeToAdd = new EffectDeclType(dt.getName(), ga.getEffect(), dt.getLocation()); } else { continue; } declTypes.add(declTypeToAdd); } if (genericArgumentIterator.hasNext()) { final GenericArgument ga = genericArgumentIterator.next(); switch (ga.getKind()) { case TYPE: ToolError.reportError(ErrorMessage.NO_TYPE_MEMBER, getLocation(), ga.getType().toString()); break; case EFFECT: ToolError.reportError(ErrorMessage.NO_EFFECT_MEMBER, getLocation(), ga.getEffect().toString()); break; default: throw new RuntimeException("Unhandled corewyvernIL generic argument kind: " + ga.getKind()); } } } return declTypes; }