Ersetzen von Generics wenn bereits ein Generic existiert #32

Open
opened 2025-02-26 10:47:28 +00:00 by RubenKraft · 0 comments
Owner

Wird ein Generic ausgewählt und es existiert noch keines in der Klasse, wird dieses legal hinzugefügt.

class TPHsAndGenerics<DRX> {
id = x -> x ;
    id2 (x) {
        return id.apply(x);
    }

    DRX m (a , DRX b ){
        return b ; 
    }

    m2 (a , be ) {
        var c = m (a , be );
        return a; 
    }
}

Wenn nun ein neues Generic ausgewählt wird, resultiert das in folgender, illegaler Syntax.

class TPHsAndGenerics<DRX> <ELH> {
    id = x -> x ;
    ELH id2 (x) {
        return id.apply(x);
    }

    DRX m (a , DRX b ){
        return b ; 
    }

    m2 (a , be ) {
        var c = m (a , be );
        return a; 
    }
}

Eigentlich entstehen sollte

class TPHsAndGenerics<DRX, ELH> {
    id = x -> x ;
    ELH id2 (x) {
        return id.apply(x);
    }

    DRX m (a , DRX b ){
        return b ; 
    }

    m2 (a , be ) {
        var c = m (a , be );
        return a; 
    }
}
Wird ein Generic ausgewählt und es existiert noch keines in der Klasse, wird dieses legal hinzugefügt. ```java class TPHsAndGenerics<DRX> { id = x -> x ; id2 (x) { return id.apply(x); } DRX m (a , DRX b ){ return b ; } m2 (a , be ) { var c = m (a , be ); return a; } } ``` Wenn nun ein neues Generic ausgewählt wird, resultiert das in folgender, illegaler Syntax. ```java class TPHsAndGenerics<DRX> <ELH> { id = x -> x ; ELH id2 (x) { return id.apply(x); } DRX m (a , DRX b ){ return b ; } m2 (a , be ) { var c = m (a , be ); return a; } } ``` Eigentlich entstehen sollte ```java class TPHsAndGenerics<DRX, ELH> { id = x -> x ; ELH id2 (x) { return id.apply(x); } DRX m (a , DRX b ){ return b ; } m2 (a , be ) { var c = m (a , be ); return a; } } ```
RubenKraft added the
Bug
Server
labels 2025-02-26 10:47:51 +00:00
RubenKraft added the
Generics
label 2025-02-26 10:49:13 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: RubenKraft/JavaTXLanguageServer#32
No description provided.