mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Swift was previously crashing while emitting an error ("could not generate C++ types from the generic Swift types provided") for C++ decls that do not have a name, such as constructors: `func->getName()` triggered an assertion.
41 lines
1.1 KiB
C++
41 lines
1.1 KiB
C++
#ifndef TEST_INTEROP_CXX_TEMPLATES_INPUTS_CLASS_TEMPLATE_INSTANTIATION_ERRORS_H
|
|
#define TEST_INTEROP_CXX_TEMPLATES_INPUTS_CLASS_TEMPLATE_INSTANTIATION_ERRORS_H
|
|
|
|
template<class T>
|
|
struct MagicWrapper {
|
|
T t;
|
|
int getValuePlusArg(int arg) const { return t.getValue() + arg; }
|
|
};
|
|
|
|
template<class T>
|
|
struct MagicWrapperWithExplicitCtor {
|
|
T t;
|
|
MagicWrapperWithExplicitCtor(T t) : t(t) {}
|
|
};
|
|
|
|
struct IntWrapper {
|
|
int value;
|
|
int getValue() const { return value; }
|
|
};
|
|
|
|
template<class T>
|
|
struct CannotBeInstantianted {
|
|
T value;
|
|
|
|
CannotBeInstantianted(char, T value) { value.doesNotExist(); }
|
|
CannotBeInstantianted(char, char) { memberWrongType(); }
|
|
CannotBeInstantianted(T value) : value(value) {}
|
|
|
|
void callsMethodWithError() { memberWrongType(); }
|
|
|
|
void memberWrongType() { value.doesNotExist(); }
|
|
|
|
void argWrongType(T t) { t.doesNotExist(); }
|
|
|
|
int getOne() { return 1; }
|
|
int incValue() { return value.value + getOne(); }
|
|
int incValue(T t) { return t.value + getOne(); }
|
|
};
|
|
|
|
#endif // TEST_INTEROP_CXX_TEMPLATES_INPUTS_CLASS_TEMPLATE_INSTANTIATION_ERRORS_H
|