<?php
class Bar {}
class Foo extends Bar {}
function f(Bar $f) {
var_dump($f instanceof Foo);
}
f(null);
// - Foo is "unused" and will not be generated
// - instanceof produces unconditional class_dep on Foo
// - we get Can't find header cl/C@Foo.h required by o_0/f.h + compiler crash
class_dep is added here:
|
if (auto instanceof = vertex.try_as<op_instanceof>()) { |
|
current_function->class_dep.insert(instanceof->derived_class); |
|
} |
Possible solutions:
- Don't add
class_dep for unused classes?
- Don't try to add a header for unused class?
- Mark class as used if it was reachable from
instanceof from a used function?
- ...
I'll reference another related problem to this issue.
class_depis added here:kphp/compiler/pipes/calc-func-dep.cpp
Lines 34 to 36 in df45fd1
Possible solutions:
class_depfor unused classes?instanceoffrom a used function?I'll reference another related problem to this issue.