-
Notifications
You must be signed in to change notification settings - Fork 29
Add composable serialization intrinsics #1224
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
ff48f03
9c5de39
0ae98c7
54131e2
d43e359
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -294,7 +294,7 @@ private ToStringConversionResolution(@Nullable FuncLink conversion, @Nullable St | |
| return null; | ||
| } | ||
| if (CompilerIntrinsics.isNew(node)) { | ||
| return null; | ||
| return findIntrinsicDeclaration(node); | ||
| } | ||
| FuncLink result = searchFunction(node.getFuncName(), node, argumentTypes(node)); | ||
|
|
||
|
|
@@ -311,6 +311,22 @@ private ToStringConversionResolution(@Nullable FuncLink conversion, @Nullable St | |
| return result; | ||
| } | ||
|
|
||
| private static @Nullable FuncLink findIntrinsicDeclaration(ExprFunctionCall node) { | ||
| for (FuncLink candidate : node.lookupFuncs(node.getFuncName())) { | ||
| if (!CompilerIntrinsics.isDeclaration(candidate.getDef()) | ||
| || candidate.getVisibility() == Visibility.PRIVATE_OTHER | ||
| || candidate.getVisibility() == Visibility.PROTECTED_OTHER) { | ||
| continue; | ||
| } | ||
| FunctionSignature signature = FunctionSignature.fromNameLink(candidate); | ||
| if (node.getTypeArgs().size() == signature.getDefinitionTypeVariables().size() | ||
| && signature.matchAgainstArgs(argumentTypesPre(node), node) != null) { | ||
| return candidate; | ||
| } | ||
| } | ||
| return null; | ||
| } | ||
|
|
||
| private static boolean isConstructorThisCall(ExprFunctionCall node) { | ||
| if (!node.getFuncName().equals("this")) { | ||
| return false; | ||
|
|
@@ -519,6 +535,12 @@ public static boolean hasApplicableUserFunction(ExprFunctionCall node) { | |
| } | ||
| List<WurstType> argumentTypes = argumentTypesPre(node); | ||
| for (FuncLink candidate : candidates) { | ||
| // A @compilerintrinsic declaration is an IDE-visible contract for an operation which | ||
| // is still lowered by the compiler. It must not shadow that lowering like an ordinary | ||
| // user function with the same name does. | ||
| if (CompilerIntrinsics.isDeclaration(candidate.getDef())) { | ||
| continue; | ||
|
Comment on lines
+541
to
+542
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When an imported AGENTS.md reference: AGENTS.md:L310-L311 Useful? React with 👍 / 👎. |
||
| } | ||
| if (candidate.getVisibility() == Visibility.PRIVATE_OTHER | ||
| || candidate.getVisibility() == Visibility.PROTECTED_OTHER) { | ||
| continue; | ||
|
|
@@ -541,6 +563,15 @@ private static FuncLink searchFunction(String funcName, @Nullable FuncRef node, | |
| return null; | ||
| } | ||
| ImmutableCollection<FuncLink> funcs1 = node.lookupFuncs(funcName); | ||
| if (node instanceof ExprFunctionCall | ||
| && hasApplicableUserFunction((ExprFunctionCall) node)) { | ||
| ImmutableList<FuncLink> ordinaryFunctions = funcs1.stream() | ||
| .filter(f -> !CompilerIntrinsics.isDeclaration(f.getDef())) | ||
| .collect(Utils.toImmutableList()); | ||
| if (!ordinaryFunctions.isEmpty()) { | ||
| funcs1 = ordinaryFunctions; | ||
| } | ||
| } | ||
| if (funcs1.size() == 0) { | ||
| if (funcName.startsWith("InitTrig_")) { | ||
| // ignore error | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When an IDE resolves an annotated
wurstNewInstance<T>()call, this declaration is excluded from ordinary-function detection, after whichAttrFuncDef.calculate(ExprFunctionCall)returnsnullimmediately becauseCompilerIntrinsics.isNew(node)is true. Consequently get-definition and hover return no result for the documented construction intrinsic, even though the new declaration mechanism works for the field-iteration intrinsics; preserve the declaration link for tooling while keeping compiler lowering intact.Useful? React with 👍 / 👎.