Code review comment: We can revisit this separately. 

Code before review:
public void visit(BLangTypeDefinition astTypeDefinition) {
BType type = getDefinedType(astTypeDefinition);
Name displayName = astTypeDefinition.symbol.name;
if (type.tag == TypeTags.RECORD) {
BRecordType recordType = (BRecordType) type;
if (recordType.shouldPrintShape()) {
displayName = new Name(recordType.toString());
}
}
BIRTypeDefinition typeDef = new BIRTypeDefinition(astTypeDefinition.pos,
astTypeDefinition.symbol.name,
astTypeDefinition.symbol.flags,
astTypeDefinition.isBuiltinTypeDef,
type,
new ArrayList<>(),
astTypeDefinition.symbol.origin.toBIROrigin(),
displayName,
astTypeDefinition.symbol.originalName);
if (astTypeDefinition.symbol.tag == SymTag.TYPE_DEF) {
BTypeReferenceType referenceType = ((BTypeDefinitionSymbol) astTypeDefinition.symbol).referenceType;
typeDef.referenceType = referenceType;
BTypeSymbol typeSymbol = astTypeDefinition.symbol.type.tsymbol;
if (type.tsymbol.owner == astTypeDefinition.symbol.owner
&& !(Symbols.isFlagOn(typeSymbol.flags, Flags.CLASS))) {
typeDefs.put(typeSymbol, typeDef);
} else {
if (referenceType != null) {
typeDef.type = referenceType;
}
}
} else {
typeDefs.put(astTypeDefinition.symbol, typeDef);
}
this.env.enclPkg.typeDefs.add(typeDef);
typeDef.index = this.env.enclPkg.typeDefs.size() - 1;
typeDef.setMarkdownDocAttachment(astTypeDefinition.symbol.markdownDocumentation);
populateBIRAnnotAttachments(astTypeDefinition.annAttachments, typeDef.annotAttachments, this.env);
if (astTypeDefinition.typeNode.getKind() == NodeKind.RECORD_TYPE ||
astTypeDefinition.typeNode.getKind() == NodeKind.OBJECT_TYPE) {
BLangStructureTypeNode typeNode = (BLangStructureTypeNode) astTypeDefinition.typeNode;
for (BLangType typeRef : typeNode.typeRefs) {
typeDef.referencedTypes.add(typeRef.getBType());
}
}
BSymbol typeSymbol = astTypeDefinition.symbol.tag == SymTag.TYPE_DEF
? astTypeDefinition.symbol.type.tsymbol : astTypeDefinition.symbol;
if (typeSymbol.tag != SymTag.OBJECT || !Symbols.isFlagOn(typeSymbol.flags, Flags.CLASS)) {
return;
}
for (BAttachedFunction func : ((BObjectTypeSymbol) typeSymbol).referencedFunctions) {
if (!Symbols.isFlagOn(func.symbol.flags, Flags.INTERFACE)) {
return;
}
BInvokableSymbol funcSymbol = func.symbol;
BIRFunction birFunc = new BIRFunction(astTypeDefinition.pos, func.funcName, funcSymbol.flags, func.type,
names.fromString(DEFAULT_WORKER_NAME), 0,
funcSymbol.origin.toBIROrigin());
if (funcSymbol.receiverSymbol != null) {
birFunc.receiver = getSelf(funcSymbol.receiverSymbol
);
}
birFunc.setMarkdownDocAttachment(funcSymbol.markdownDocumentation);
int defaultableParamsCount = 0;
birFunc.argsCount = funcSymbol.params.size() + defaultableParamsCount +
(funcSymbol.restParam != null ? 1 : 0);
funcSymbol.params.forEach(requiredParam -> addParam(birFunc, requiredParam, astTypeDefinition.pos));
if (funcSymbol.restParam != null) {
addRestParam(birFunc, funcSymbol.restParam, astTypeDefinition.pos);
}
birFunc.returnVariable = new BIRVariableDcl(astTypeDefinition.pos, funcSymbol.retType,
this.env.nextLocalVarId(names), VarScope.FUNCTION, VarKind.RETURN, null);
birFunc.localVars.add(0, birFunc.returnVariable);
typeDef.attachedFuncs.add(birFunc);
}
}

Line under review: && !(Symbols.isFlagOn(typeSymbol.flags, Flags.CLASS))) {

Code after addressing the review:
public void visit(BLangTypeDefinition astTypeDefinition) {
BType type = getDefinedType(astTypeDefinition);
Name displayName = astTypeDefinition.symbol.name;
if (type.tag == TypeTags.RECORD) {
BRecordType recordType = (BRecordType) type;
if (recordType.shouldPrintShape()) {
displayName = new Name(recordType.toString());
}
}
BIRTypeDefinition typeDef = new BIRTypeDefinition(astTypeDefinition.pos,
astTypeDefinition.symbol.name,
astTypeDefinition.symbol.flags,
astTypeDefinition.isBuiltinTypeDef,
type,
new ArrayList<>(),
astTypeDefinition.symbol.origin.toBIROrigin(),
displayName,
astTypeDefinition.symbol.originalName);
if (astTypeDefinition.symbol.tag == SymTag.TYPE_DEF) {
BTypeReferenceType referenceType = ((BTypeDefinitionSymbol) astTypeDefinition.symbol).referenceType;
typeDef.referenceType = referenceType;
BTypeSymbol typeSymbol = astTypeDefinition.symbol.type.tsymbol;
if (type.tsymbol.owner == astTypeDefinition.symbol.owner
&& !(Symbols.isFlagOn(typeSymbol.flags, Flags.CLASS))) {
typeDefs.put(typeSymbol, typeDef);
} else {
if (referenceType != null) {
typeDef.type = referenceType;
}
}
} else {
typeDefs.put(astTypeDefinition.symbol, typeDef);
}
this.env.enclPkg.typeDefs.add(typeDef);
typeDef.index = this.env.enclPkg.typeDefs.size() - 1;
typeDef.setMarkdownDocAttachment(astTypeDefinition.symbol.markdownDocumentation);
populateBIRAnnotAttachments(astTypeDefinition.annAttachments, typeDef.annotAttachments, this.env);
if (astTypeDefinition.typeNode.getKind() == NodeKind.RECORD_TYPE ||
astTypeDefinition.typeNode.getKind() == NodeKind.OBJECT_TYPE) {
BLangStructureTypeNode typeNode = (BLangStructureTypeNode) astTypeDefinition.typeNode;
for (BLangType typeRef : typeNode.typeRefs) {
typeDef.referencedTypes.add(typeRef.getBType());
}
}
BSymbol typeSymbol = astTypeDefinition.symbol.tag == SymTag.TYPE_DEF
? astTypeDefinition.symbol.type.tsymbol : astTypeDefinition.symbol;
if (typeSymbol.tag != SymTag.OBJECT || !Symbols.isFlagOn(typeSymbol.flags, Flags.CLASS)) {
return;
}
for (BAttachedFunction func : ((BObjectTypeSymbol) typeSymbol).referencedFunctions) {
if (!Symbols.isFlagOn(func.symbol.flags, Flags.INTERFACE)) {
return;
}
BInvokableSymbol funcSymbol = func.symbol;
BIRFunction birFunc = new BIRFunction(astTypeDefinition.pos, func.funcName, funcSymbol.flags, func.type,
names.fromString(DEFAULT_WORKER_NAME), 0,
funcSymbol.origin.toBIROrigin());
if (funcSymbol.receiverSymbol != null) {
birFunc.receiver = getSelf(funcSymbol.receiverSymbol
);
}
birFunc.setMarkdownDocAttachment(funcSymbol.markdownDocumentation);
int defaultableParamsCount = 0;
birFunc.argsCount = funcSymbol.params.size() + defaultableParamsCount +
(funcSymbol.restParam != null ? 1 : 0);
funcSymbol.params.forEach(requiredParam -> addParam(birFunc, requiredParam, astTypeDefinition.pos));
if (funcSymbol.restParam != null) {
addRestParam(birFunc, funcSymbol.restParam, astTypeDefinition.pos);
}
birFunc.returnVariable = new BIRVariableDcl(astTypeDefinition.pos, funcSymbol.retType,
this.env.nextLocalVarId(names), VarScope.FUNCTION, VarKind.RETURN, null);
birFunc.localVars.add(0, birFunc.returnVariable);
typeDef.attachedFuncs.add(birFunc);
}
}