Files
kotlin-fork/compiler/testData/diagnostics
Alexander Udalov 456ba79793 Consider callable reference's LHS when resolving RHS
Previous resolution sequence (static scope, nested classes scope, receiver) and
a check against type parameters only made sense when there's a type, not an
expression, on the LHS of a callable reference. Also TransientReceiver is
incorrect in such case because private-to-this visibility check only works for
ExpressionReceiver values
2016-06-19 12:45:22 +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:

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