defineType method

void defineType(
  1. Type type
)

Defines a name in the environment with the passed value.

Implementation

void defineType(Type type) {
  final name = buildTypeName(type);

  if (type is TopType) {
    throw "Can't redefine the top type.";
  }

  if (type is BottomType) {
    throw "Can't redefine the bottom type.";
  }

  final existingType = getType(name);

  if (type case MonomorphicType(:final source) || PolymorphicType(:final source)) {
    if (existingType case MonomorphicType(source: final existingTypeSource) || PolymorphicType(source: final existingTypeSource)) {
      if (source != existingTypeSource) {
        // Type is being shadowed
      }
    }
  }

  _definedTypes[name] = type;
}