type-erasure

    6熱度

    4回答

    無法編譯爲什麼下面沒有在斯卡拉編譯: class A class B object X { def f[Q <: A](q: Q): Q = q def f[Q <: B](q: Q): Q = q } 與錯誤信息 <console>:16: error: method f is defined twice conflicting symbols both

    0熱度

    3回答

    我們導入了一個過時的項目,它促使我們將其轉換爲Swift 3.作爲對Swift不太瞭解的個人,我們在修復錯誤時遇到困難。 Error can be found at this image import Foundation class CellDescriptorHelper { let itemKey = "Items" let isExpandableKey = "isExpanda

    0熱度

    3回答

    說..,Java編譯器將刪除所有類型的信息,並取代那些與他們的上限(如果提到)或對象的所有出現.. 我的問題是:沒有管型插入發生在這裏。當一些其他類被編譯爲這種類型的無信息類時,後來發生Casting,其中,取決於其他類補充的類型參數,泛型類被重新編譯(第二次),並且所有的類都被放置到位並且班級已準備好運行時間了,對嗎?

    1熱度

    2回答

    我正在嘗試爲我的應用程序創建數據模型。這裏是場景: 我的應用程序有客戶模型,其中包含客戶的信息,也包含他/她的支付來源。該API給我兩種支付來源:卡和銀行帳戶他們有完全不同的領域。 所以,這裏是我的問題,我想要具有PaymentSource的抽象類型,然後在每個PaymentSource中都有一個函數來將對象轉換爲它的類型。一些我是如何刪除類型的。 我需要把我的抽象類型放在一個盒子裏,並用它作爲具

    3熱度

    1回答

    假設我有一個通用的容器類型這樣的: public final class Container<T> { public final T t; public Container(final T t) { this.t = t; } } 我想要實現等於使得該通行證: final Container<Object> a = new Container<>

    1熱度

    2回答

    我有一個問題(也許關於類型擦除)。想象一下以下情形: public protocol DataItem { associatedtype T var action: ((_ item: T) -> Void)? {get} } struct UserItem: DataItem { typealias T = UserItem // Custom

    2熱度

    2回答

    我有Class<?>這個字段。我有一個方法,它必須在Jackson的幫助下將字符串投射到對象上。 private Class<?> myType = ...; private String jsonRepresentationOfObject = ....; ObjectMapper mapper = new ObjectMapper(); public <T> T get() {

    1熱度

    1回答

    (弗林克1.3) 我與類型的提取問題: The return type of function '...' could not be determined automatically, due to type erasure. You can give type information hints by using the returns(...) method on the result o

    0熱度

    3回答

    我正試圖編寫一個雙向映射,因爲(據我所見)Java沒有提供。我的代碼如下。 private static final class ColourCharTwoWayMap<E,F> { private ArrayList<E> eArrayList; private ArrayList<F> fArrayList; private ColourCharTwoWayM

    1熱度

    1回答

    我有使用無類型的一個Something[Any]轉換爲Scala中的一個Something[X]功能: import shapeless._ import shapeless.syntax.typeable._ def doCast[T: Typeable](v: Vector[Any]): T = v.cast[T].get 現在我想通過索引來訪問列表: val a = Vector[