<< Back to previous view

[CTYP-260] Add Queue and BlockingQueue to altered classes Created: 23/Jul/15  Updated: 27/Aug/15

Status: Open
Project: core.typed
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Enhancement Priority: Major
Reporter: Mark Feeney Assignee: Ambrose Bonnaire-Sergeant
Resolution: Unresolved Votes: 0
Labels: None

Attachments: Text File alter-queues.patch    
Patch: Code

 Description   

Add java.util.Queue and java.util.concurrent.BlockingQueue to the list of special cases that allows them to be annotated with a type parameter.

Discussion: https://groups.google.com/forum/#!topic/clojure-core-typed/cgJlGriJ4OY



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 24/Jul/15 1:51 AM ]

I'm not sure we need to annotate java.util.Queue to get what you want.

We should already be able to upcast a Queue to a (Collection Any), and therefore
a (Seqable Any).

If you want to track the type of the queue, you might want to use an intersection
like (I Queue (Seqable Num)).

So try replacing (Queue Num) with (I Queue (Seqable Num)) and see if that covers
your use cases.

Comment by Mark Feeney [ 26/Jul/15 11:35 PM ]

Hm, I think this may work.

With this sort of method, is it possible to tell the checker what element type is in the collection at create time? e.g.

(t/cf (java.util.LinkedList. [1 2 3]) (t/I java.util.Queue (t/Seqable t/Any))) ; checks, but t/Any
(t/cf (java.util.LinkedList. [1 2 3]) (t/I java.util.Queue (t/Seqable t/Num))) ; doesn't check, but desirable t/Num

i.e. I can create a fn expecting an (I Queue (Seqable Num)), but I'm not sure I see how to create one to pass to it.

Comment by Ambrose Bonnaire-Sergeant [ 27/Jul/15 3:55 AM ]

This is the same situation as your patch. Only unchecked code can introduce a Queue that
holds anything other than Any.

Comment by Mark Feeney [ 27/Aug/15 8:26 PM ]

I think I can work around my original issues with the intersection type approach. Happy to close this unless you think the enhancement is still worthwhile.





[CTYP-272] check-ns: Assert failed: (r/Type? t) Created: 25/Aug/15  Updated: 25/Aug/15

Status: Open
Project: core.typed
Component/s: Clojure Checker
Affects Version/s: 0.3.10, 0.3.11
Fix Version/s: 0.3.12

Type: Defect Priority: Major
Reporter: Connor Clark Assignee: Ambrose Bonnaire-Sergeant
Resolution: Unresolved Votes: 0
Labels: bug
Environment:

Java 8, Clojure 1.7, OS X 10.10.3


Attachments: File bugoutput     File jim.clj     File project.clj    

 Description   

The presence of the function

(defn foo
[x y]
(pos? (rem x y)))

in a namespace causes an assert error when check-ns is called on it.

Attached is the full output of lein typed check, and the full code for a lein project that demonstrates the bug. This only occurs in 0.3.11 and 0.3.10.






[CTYP-271] reduce form with (U nil Num) accumulator needs inst to type check Created: 24/Aug/15  Updated: 24/Aug/15

Status: Open
Project: core.typed
Component/s: Core type system
Affects Version/s: 0.3.11
Fix Version/s: None

Type: Enhancement Priority: Minor
Reporter: Eric Bailey Assignee: Ambrose Bonnaire-Sergeant
Resolution: Unresolved Votes: 0
Labels: None
Environment:

Clojure 1.7.0



 Description   

In the example below, the inst shouldn't be needed.

(fn [string :- Str]
  (-> ((inst reduce (U nil Num) Character)
       (fn [sum :- (U nil Num), c :- Character]
         (when sum
           (some-> (case c \1 1, \0 0, nil)
             (+ (* 2 sum)))))
       0 string)
      (or 0)))





Generated at Sun Aug 30 11:11:58 CDT 2015 using JIRA 4.4#649-r158309.