Skip to content

泛型匹配问题 #880

@xuhuanzy

Description

@xuhuanzy

由于infer_expr得到的结果是泛型展开后的类型, 导致以下测试失败

    #[test]
    fn test_base_generic() {
        let mut ws = crate::VirtualWorkspace::new();
        ws.def(
            r#"
            ---@alias Arrayable<T> T | {a: T}

            ---@class Suite

            ---@generic T
            ---@param value Arrayable<T>
            ---@return T[]
            function toArray(value)
            end
        "#,
        );

        ws.def(
            r#"
            ---@type Arrayable<Suite>
            local suite

            arraySuites = toArray(suite)
        "#,
        );

        let a = ws.expr_ty("arraySuites");
        let expected = ws.ty("Suite[]");
        assert_eq!(a, expected);
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions