cd359a046c
CapturedType captures type projection while solving the constraint system. During the substitution type containing captured types is approximated to get rid of captured types and (for simple cases) replace them with corresponding type projections. Note that Array<Array< CapturedType(out Int) >> is (over)approximated by Array<out<Array<out Int>> See 'Mixed-site variance' by Ross Tate for details. #KT-2570 Fixed #KT-2872 Fixed #KT-3213 Fixed
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 +BARmeans include onlyFOOandBAR.
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