HaxeFoundation / HaxeFoundation/haxe

Generic and call-site inlining

Open
#8,369 1 comment 0 reactions 0 assignees View on GitHub
feature-generic feature-inline
Dominant language
Haxe
Stars
6.9k
Forks
715
Avg merge
2d 2h
Merged PRs (30d)
11

Description

```haxe
class Some {
var v:Int;
public function new() {}
public function something(v:Int) { this.v = v; }
}

@:generic
class Generic {
var t:T;
public function new(t:T) this.t = t;
public function something(v:Int) { inline t.something(v); }
}
```
.Generic.hx:12: characters 47-58 : Generic.T has no field something

Haxe expects a type parameter constraint:

```haxe
@:generic
class Generic {
```

however, this causes t.something(v) to not be inline (cpp code)

```cpp
this->t->something(v);
```

versus explicit cast

```haxe
public function something(v:Int) { inline (cast t:Some).something(v); }
```
```cpp
this->t->v = v;
```

Why Generic.T doesn't resolve to Some type when it's clear that it is of a Some type in Generic_Some.cpp? Because Generic.T is a TLazy?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.