Skip to content

Commit 96a6022

Browse files
committed
Fix Truffle DSL not honoring @SuppressWarnings("deprecation").
1 parent 31d7c6a commit 96a6022

File tree

2 files changed

+40
-5
lines changed

2 files changed

+40
-5
lines changed

truffle/src/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/SuppressWarningTest.java

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* The Universal Permissive License (UPL), Version 1.0
@@ -47,7 +47,7 @@
4747
public class SuppressWarningTest {
4848

4949
@SuppressWarnings({"unused", "truffle-inlining"})
50-
public abstract static class DeprecationTestNode extends Node {
50+
public abstract static class DeprecatedTestNode extends Node {
5151

5252
abstract int execute(int v);
5353

@@ -81,4 +81,39 @@ static boolean deprecatedGuard(int v) {
8181

8282
}
8383

84+
@SuppressWarnings({"unused", "truffle-inlining"})
85+
public abstract static class DeprecationTestNode extends Node {
86+
87+
abstract int execute(int v);
88+
89+
/*
90+
* Suppress deprecation warning with "deprecation".
91+
*/
92+
@SuppressWarnings("deprecation")
93+
@Specialization(guards = {"deprecatedGuard(v)", "v == 0"})
94+
int s0(int v) {
95+
return v;
96+
}
97+
98+
/*
99+
* Suppress deprecation warning with "all".
100+
*/
101+
@SuppressWarnings("all")
102+
@Specialization(guards = {"deprecatedGuard(v)", "v == 1"})
103+
int s1(int v) {
104+
return v;
105+
}
106+
107+
@Specialization
108+
int s2(int v) {
109+
return v;
110+
}
111+
112+
@Deprecated
113+
static boolean deprecatedGuard(int v) {
114+
return true;
115+
}
116+
117+
}
118+
84119
}

truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/expression/DSLExpression.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* The Universal Permissive License (UPL), Version 1.0
@@ -264,7 +264,7 @@ public static DSLExpression resolve(DSLExpressionResolver resolver, MessageConta
264264
try {
265265
expression.accept(resolver);
266266
List<Element> deprecatedElements = expression.findBoundDeprecatedElements();
267-
if (!deprecatedElements.isEmpty() && !TruffleSuppressedWarnings.isSuppressed(container.getMessageElement(), "deprecated")) {
267+
if (!deprecatedElements.isEmpty() && !TruffleSuppressedWarnings.isSuppressed(container.getMessageElement(), TruffleSuppressedWarnings.DEPRECATION, "deprecated")) {
268268
AnnotationMirror mirror = container.getMessageAnnotation();
269269
AnnotationValue value = null;
270270
if (mirror != null && annotationValueName != null) {
@@ -277,7 +277,7 @@ public static DSLExpression resolve(DSLExpressionResolver resolver, MessageConta
277277
b.append(String.format("%n - "));
278278
b.append(relativeName);
279279
}
280-
b.append(String.format("%nUpdate the usage of the elements or suppress the warning with @SuppressWarnings(\"deprecated\")."));
280+
b.append(String.format("%nUpdate the usage of the elements or suppress the warning with @SuppressWarnings(\"" + TruffleSuppressedWarnings.DEPRECATION + "\")."));
281281
container.addWarning(value, b.toString());
282282
}
283283
return expression;

0 commit comments

Comments
 (0)