Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix CTYP-91

Correctly instantiate polymorphic Protocol instances.
  • Loading branch information...
commit 4474f76eea1e966523914c5455761f1e7b8542c8 1 parent 2fbd2fb
@frenchy64 frenchy64 authored
View
4 src/main/clojure/clojure/core/typed/type_ctors.clj
@@ -451,9 +451,7 @@
(symbol? the-var)
(symbol? on-class)]
:post [(r/Type? %)]}
- (let [methods (into {} (for [[k v] methods]
- [k (abstract-many names v)]))
- p (r/Protocol-maker the-var (seq variances) (seq poly?) on-class methods declared?)]
+ (let [p (r/Protocol-maker the-var (seq variances) (seq poly?) on-class methods declared?)]
(if (seq variances)
(TypeFn* names variances bnds p)
p)))
View
4 src/main/clojure/clojure/core/typed/type_rep.clj
@@ -324,10 +324,10 @@
(every? variance? variances)))
(or (nil? poly?)
(and (seq poly?)
- (every? Type? poly?)))
+ (every? (some-fn Scope? Type?) poly?)))
(= (count poly?) (count variances))
(symbol? on-class)
- ((u/hash-c? (every-pred symbol? (complement namespace)) Type?) methods)
+ ((u/hash-c? (every-pred symbol? (complement namespace)) (some-fn Scope? Type?)) methods)
(u/boolean? declared?)]
:methods
[p/TCType])
View
14 src/test/clojure/clojure/core/typed/test/protocol.clj
@@ -12,3 +12,17 @@
(adder [_ i] 1))
(ann-protocol short/ShortNs)
+
+;; polymorphic protocols
+
+(ann-protocol [[x :variance :covariant]]
+ IFoo
+ bar [IFoo -> Number]
+ baz [IFoo -> Any])
+(defprotocol> IFoo
+ (bar [this])
+ (baz [this]))
+
+(comment
+ (check-ns 'clojure.core.typed.test.protocol)
+ )

0 comments on commit 4474f76

Please sign in to comment.
Something went wrong with that request. Please try again.