Skip to content

class extends basis class with generic compile error #1971

Closed
@HerrCai0907

Description

@HerrCai0907

Hello,
Is this compile error reasonable? I'm not sure whether assemblyscript supports the way of following inheritance.

ERROR TS2322: Type '(this: assembly/index/B<f64,~lib/string/String>, f64) => void' is not assignable to type '(this: assembly/index/A, i32) => void'.

 foo(a:T):void{
class A<T>{
    foo(a:T):void{
        trace(`class A ${a}`)
    }
}
class B<T,V> extends A<T>{
    foo(a:T):void{
        trace(`class B ${a}`)
    }
}
export function test_foo():void{
    let v = new B<i32,f64>()
    let v2 = new B<i32,string>()
    let v3 = new B<f64,string>() // if comment this line, compile OK
    const v_usize = changetype<usize>(v)
    changetype<A<i32>>(v_usize).foo(1)
}

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions