use of org.wso2.ballerinalang.compiler.semantics.model.types.BStreamType in project ballerina by ballerina-lang.
the class SymbolResolver method visit.
public void visit(BLangConstrainedType constrainedTypeNode) {
BType type = resolveTypeNode(constrainedTypeNode.type, env);
BType constraintType = resolveTypeNode(constrainedTypeNode.constraint, env);
if (type.tag == TypeTags.TABLE) {
resultType = new BTableType(TypeTags.TABLE, constraintType, type.tsymbol);
} else if (type.tag == TypeTags.STREAM) {
resultType = new BStreamType(TypeTags.STREAM, constraintType, type.tsymbol);
} else if (type.tag == TypeTags.FUTURE) {
resultType = new BFutureType(TypeTags.FUTURE, constraintType, type.tsymbol);
} else if (type.tag == TypeTags.MAP) {
resultType = new BMapType(TypeTags.MAP, constraintType, type.tsymbol);
} else {
if (!types.checkStructToJSONCompatibility(constraintType) && constraintType != symTable.errType) {
dlog.error(constrainedTypeNode.pos, DiagnosticCode.INCOMPATIBLE_TYPE_CONSTRAINT, type, constraintType);
resultType = symTable.errType;
return;
}
resultType = new BJSONType(TypeTags.JSON, constraintType, type.tsymbol);
}
}
Aggregations