简体   繁体   中英

eiffel type conformance and attachement check not working

Trying to solve one of the SCOOP consequences with make_from_separate I'm running into an issue where at runtime types seem to be the same and won't pass the attached statement.

non_separate_from_any

non_separate_from_any, any_from_separate (v: separate ANY): ANY
    local
        l_array: ARRAY[detachable ANY]
        l_res_ll_arr_det_any: LINKED_LIST[ARRAY[detachable ANY]]
        l_arr_det_str: ARRAY[detachable STRING]
    do
        if
            attached {REAL} v as l_v
        then
            Result := l_v
        elseif attached {separate INTEGER_32_REF} v as l_v then
            Result := l_v.as_integer_32
        elseif attached {INTEGER} v as l_v then
            Result := l_v
        elseif attached {separate STRING} v as l_v then
            create {STRING} Result.make_from_separate (l_v)
        elseif attached {separate STRING_32} v as l_v then
            create {STRING_32} Result.make_from_separate (l_v)
        elseif attached {separate LINKED_LIST[separate ARRAY[detachable ANY]]} v as l_v then
            create l_res_ll_arr_det_any.make
            across
                l_v is l_list_item_sep
            loop
                create l_array.make_empty
                separate l_list_item_sep as l_list_item_sep_tmp do
                    across
                        l_list_item_sep_tmp as l_array_item_non_sep
                    loop
                        if attached l_array_item_non_sep as l_any_sep then
                            l_array.put (non_separate_from_any (l_any_sep), l_array_item_non_sep.cursor_index)
                        else
                            l_array.put (Void, l_array_item_non_sep.cursor_index)
                        end
                    end
                end
                l_res_ll_arr_det_any.extend (l_array)
            end
            Result := l_res_ll_arr_det_any
        elseif attached {separate ARRAY[detachable STRING]} v as l_v then
            create l_arr_det_str.make_empty
            across
                l_v as l_s_sep
            loop
                if attached l_s_sep.item as l_s_sep_att then
                    l_arr_det_str.put (create {STRING}.make_from_separate (l_s_sep_att), l_s_sep.cursor_index)
                else
                    l_arr_det_str.put (Void, l_s_sep.cursor_index)
                end
            end
            Result := l_arr_det_str
        else
            check
                implement_me: False
            then
                do_nothing
            end
        end
    ensure
        instance_free: Class
    end

Variables and statements with screenshot

埃菲尔工作室截图

安慰出来

UPDATE 20200616

Declarations are following:

DB_TUPLE_COL_NAMES -> items: ARRAY[STRING]
DEFAULT_DB_ACTION -> column_names: separate like {DB_TUPLE_COL_NAMES}.items


DEFAULT_DB_ACTION -> make_from_separate (other: separate like Current)

At runtime I got a other.column_names -> at runtime: ARRAY[detachable STRING]

How can that be!!! thats the reason of my implementation of any_from_separate with l_arr_det_str在此处输入图像描述

It looks like the actual type of the object is ARRAY [detachable STRING] rather than ARRAY [STRING] .

TL;DR:

Change

        elseif attached {separate LINKED_LIST[separate ARRAY[detachable ANY]]} v as l_v then
            create ll_arr_det_any.make -- l_arr_det_str: ARRAY[detachable STRING]

with

        elseif attached {separate LINKED_LIST[separate ARRAY[detachable ANY]]} v as l_v then
            create l_arr_str.make -- l_arr_det_str: ARRAY[STRING]

Explanation

My Error was into {SCOOP_UTIL}.any_from_separate .

As

{separate LINKED_LIST[separate ARRAY[ANY]]}

conforms to

{separate LINKED_LIST[separate ARRAY[detachable ANY]]}

it was taking this path and I interpreted that I had to create an

ARRAY[detachable ANY] but was a ARRAY[ANY] .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM