typir
Version:
General purpose type checking library
51 lines • 2.03 kB
JavaScript
/******************************************************************************
* Copyright 2024 TypeFox GmbH
* This program and the accompanying materials are made available under the
* terms of the MIT License, which is available in the project root.
******************************************************************************/
import { isType, Type } from '../../graph/type-node.js';
import { TypeEqualityProblem } from '../../services/equality.js';
import { createKindConflict } from '../../utils/utils-type-comparison.js';
import { isBottomKind } from './bottom-kind.js';
export class BottomType extends Type {
constructor(kind, identifier, typeDetails) {
super(identifier, typeDetails);
this.kind = kind;
this.defineTheInitializationProcessOfThisType({}); // no preconditions
// ensure, that this Bottom type is a sub-type of all (other) types:
const graph = kind.services.infrastructure.Graph;
graph.addListener(this, { callOnAddedForAllExisting: true });
}
dispose() {
this.kind.services.infrastructure.Graph.removeListener(this);
}
onAddedType(type, _key) {
// this method is called for the already existing types and for all upcomping types
if (type !== this) {
this.kind.services.Subtype.markAsSubType(this, type, { checkForCycles: false });
}
}
getName() {
return this.getIdentifier();
}
getUserRepresentation() {
return this.getIdentifier();
}
analyzeTypeEqualityProblems(otherType) {
if (isBottomType(otherType)) {
return [];
}
else {
return [{
$problem: TypeEqualityProblem,
type1: this,
type2: otherType,
subProblems: [createKindConflict(this, otherType)],
}];
}
}
}
export function isBottomType(type) {
return isType(type) && isBottomKind(type.kind);
}
//# sourceMappingURL=bottom-type.js.map