nested-generics Questions

4

Solved

Please consider the following pseudo-code trying to define a higher-order type function with a function-typed parameter M<?>: type HigherOrderTypeFn<T, M<?>> = T extends (...) ?...
Dukas asked 31/1, 2020 at 16:6

4

Solved

I have the following code: IEnumerable<IList<MyClass>> myData = //...getMyData foreach (MyClass o in myData) { // do something } It compiles, runs and obviously I get an System.Inv...
Globin asked 30/11, 2018 at 14:18

2

Solved

I am a little bit confused with the following and would be thankful for help. What I wanted to do was implement a generic circular list where I can get access to the nodes (not their values) from ...
Kayleigh asked 12/6, 2018 at 9:0

1

Solved

I'm prototyping some highly declarative code, and the type inference and safety that comes with Kotlin helps a lot. One of the goals is making extensions (subclasses) of the primary types stupidly ...
Ordination asked 7/6, 2017 at 9:26

1

Solved

First of all, thank you for visiting. I'm currently playing with Swift 3.1 Nested Generics and I've encountered an error with initialization. class NestedProduct<T> { enum Gadget { case ...
Alcock asked 13/4, 2017 at 3:2

5

Solved

In the following example: public static void main(String[] args) { List<String> b = new ArrayList<String>(); first(b); second(b); List<List<String>> a = new ArrayList...
Lotic asked 5/11, 2012 at 10:15

2

Solved

I am having an issue initializing a class with type parameter. It seems to be a shortcoming of Java's type inference and I would like to know if there's a way around this or a better way of achievi...
Gook asked 13/3, 2016 at 17:40

7

Solved

tl;dr Trying to implement a hierarchal fluent interface such that I can combine nodes child classes while also the class standalone, but getting type parameter is not within its bound errors. De...
Peal asked 10/10, 2014 at 17:4

1

Solved

For the following code sample: public static class Abc<X> { } public static class Def<Y> { } public static class Ghi<Z> { } public void doThis() { List<?> listOne; List&...
Krishna asked 19/6, 2014 at 13:57

1

I have a class with a bounded type parameter with nested wildcard bounded types. In the class I need to use the types of the bound nested parameters in multiple methods. Is there a way to define th...
Startling asked 5/7, 2013 at 16:51

1

I am currently trying to implement an API for a conceptual model using Java interfaces and generics. The model (Transmodel V5.0) is described as an entity-relationship model in great detail, but it...
Foreordain asked 31/1, 2014 at 1:32

2

Solved

I am trying to figure out how to get generics to jump through hoops. I have: interface Root { } interface Middle extends Root { } class Type implements Root { } And many "Subtype" classes: cla...
Glycoside asked 27/3, 2013 at 23:40

2

Solved

The following little Java example won't compile for unclear reasoning: package genericsissue; import java.util.ArrayList; import java.util.List; interface Attribute<V> {} interface ListAt...
Cyanamide asked 17/5, 2013 at 15:47

3

class HasId<I> {} class HasStringId extends HasId<String> {} class Alert<T extends /*Some*/Object> extends HasStringId {} class BaseController<M extends HasId<String>>...
Crispation asked 11/3, 2013 at 3:16

3

Solved

I was playing around with a hobby project when I came across a type-inference error I didn't understand. I have simplified it to the following trivial example. I have the following classes and fun...
Mattins asked 4/9, 2012 at 2:30

2

Solved

Apparently, C# is as susceptible to '>>' lexer dilemma as is C++. This C# code is pretty valid, it compiles and runs just fine: var List = new Dummy("List"); var Nullable = new Dummy("Nullable");...
Mahau asked 16/5, 2012 at 0:6

3

I have the following Classes / Interfaces: // Model public class A : IA { } // ModelLogic public class B : IB<A> { } // Model Interface public interface IA { } // ModelLogic Interface publi...
Coyne asked 27/4, 2012 at 14:32

2

Solved

UPDATE: As of C# 7.3, this should no longer be an issue. From the release notes: When a method group contains some generic methods whose type arguments do not satisfy their constraints, these m...

2

Solved

I wrote this extension method (which compiles): public static IEnumerable<J> Flatten<T, J>(this IEnumerable<T> @this) where T : IEnumerable<J> { foreach (T t in @this) ...
Villada asked 25/2, 2012 at 2:2

3

Solved

I have a generic java class that stores comparables: public class MyGenericStorage<T extends Comparable<T>> { private T value; public MyGenericStorage(T value) { this.value = value...
Pulpboard asked 29/11, 2011 at 17:53

3

This is an example which I made up to be a simplification of my real code, so I apologize if it is a little contrived. What I would like to do is to effectively get two type parameters out of a sin...
Dryden asked 8/11, 2011 at 23:27

2

Solved

I suspect this has been asked here (and answered) before, but I don't know how to name the problem. Why can I express the wildcards without problem only when I'm not passing the class itself? It ...
Hypaethral asked 14/8, 2011 at 3:38

1

Solved

Given the following classes... public abstract class FooBase<TBar> where TBar : BarBase{} public abstract class BarBase{} public class Bar1 : BarBase{} public class Foo1 : FooBase<Bar1&gt...
Dorcia asked 8/7, 2011 at 21:26

3

Solved

Note: purely out of curiosity and not for any actual use case. I'm wondering if there is a way to declare the Class Class object with valid type parameters: Class cc1 = Class.class; //raw type Cl...
Polytrophic asked 19/5, 2011 at 23:33

3

Solved

I am having a problem understanding how polymorphism works when using generics. As an example, I have defined the following program: public interface IMyInterface { void MyMethod(); } public cla...
Autoeroticism asked 25/8, 2010 at 12:4

© 2022 - 2024 — McMap. All rights reserved.