Questions tagged [subtype]

198 questions
4
votes
1 answer

How to load a different keyboard layout for subtype in android?

I'm using the android sample keyboard. it includes En (US) and En (GB) subtypes. On selecting either of the subtypes it only changes the flag on the spacebar. Say I want to change the layout based on whichever subtype is selected but I am unable to…
Junaid Qadir Shekhanzai
  • 1,287
  • 1
  • 18
  • 34
4
votes
5 answers

Child class doesn't see parent variable

public class Program { public static void main(String[] args) { Listener listener = new Listener(); listener.listen(); } } public class Listener { ServerQuery query; int test = 1; public listen() { …
user1652792
  • 309
  • 3
  • 15
4
votes
4 answers

Subtypes in java

If I have 4 distinct Java types (call them A B C D), and A is a subtype of B and A is a subtype of C and B is a subtype of D and C is a subtype of D, is this legal? Are there any examples out there? Drawing the diagram: D | | …
pauliwago
  • 5,359
  • 10
  • 36
  • 48
3
votes
5 answers

Java inheritor array construction and covariant return

(Title sounds a bit too fancy but I couldn't find a match so we'll hope it's descriptive.) I have a working piece of code as follows: @SuppressWarnings("unchecked") public static Copyable[] copyOf(Copyable[] objects, Class type) { Copyable[]…
orbfish
  • 6,349
  • 12
  • 50
  • 71
3
votes
1 answer

Difference between isSubtype and isAssignable for TypeMirror

In the documentation for the utility interface Types, of which an instance must be made available to an annotation processor for Java SE 6 or 7 by the compiler, there are two methods which interest me for a code snippet I'm working on. I need to…
G_H
  • 11,514
  • 2
  • 32
  • 73
3
votes
1 answer

Implicit resolution choosing the most specific subtype

Can some one explain me why scala resolve the most generic implicit no matter of local scope implicit more specific ? Example: import scala.math.ScalaNumber type Serializer[T] = T => String object SerializedOps{ implicit class AnyOps[T](t: T){ …
David Geirola
  • 576
  • 2
  • 15
3
votes
1 answer

Defining subtype relation in Coq

Is there a way to define subtype relationship in Coq? I read about subset typing, in which a predicate is used to determine what goes into the subtype, but this is not what I am aiming for. I just want to define a theory in which there is a type…
Yasmine Shaorda
  • 353
  • 1
  • 6
3
votes
1 answer

Swift protocol conformance requirements for subtypes

(if someone can suggest a better title, please do) The following code does not compile with an error Type 'ObserverClass' does not conform to protocol 'Observer', and compiler suggests a fix by declaring var object: ObservedObject. class…
user1244109
  • 2,024
  • 2
  • 23
  • 24
3
votes
1 answer

Equality for elements of sig type in Coq

With a sig type defintion like: Inductive A: Set := mkA : nat-> A. Function getId (a: A) : nat := match a with mkA n => n end. Function filter (a: A) : bool := if (beq_nat (getId a) 0) then true else false. Coercion is_true : bool >->…
Zheng Cheng
  • 354
  • 1
  • 11
3
votes
4 answers

Accessing the grand child of a class using polymorphism in C++

I was asked to implement this chart in polymorphism, which the output is to calculate geometry: The criteria is as follows: print() and getArea() function are placed in base class, which is Shape. It is also asked that it's a pure virtual function…
3
votes
1 answer

In common lisp, what is a function that returns the most specific supertype of two objects?

I am most interested in the applicability to SBCL, but am curious about other implementations of Common Lisp as well. In Common Lisp we have the type hierarchy. I would like a function that, given two objects as parameters, returns the symbol…
DJMelksham
  • 163
  • 7
3
votes
1 answer

Subtype polymorphism in scala

What is the difference between following two declarations of sum functions? def sum[A](xs:List[A]) = ..... def sum[A <: List[A]](xs:A) = .... EDIT: To elaborate more.... Lets say I want to write a method head on List. I can write head as…
amol
  • 66
  • 4
3
votes
1 answer

Casting to subtype in Oracle SQL when using refs

I have a type lecturer_typ with 2 sub types module_leader_typ and external_typ. I have inserted objects of all 3 of these types in one table called lecturer_tbl. I want to insert a reference to a module_leader_typ in another table but it's telling…
Max Carroll
  • 2,773
  • 1
  • 21
  • 24
3
votes
3 answers

Using a Class/record in an other class (subtype mark required in this context)

I want to learn ADA and have a problem with the 'class' I have 2 classes A and B and want that class A can use class B. Class A with B; package A is type A is tagged record varA : INTEGER := 0; varB : INTEGER := 0; …
3
votes
2 answers

Generic method is not applicable for the arguments

Sorry for the yet another "Java generic method is not applicable" question. I would like to know what am I missing in my understanding: List is a subtype of Collection --> meaning, List is a subtype of Collection Suppose A…
user1766760
  • 621
  • 1
  • 8
  • 25
1 2
3
13 14