What is the list of valid #SuppressWarnings warning names in Gosu? - intellij-idea

What is the list of valid #SuppressWarnings warning names in Gosu?
The bit that comes in between the ("") in #SuppressWarnings("").
There is already an SO answer for Java but I'm interested in suppressing the warning that my variable type can be inferred (passing an inferred block variable as a function parameter does not compile so I'm using an explicitly typed variable).
Java answer: What is the list of valid #SuppressWarnings warning names in Java?

Related

What is the significance of a ! following a type in kotlin? [duplicate]

What does a single exclamation mark mean in Kotlin? I've seen it a few times especially when using Java APIs. But I couldn't find it in the documentation nor on StackOverflow.
They're called platform types and they mean that Kotlin doesn't know whether that value can or cannot be null and it's up to you to decide if it's nullable or not.
In a nutshell, the problem is that any reference coming from Java may be null, and Kotlin, being null-safe by design, forced the user to null-check every Java value, or use safe calls (?.) or not-null assertions (!!). Those being very handy features in the pure Kotlin world, tend to turn into a disaster when you have to use them too often in the Kotlin/Java setting.
This is why we took a radical approach and made Kotlin’s type system more relaxed when it comes to Java interop: now references coming from Java have specially marked types -- Kotlin Blog
It's the notation for platform types:
T! means "T or T?"
Platform Types
The type names or class names ending with single exclamation mark ! are called platform types in Kotlin. You find them when you are working in Kotlin with old Java code that doesn't contain nullability information.
Examples:
Nullable Information: Nullable Type
#Nullable String in Java is considered as String? by Kotlin.
Non-null Information: Non-null Type
#NotNull String in Java is considered as String by Kotlin.
No Information: Platform Type
String without annotations in Java is considered as String! by Kotlin.
How to deal with Platform Types?
You can work with a platform type either as a nullable or a non-null. The compiler will allow you to call all methods on this type. It’s your responsibility how to use them. If you know that the value can be null, you should compare it with null before you call methods on it. If you know it’s not null, you can use it directly but as in Java, you’ll get exception if your assumption about the nullability is wrong.
Note that you can't declare platform types in Kotlin code, they come only from Java code.
Inheritance and Platform Types
While overriding Java methods in Kotlin code, you have the option to declare parameters and return types as nullable or non-null. You need to choose this wisely, because if you decide to make the parameters non-null, the Kotlin compiler generates non-null assertions for these non-null parameters. And when next time you access this Kotlin code back from Java and you pass a null value, you'll get exception.
Hope that helps clearing all your doubts about Platform Types.
A Type notated with ! is called platform type, which is a type coming from Java and thus can most probably be null. It’s what the Kotlin compiler infers by default when calling Java (for the most basic cases, Java methods can be annotated to get around this). You should handle platform types as nullable types, unless you certainly know that the particular API will never return null. The compiler allows platform types to be assigned to variables of both nullable and non-null types.
Notation for Platform Types
[...]
T! means "T or T?" [...]
You could refer to platform types as "types of unknown nullability". Also important to know is that you cannot use the exclamation-marked type for your own types, it's not part of the Kotlin syntax, it's only a notation.
I use the funny interpretation to remember those things as below:
?: I dont know whether it is null or not.
!: Be careful! This might be null.
!!: Be careful, and yes I know it. This is always not null.
I've seen it a few times especially when using Java APIs
As mentioned by s1m0nw1, T! means T or T?. The next question is: what is T?? This is nicely documented at https://kotlinlang.org/docs/reference/null-safety.html. Kotlin does not allow certain elements to be null, e.g. String, unlike Java
To allow nulls, we can declare a variable as nullable string, written
String?:
var b: String? = "abc"
b = null // ok
[...]
b?.length
This returns b.length if b is not null, and null otherwise. The type of this expression is Int?.
Excerpt from Platform Types in Kotlin :
Besides explicitly specifying a type as optional (e.g. Person?), Kotlin presents us with another beast, called Platform Type, specified by putting a single exclamation mark instead (e.g. Person!). This concept has been created for compatibility reasons, when accessing code from null-unsafe platforms like Java. It is often the case that when using a Java library, many methods return SomeType!, since the Kotlin compiler cannot infer if the result is nullable or not.
For example:
(Mutable)Collection<T>!
Just means the following: "Java collection of T may be mutable or not, may be nullable or not".
Hope this helps.

Must Kotlin Local Functions be Declared Before Use

In this simple code example...
fun testLocalFunctions() {
aLocalFun() //compiler error: unresolved reference at aLocalFun
fun aLocalFun() {}
aLocalFun() //no error
}
Elsewhere in the language, using a function before definition is allowed. But for local functions, that does not appear to be the case. Refering to the Kotlin Language Specification, the section on Local Functions is still marked "TODO".
Since this sort of constraint does not hold for other types of functions (top-level and member functions), is this a bug?
(Granted, local variable declarations must occur before use, so the same constraint on local functions is not unreasonable. Is there a definitive, preferably authoritative source document that discusses this behavior?)
It's not a bug, it is the designed behavior.
When you use a symbol (variable, type or function name) in an expression, the symbol is resolved against some scope. If we simplify the scheme, the scope is formed by the package, the imports, the outer declarations (e.g. other members of the type) and, if the expression is placed inside a function, the scope also includes the local declarations that precede the expression.
So, you can't use a local function until it's declared just like you cannot use a local variable that is not declared up to that point: it's just out of scope.

PhpStorm: Highlight variables with no known type?

PhpStorm does a great job of reading type hints and inferring types of variables from their usage. But it gives no warning when it cannot determine a reasonable type for a variable. The obvious downside is if you use a variable in a way thats illegal when it doesn't know the type it will never raise a warning.
Is it possible to raise a warning or highlight a variable if it cannot determine the type of it? The fix would be add an explicit type hint or missing return annotations.

How to check the type of a variable

I need to verify a variable is a certain type.
Is there a way to check the type of a variable in Ada?
I've tried looking at Ada attributes but didn't see anything.
Ada is a strongly typed language so there is really no need to have a function to return the variable's type, as there is in Python or Ruby (duck typed languages) because when you declare a variable you specify its type. The program already knows its type.
If a variable X is declared with type T'Class, then the type of the actual value can be T or any type derived from T. In that case, you can use X'Tag to get the tag of the value's actual type, which is the closest you can come to getting the actual type. Once you have a tag, you can do things like getting the type's name (there are functions for this in Ada.Tags), comparing it to the tag of some type to see if it's that type, etc. But Integer is not a tagged type, so you can't use 'Tag on it and there would be no use for it because it is a primitive type.

How to get the name of the variable the pointer is pointing to in LLVM

I have a pointer to an array or to a variable. I want to get the name of that array or variable. How to get this in LLVM?
I am trying to instrument a function to which an array or variable is passed through pointer. I want to get the name of that array or variable argument. I am instrumenting my functions using LLVM.
You need to use debug information for that, because otherwise names from the original C code do not get represented in LLVM IR, in the general case. See the debug info document. In particular, look in the sections about "#llvm.dbg.declare" and "Global Value Descriptors"