2017-10-23 24 views
0

나는 다음과 같은 한 테스트 케이스 :에펠 상속 커서 사용 [컴파일 할 수 없습니다]

test_different_cursor: BOOLEAN 
     local 
      cursor: SET_ITERATION_CURSOR[INTEGER, INTEGER] 
      sets: ARRAY[SET[INTEGER, INTEGER]] 
     do 
      create sets.make_empty 

      check attached {SET_ITERATION_CURSOR[INTEGER, INTEGER]} d.different_cursor as current_cursor then 
       cursor := current_cursor 
      end 
      from 
      until 
       cursor.after 
      loop 
       sets.force (cursor.item, sets.count + 1) 
       cursor.forth 
      end 

     end 

여기 ~ 끝에서의 루프에서, 나는 Array 클래스의 힘 기능을 호출하려고 노력하지만, 컴파일러는 자꾸 그 라인에 대한 오류를 다음

Error code: VUAR(2) 

Type error: non-compatible actual argument in feature call. 
What to do: make sure that type of actual argument is compatible with 
    the type of corresponding formal argument. 

Class: MY_TESTS 
Feature: test_different_cursor 
Called feature: force (v: [like item] G; i: INTEGER_32) from ARRAY 
Argument name: v 
Argument position: 1 
Formal argument type: SET [INTEGER_32, INTEGER_32] 
Actual argument type: TUPLE [INTEGER_32, INTEGER_32] 
Line: 193 
     loop 
->  sets.force (cursor.item, sets.count + 1) 
      cursor.forth 

를이 경우, 내가 ARRAY 클래스를 상속 SET 클래스를 만들고 거기에 힘 기능을 재정의해야 할 것 같다. 하지만 컴파일 오류를 수정하는 올바른 방법은 아닌지 잘 모르겠습니다. 다음은 내 SET 클래스의 모습입니다.

class 
    SET[A, B] 

create 
    make 

feature 
    valueA: A 
    valueB: B 

feature 
    make (first: A; second: B) 
     do 
      valueA := first 
      valueB := second 
     end 
end 

이 문제를 해결하려면 어떻게해야합니까?

+0

에 선

sets.force (cursor.item, sets.count + 1) 

을 특징 test_different_cursor에 지역 변수

t: TUPLE [first: INTEGER; second: INTEGER] 

를 추가하고 변경하여 수행 할 수 있습니다 VUAR (2)'와 같은 실제 인수의 유형을 지정합니다. 현재 코드에서'cursor.item'이 반환하는 것을 추측하는 것은 어렵습니다. 또는'SET_ITERATION_CURSOR' 클래스의 짧은 형식을 제공 할 수 있습니다. –

+0

@AlexanderKogtenkov 오류 코드 : VUAR (2) 유형 오류 : 기능 호출에서 호환되지 않는 실제 인수. 수행 할 작업 : 실제 인수 유형이 해당 형식 인수의 유형과 호환되는지 확인하십시오. 등급 : MY_TESTS 기능 : test_different_cursor – Miku

+0

유형은 무엇입니까? –

답변

0

cursor.item이 반환하는 값은 SET [INTEGER, INTEGER]으로 변환되어야합니다. 이 작업은 '보고 더 자세한 정보를 제공하는 경우 도움이 될

t := cursor.item 
sets.force (create {SET [INTEGER, INTEGER]}.make (t.first, t.second), sets.count + 1)