給定一個Java類兩種方法(從的Mockito拍攝):部隊單個參數可變參數
OngoingStubbing<T> thenReturn(T value);
OngoingStubbing<T> thenReturn(T value, T... values);
如果我從斯卡拉調用與
....thenReturn("something")
我得到一個錯誤:
Description Resource Path Location Type
ambiguous reference to overloaded definition, both method thenReturn in trait OngoingStubbing of type (x$1: java.lang.Object, x$2: <repeated...>[java.lang.Object])org.mockito.stubbing.OngoingStubbing[java.lang.Object] and method thenReturn in trait OngoingStubbing of type (x$1: java.lang.Object)org.mockito.stubbing.OngoingStubbing[java.lang.Object] match argument types (java.lang.String)
而我無法弄清楚如何解決這個問題。
問題是,當你對一個返回java.lang.Object(又名AnyRef)的方法進行stubbing,然後你被Scala搞砸了。 –
我認爲你的意思是AnyVal不是一個對象 –