compiler: Check nominal and match classification

7a69753cc1b226af87845d714dde369562566355a28a2177cab7e91a6af451eb
Alexis Sellier committed ago 1 parent 732b4a2c
lib/std/lang/lower.rad +15 -9
680 680
    /// Union type: tag compared against variant indices.
681 681
    Union(resolver::UnionType),
682 682
}
683 683
684 684
/// Determine the kind of a match subject from its type.
685 -
unsafe fn matchSubjectKind(type: resolver::Type) -> MatchSubjectKind {
685 +
fn matchSubjectKind(type: resolver::Type) -> MatchSubjectKind {
686 686
    if resolver::isOptionalPointer(type) {
687 687
        return MatchSubjectKind::OptionalPtr;
688 688
    }
689 689
    if resolver::isOptionalAggregate(type) {
690 690
        return MatchSubjectKind::OptionalAggregate;
4325 4325
///////////////////////////////////////
4326 4326
// Record and Aggregate Type Helpers //
4327 4327
///////////////////////////////////////
4328 4328
4329 4329
/// Extract the nominal record info from a resolver type.
4330 -
unsafe fn recordInfoFromType(typ: resolver::Type) -> ?resolver::RecordType {
4331 -
    let case resolver::Type::Nominal(resolver::NominalType::Record(recInfo)) = typ
4330 +
fn recordInfoFromType(typ: resolver::Type) -> ?resolver::RecordType {
4331 +
    let case resolver::Type::Nominal(info) = typ
4332 4332
        else return nil;
4333 -
4334 -
    return recInfo;
4333 +
    unsafe {
4334 +
        let case resolver::NominalType::Record(recInfo) = *info
4335 +
            else return nil;
4336 +
        return recInfo;
4337 +
    }
4335 4338
}
4336 4339
4337 4340
/// Extract the nominal union info from a resolver type.
4338 -
unsafe fn unionInfoFromType(typ: resolver::Type) -> ?resolver::UnionType {
4339 -
    let case resolver::Type::Nominal(resolver::NominalType::Union(unionInfo)) = typ
4341 +
fn unionInfoFromType(typ: resolver::Type) -> ?resolver::UnionType {
4342 +
    let case resolver::Type::Nominal(info) = typ
4340 4343
        else return nil;
4341 -
4342 -
    return unionInfo;
4344 +
    unsafe {
4345 +
        let case resolver::NominalType::Union(unionInfo) = *info
4346 +
            else return nil;
4347 +
        return unionInfo;
4348 +
    }
4343 4349
}
4344 4350
4345 4351
/// Return the effective type of a node after any coercion applied by
4346 4352
/// the resolver. `lowerExpr` already materializes the coercion in the
4347 4353
/// IL value, so the lowerer must use the post-coercion type when