Files
kotlin-fork/compiler/testData/diagnostics
Denis Zharkov fc5217f7fc Fix signature clash problems caused by special built-ins
Do not treat members with already changed signature as a reason
to create a hidden copy

See tests for clarification:
- There are `charAt` method in B that has different name in Kotlin - `get`,
  i.e. relevant descriptor has initialSignatureDescriptor != null
- When collecting methods from supertypes, `charAt` from A is also get
  transformed to `get`
- So it has effectively the same signature as B.get (already declared)
- If by an accident B.get had been declared with Kotlin signature
  we would have add A.charAt (after transformation) with special flag:
  HiddenToOvercomeSignatureClash (hides it from resolution)
- But here B.charAt was artificially changed to `get`, so no signature clash
  actually happened

 #KT-13730 Fixed
2016-09-09 16:33:32 +03:00
..

Diagnostic tests format specification

Each diagnostic test consists of a single .kt file containing the code of one or several Kotlin or Java source files. Each diagnostic, be it a warning or an error, is marked in the following way:

<!DIAGNOSTIC_FACTORY_NAME!>element<!>

where DIAGNOSTIC_FACTORY_NAME is the name of the diagnostic which is usually one of the constants in one of Errors* classes.

To test not only the presence of the diagnostic but also the arguments which will be rendered to the user, provide string representations of all of them in the parentheses delimited with ; after the diagnostic name:

return <!TYPE_MISMATCH(String; Nothing)!>"OK"<!>

Note: if you're unsure what text should be added for the parameters, just leave the parentheses empty and the failed test will present the actual values in the assertion message.

Directives

Several directives can be added to the beginning of a test file with the following syntax:

// !DIRECTIVE

1. DIAGNOSTICS

This directive allows to exclude some irrelevant diagnostics (e.g. unused parameter) from a certain test, or to test only a specific set of diagnostics.

The syntax is

'([ + - ! ] DIAGNOSTIC_FACTORY_NAME | ERROR | WARNING | INFO ) +'

where

  • + means 'include';

  • - means 'exclude';

  • ! means 'exclude everything but this'.

    Directives are applied in the order of appearance, i.e. !FOO +BAR means include only FOO and BAR.

Usage:

// !DIAGNOSTICS: -WARNING +CAST_NEVER_SUCCEEDS

// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE

2. CHECK_TYPE

The directive adds the following declarations to the file:

fun <T> checkSubtype(t: T) = t

class Inv<T>
fun <E> Inv<E>._() {}
infix fun <T> T.checkType(f: Inv<T>.() -> Unit) {}

With that, an exact type of an expression can be checked in the following way:

fun test(expr: A) {
   expr checkType { _<A>() }
}

Usage:

// !CHECK_TYPE

3. FILE

The directive lets you compose a test consisting of several files in one actual file.

Usage:

// FILE: A.java
/* Java code */

// FILE: B.kt
/* Kotlin code */

4. LANGUAGE

This directive lets you enable or disable certain language features. Language features are named as enum entries of the class LanguageFeature. Each feature can be enabled with + or disabled with -.

Usage:

// !LANGUAGE: -TopLevelSealedInheritance

// !LANGUAGE: +TypeAliases -LocalDelegatedProperties