skiptools / skiptools/skip

Complex generic constraints can't be overridden with `SKIP DECLARE`

Open
#432 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

transpilation
Dominant language
Swift
Stars
3.2k
Forks
106
Avg merge
6d 13h
Merged PRs (30d)
1

Description

Regarding https://github.com/skiptools/skip-ui/pull/210 I was unable to get this declaration to transpile:

// SKIP DECLARE: public fun <K: PreferenceKey<V>, V: Any> View.onPreferenceChange(key: KClass<K>, perform: (V) -> Unit): View
public func onPreferenceChange<K>(
        _ key: K.Type = K.self,
        perform action: @escaping (
            K.Value
        ) -> Void
    ) -> some View where K : PreferenceKey, K.Value : Equatable {

The transpiler kept objecting to the K.Value : Equatable clause of the where. That would be fine if the SKIP DECLARE comment would allow me to use an alternate declaration, but Skip refused to transpile this code even with SKIP DECLARE.

IMO, SKIP DECLARE should make the transpiler stop complaining about the declaration.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the declaration shown in the issue and start by tracing the transpiler's handling of the SKIP DECLARE annotation. The change is complete when this declaration is accepted without errors and the alternate declaration is used instead of validating the unsupported generic constraint.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.