Files
kotlin-fork/compiler/testData/diagnostics
Dmitry Petrov 5d9ee7efee Java 8 rules for method overrides:
- base class method wins against a (default) interface method,
so an abstract base class method should always be implemented
in a derived class;

- interface methods clash regardless of abstract/default
with possibly undefined behavior at run-time,
so a class or interface should always define its own method
for methods inherited from multiple interfaces and not from base class;

- meaningful diagnostics for class inheriting conflicting JVM signatures.
Since no override will happen under Java 8 rules,
ACCIDENTAL_OVERRIDE is misleading for this case;

- update testData.
2015-10-12 14:12:31 +03:00
..
2015-10-12 14:12:31 +03:00

Several directives can be added in the beginning of a test file in the syntax:

// !DIRECTIVE

Directives:

1. DIAGNOSTICS

Must be

'([ + - ! ] 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.

Examples:

// !DIAGNOSTICS: -WARNING +CAST_NEVER_SUCCEEDS

// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE

2. CHECK_TYPE

The directive adds the following declarations to the file:

class _<T>
fun <T> T.checkType(f: (_<T>) -> Unit) = f

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

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

Usage:

// !CHECK_TYPE

3. FILE

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

Usage:

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

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