skiptools / skiptools/skip

Skip Lite doesn't transpile implicitly unwrapped optionals

Open
#571 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

import SwiftUI

struct ContentView: View {
    func example(_ x: String) {
        print(x)
    }
    
    func example2() {
        var x: String! = nil
        x = "world"
        example(x)
    }
    
    var body: some View {
        let _ = example2()
        Text("hello")
    }
}

This transpiles to:

internal class ContentView: View {
    internal fun example(x: String): Unit = print(x)

    internal fun example2() {
        var x: String = null
        x = "world"
        example(x)
    }

    override fun body(): View {
        return ComposeBuilder { composectx: ComposeContext ->
            example2()
            Text(LocalizedStringKey(stringLiteral = "hello")).Compose(composectx)
            ComposeResult.ok
        }
    }
}

But that fails to compile. "Null cannot be a value of a non-null type 'String'."

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

Start with the SwiftUI reproduction in this issue and compare its generated Kotlin output. Trace how an implicitly unwrapped optional is represented during transpilation, then verify that the resulting code accepts the shown nil initialization and compiles successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
kotlin, swift
Domain
compilers, mobile-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.