clojure.core/slurp does not mark its return type as String

Description

Given that slurp always returns a string (or throws), a user might expect that calling a string method on it will not reflect. However, its return type is not hinted, so calling, say, (.getBytes (slurp "foo")) will reflect unless the user hints. If we hint in clojure.core, the user won't have to.

user=> (set! *warn-on-reflection* true) true user=> (.length (slurp "pom.xml")) Reflection warning, NO_SOURCE_PATH:3:1 - reference to field length can't be resolved. 9218

Patch: CLJ-2188-v1.patch

Prescreened by: Alex Miller

Environment

None

Attachments

1
  • 23 Jun 2017, 11:37 PM

Activity

Show:
Completed

Details

Assignee

Reporter

Approval

Ok

Patch

Code

Priority

Affects versions

Fix versions

Created June 23, 2017 at 11:32 PM
Updated September 7, 2017 at 10:25 PM
Resolved September 7, 2017 at 10:25 PM

Flag notifications