Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid "Classes cannot have non-final generic functions in embedded Swift" error #78150

Open
TeamPuzel opened this issue Dec 12, 2024 · 0 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels

Comments

@TeamPuzel
Copy link

TeamPuzel commented Dec 12, 2024

Description

There is a bug where despite the class being final the compiler does not let me use generics in the initializer. This can't be fixed by adding final as it seems to be disallowed on initializers. There appears to be a workaround, I made the initializer only create an empty texture and put the generics in a convenience initializer

Reproduction

public final class Texture {
    private let id: GLuint
    public var unit: GLuint

    public init(_ unit: GLuint = 0, image: some Drawable) { // Error
        var id: GLuint = 0
        glad_glGenTextures(1, &id)
        
        (...)
    }
    (...)
}

Expected behavior

This class is final and only being used for reference semantics. It should compile.

Environment

Apple Swift version 6.2-dev (LLVM 4930d5a55e7728b, Swift ec5bee8bc94399a)
Target: arm64-apple-macosx15.0

Additional information

No response

@TeamPuzel TeamPuzel added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels labels Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels
Projects
None yet
Development

No branches or pull requests

1 participant