{ <EOL> val testingPairs = mapOf ( Double . NaN to Double . NaN , Double . POSITIVE_INFINITY to Double . POSITIVE_INFINITY , Double . NEGATIVE_INFINITY to Double . NEGATIVE_INFINITY , Double . fromBits ( <NUM_LIT> ) to <NUM_LIT> , Double . fromBits ( <NUM_LIT> ) to <NUM_LIT> , Double . MAX_VALUE to <NUM_LIT> , <NUM_LIT:0.0> to <NUM_LIT:0.0> , <NUM_LIT> to <NUM_LIT> , <NUM_LIT> to <NUM_LIT> , <NUM_LIT> to <NUM_LIT:3.0> , <NUM_LIT> to <NUM_LIT> , <NUM_LIT> to <NUM_LIT> , <NUM_LIT> to <NUM_LIT> , <NUM_LIT> to <NUM_LIT> ) <EOL> for ( ( x , result ) in testingPairs ) { <EOL> assertEquals ( result , cbrt ( x ) , if ( result . isFinite ( ) ) <NUM_LIT:2.0> * result . ulp else <NUM_LIT:0.0> ) <EOL> assertEquals ( cbrt ( - x ) , - cbrt ( x ) ) <EOL> } <EOL> }


{ <EOL> assertEquals ( <NUM_LIT> , hypot ( <NUM_LIT:3.0> , <NUM_LIT> ) ) <EOL> assertEquals ( Double . POSITIVE_INFINITY , hypot ( Double . NEGATIVE_INFINITY , Double . NaN ) ) <EOL> assertEquals ( Double . POSITIVE_INFINITY , hypot ( Double . NaN , Double . POSITIVE_INFINITY ) ) <EOL> assertTrue ( hypot ( Double . NaN , <NUM_LIT:0.0> ) . isNaN ( ) ) <EOL> assertEquals ( <NUM_LIT:1.0> , Double . NaN . pow ( <NUM_LIT:0.0> ) ) <EOL> assertEquals ( <NUM_LIT:1.0> , Double . POSITIVE_INFINITY . pow ( <NUM_LIT:0> ) ) <EOL> assertEquals ( <NUM_LIT> , <NUM_LIT> . pow ( <NUM_LIT:2> ) ) <EOL> assertEquals ( <NUM_LIT> , <NUM_LIT:2.0> . pow ( - <NUM_LIT:2> ) ) <EOL> assertTrue ( <NUM_LIT:0.0> . pow ( Double . NaN ) . isNaN ( ) ) <EOL> assertTrue ( Double . NaN . pow ( - <NUM_LIT:1> ) . isNaN ( ) ) <EOL> assertTrue ( ( - <NUM_LIT> ) . pow ( <NUM_LIT:1> / <NUM_LIT:3.0> ) . isNaN ( ) ) <EOL> assertTrue ( <NUM_LIT:1.0> . pow ( Double . POSITIVE_INFINITY ) . isNaN ( ) ) <EOL> assertTrue ( ( - <NUM_LIT:1.0> ) . pow ( Double . NEGATIVE_INFINITY ) . isNaN ( ) ) <EOL> assertEquals ( <NUM_LIT> , sqrt ( <NUM_LIT> + <NUM_LIT> ) ) <EOL> assertTrue ( sqrt ( - <NUM_LIT:1.0> ) . isNaN ( ) ) <EOL> assertTrue ( sqrt ( Double . NaN ) . isNaN ( ) ) <EOL> assertTrue ( exp ( Double . NaN ) . isNaN ( ) ) <EOL> assertAlmostEquals ( E , exp ( <NUM_LIT:1.0> ) ) <EOL> assertEquals ( <NUM_LIT:1.0> , exp ( <NUM_LIT:0.0> ) ) <EOL> assertEquals ( <NUM_LIT:0.0> , exp ( Double . NEGATIVE_INFINITY ) ) <EOL> assertEquals ( Double . POSITIVE_INFINITY , exp ( Double . POSITIVE_INFINITY ) ) <EOL> assertEquals ( <NUM_LIT:0.0> , expm1 ( <NUM_LIT:0.0> ) ) <EOL> assertEquals ( Double . MIN_VALUE , expm1 ( Double . MIN_VALUE ) ) <EOL> assertEquals ( <NUM_LIT> , expm1 ( <NUM_LIT> ) ) <EOL> assertEquals ( - <NUM_LIT:1.0> , expm1 ( Double . NEGATIVE_INFINITY ) ) <EOL> assertEquals ( Double . POSITIVE_INFINITY , expm1 ( Double . POSITIVE_INFINITY ) ) <EOL> }


{ <EOL> assertTrue ( log ( <NUM_LIT:1.0> , Double . NaN ) . isNaN ( ) ) <EOL> assertTrue ( log ( Double . NaN , <NUM_LIT:1.0> ) . isNaN ( ) ) <EOL> assertTrue ( log ( - <NUM_LIT:1.0> , <NUM_LIT:2.0> ) . isNaN ( ) ) <EOL> assertTrue ( log ( <NUM_LIT:2.0> , - <NUM_LIT:1.0> ) . isNaN ( ) ) <EOL> assertTrue ( log ( <NUM_LIT:2.0> , <NUM_LIT:0.0> ) . isNaN ( ) ) <EOL> assertTrue ( log ( <NUM_LIT:2.0> , <NUM_LIT:1.0> ) . isNaN ( ) ) <EOL> assertTrue ( log ( Double . POSITIVE_INFINITY , Double . POSITIVE_INFINITY ) . isNaN ( ) ) <EOL> assertEquals ( - <NUM_LIT:2.0> , log ( <NUM_LIT> , <NUM_LIT:2.0> ) ) <EOL> assertEquals ( - <NUM_LIT> , log ( <NUM_LIT:2.0> , <NUM_LIT> ) ) <EOL> assertEquals ( Double . NEGATIVE_INFINITY , log ( Double . POSITIVE_INFINITY , <NUM_LIT> ) ) <EOL> assertEquals ( Double . POSITIVE_INFINITY , log ( Double . POSITIVE_INFINITY , <NUM_LIT:2.0> ) ) <EOL> assertEquals ( Double . NEGATIVE_INFINITY , log ( <NUM_LIT:0.0> , <NUM_LIT:2.0> ) ) <EOL> assertEquals ( Double . POSITIVE_INFINITY , log ( <NUM_LIT:0.0> , <NUM_LIT> ) ) <EOL> assertTrue ( ln ( Double . NaN ) . isNaN ( ) ) <EOL> assertTrue ( ln ( - <NUM_LIT:1.0> ) . isNaN ( ) ) <EOL> assertEquals ( <NUM_LIT:1.0> , ln ( E ) ) <EOL> assertEquals ( Double . NEGATIVE_INFINITY , ln ( <NUM_LIT:0.0> ) ) <EOL> assertEquals ( Double . POSITIVE_INFINITY , ln ( Double . POSITIVE_INFINITY ) ) <EOL> assertEquals ( <NUM_LIT:1.0> , log10 ( <NUM_LIT> ) ) <EOL> assertAlmostEquals ( - <NUM_LIT:1.0> , log10 ( <NUM_LIT> ) ) <EOL> assertAlmostEquals ( <NUM_LIT:3.0> , log2 ( <NUM_LIT> ) ) <EOL> assertEquals ( - <NUM_LIT:1.0> , log2 ( <NUM_LIT> ) ) <EOL> assertTrue ( ln1p ( Double . NaN ) . isNaN ( ) ) <EOL> assertTrue ( ln1p ( - <NUM_LIT> ) . isNaN ( ) ) <EOL> assertEquals ( <NUM_LIT:0.0> , ln1p ( <NUM_LIT:0.0> ) ) <EOL> assertEquals ( <NUM_LIT> , ln1p ( <NUM_LIT> ) ) <EOL> assertEquals ( Double . MIN_VALUE , ln1p ( Double . MIN_VALUE ) ) <EOL> assertEquals ( Double . NEGATIVE_INFINITY , ln1p ( - <NUM_LIT:1.0> ) ) <EOL> }


{ <EOL> for ( value in listOf ( Double . NaN , Double . POSITIVE_INFINITY , Double . NEGATIVE_INFINITY , <NUM_LIT:0.0> , <NUM_LIT:1.0> , - <NUM_LIT> ) ) { <EOL> assertEquals ( value , ceil ( value ) ) <EOL> assertEquals ( value , floor ( value ) ) <EOL> assertEquals ( value , truncate ( value ) ) <EOL> assertEquals ( value , round ( value ) ) <EOL> } <EOL> val data = arrayOf ( doubleArrayOf ( <NUM_LIT> , <NUM_LIT:1.0> , <NUM_LIT:1.0> , <NUM_LIT:1.0> , <NUM_LIT:2.0> ) , doubleArrayOf ( - <NUM_LIT> , - <NUM_LIT:2.0> , - <NUM_LIT:1.0> , - <NUM_LIT:1.0> , - <NUM_LIT:1.0> ) , doubleArrayOf ( <NUM_LIT> , <NUM_LIT:1.0> , <NUM_LIT:1.0> , <NUM_LIT:2.0> , <NUM_LIT:2.0> ) , doubleArrayOf ( - <NUM_LIT> , - <NUM_LIT:2.0> , - <NUM_LIT:1.0> , - <NUM_LIT:2.0> , - <NUM_LIT:1.0> ) , doubleArrayOf ( <NUM_LIT> , <NUM_LIT:1.0> , <NUM_LIT:1.0> , <NUM_LIT:2.0> , <NUM_LIT:2.0> ) , doubleArrayOf ( - <NUM_LIT> , - <NUM_LIT:2.0> , - <NUM_LIT:1.0> , - <NUM_LIT:2.0> , - <NUM_LIT:1.0> ) , doubleArrayOf ( <NUM_LIT> , <NUM_LIT:2.0> , <NUM_LIT:2.0> , <NUM_LIT:2.0> , <NUM_LIT:3.0> ) , doubleArrayOf ( - <NUM_LIT> , - <NUM_LIT:3.0> , - <NUM_LIT:2.0> , - <NUM_LIT:2.0> , - <NUM_LIT:2.0> ) , doubleArrayOf ( <NUM_LIT> , <NUM_LIT:2.0> , <NUM_LIT:2.0> , <NUM_LIT:2.0> , <NUM_LIT:3.0> ) , doubleArrayOf ( - <NUM_LIT> , - <NUM_LIT:3.0> , - <NUM_LIT:2.0> , - <NUM_LIT:2.0> , - <NUM_LIT:2.0> ) , doubleArrayOf ( <NUM_LIT> , <NUM_LIT:2.0> , <NUM_LIT:2.0> , <NUM_LIT:3.0> , <NUM_LIT:3.0> ) , doubleArrayOf ( - <NUM_LIT> , - <NUM_LIT:3.0> , - <NUM_LIT:2.0> , - <NUM_LIT:3.0> , - <NUM_LIT:2.0> ) ) <EOL> for ( ( v , f , t , r , c ) in data ) { <EOL> assertEquals ( f , floor ( v ) , "<STR_LIT>" ) <EOL> assertEquals ( t , truncate ( v ) , "<STR_LIT>" ) <EOL> assertEquals ( r , round ( v ) , "<STR_LIT>" ) <EOL> assertEquals ( c , ceil ( v ) , "<STR_LIT>" ) <EOL> } <EOL> }


{ <EOL> assertEquals ( <NUM_LIT:1L> , <NUM_LIT:1.0> . roundToLong ( ) ) <EOL> assertEquals ( <NUM_LIT:1L> , <NUM_LIT> . roundToLong ( ) ) <EOL> assertEquals ( <NUM_LIT> , <NUM_LIT> . roundToLong ( ) ) <EOL> assertEquals ( <NUM_LIT:3L> , <NUM_LIT> . roundToLong ( ) ) <EOL> assertEquals ( - <NUM_LIT> , ( - <NUM_LIT> ) . roundToLong ( ) ) <EOL> assertEquals ( - <NUM_LIT:3L> , ( - <NUM_LIT> ) . roundToLong ( ) ) <EOL> assertEquals ( <NUM_LIT> , ( <NUM_LIT> ) . roundToLong ( ) ) <EOL> assertEquals ( Long . MAX_VALUE , Double . MAX_VALUE . roundToLong ( ) ) <EOL> assertEquals ( Long . MIN_VALUE , ( - Double . MAX_VALUE ) . roundToLong ( ) ) <EOL> assertEquals ( Long . MAX_VALUE , Double . POSITIVE_INFINITY . roundToLong ( ) ) <EOL> assertEquals ( Long . MIN_VALUE , Double . NEGATIVE_INFINITY . roundToLong ( ) ) <EOL> assertFails { Double . NaN . roundToLong ( ) } <EOL> assertEquals ( <NUM_LIT:1> , <NUM_LIT:1.0> . roundToInt ( ) ) <EOL> assertEquals ( <NUM_LIT:1> , <NUM_LIT> . roundToInt ( ) ) <EOL> assertEquals ( <NUM_LIT:2> , <NUM_LIT> . roundToInt ( ) ) <EOL> assertEquals ( <NUM_LIT:3> , <NUM_LIT> . roundToInt ( ) ) <EOL> assertEquals ( - <NUM_LIT:2> , ( - <NUM_LIT> ) . roundToInt ( ) ) <EOL> assertEquals ( - <NUM_LIT:3> , ( - <NUM_LIT> ) . roundToInt ( ) ) <EOL> assertEquals ( <NUM_LIT> , ( <NUM_LIT> ) . roundToInt ( ) ) <EOL> assertEquals ( Int . MAX_VALUE , Double . MAX_VALUE . roundToInt ( ) ) <EOL> assertEquals ( Int . MIN_VALUE , ( - Double . MAX_VALUE ) . roundToInt ( ) ) <EOL> assertEquals ( Int . MAX_VALUE , Double . POSITIVE_INFINITY . roundToInt ( ) ) <EOL> assertEquals ( Int . MIN_VALUE , Double . NEGATIVE_INFINITY . roundToInt ( ) ) <EOL> assertFails { Double . NaN . roundToInt ( ) } <EOL> }


{ <EOL> assertTrue ( abs ( Double . NaN ) . isNaN ( ) ) <EOL> assertTrue ( Double . NaN . absoluteValue . isNaN ( ) ) <EOL> for ( value in listOf ( <NUM_LIT:0.0> , Double . MIN_VALUE , <NUM_LIT> , <NUM_LIT:1.0> , <NUM_LIT> , Double . MAX_VALUE , Double . POSITIVE_INFINITY ) ) { <EOL> assertEquals ( value , value . absoluteValue ) <EOL> assertEquals ( value , ( - value ) . absoluteValue ) <EOL> assertEquals ( value , abs ( value ) ) <EOL> assertEquals ( value , abs ( - value ) ) <EOL> } <EOL> }


{ <EOL> assertTrue ( sign ( Double . NaN ) . isNaN ( ) ) <EOL> assertTrue ( Double . NaN . sign . isNaN ( ) ) <EOL> val negatives = listOf ( Double . NEGATIVE_INFINITY , - Double . MAX_VALUE , - <NUM_LIT:1.0> , - Double . MIN_VALUE ) <EOL> for ( value in negatives ) { <EOL> assertEquals ( - <NUM_LIT:1.0> , sign ( value ) ) <EOL> assertEquals ( - <NUM_LIT:1.0> , value . sign ) <EOL> } <EOL> val zeroes = listOf ( <NUM_LIT:0.0> , - <NUM_LIT:0.0> ) <EOL> for ( value in zeroes ) { <EOL> assertEquals ( value , sign ( value ) ) <EOL> assertEquals ( value , value . sign ) <EOL> } <EOL> val positives = listOf ( Double . POSITIVE_INFINITY , Double . MAX_VALUE , <NUM_LIT:1.0> , Double . MIN_VALUE ) <EOL> for ( value in positives ) { <EOL> assertEquals ( <NUM_LIT:1.0> , sign ( value ) ) <EOL> assertEquals ( <NUM_LIT:1.0> , value . sign ) <EOL> } <EOL> val allValues = negatives + positives <EOL> for ( a in allValues ) { <EOL> for ( b in allValues ) { <EOL> val r = a . withSign ( b ) <EOL> assertEquals ( a . absoluteValue , r . absoluteValue ) <EOL> assertEquals ( b . sign , r . sign , "<STR_LIT>" ) <EOL> } <EOL> val rp0 = a . withSign ( <NUM_LIT:0.0> ) <EOL> assertEquals ( <NUM_LIT:1.0> , rp0 . sign ) <EOL> assertEquals ( a . absoluteValue , rp0 . absoluteValue ) <EOL> val rm0 = a . withSign ( - <NUM_LIT:0.0> ) <EOL> assertEquals ( - <NUM_LIT:1.0> , rm0 . sign ) <EOL> assertEquals ( a . absoluteValue , rm0 . absoluteValue ) <EOL> val ri = a . withSign ( - <NUM_LIT:1> ) <EOL> assertEquals ( - <NUM_LIT:1.0> , ri . sign ) <EOL> assertEquals ( a . absoluteValue , ri . absoluteValue ) <EOL> val rn = a . withSign ( Double . NaN ) <EOL> assertEquals ( a . absoluteValue , rn . absoluteValue ) <EOL> } <EOL> }


{ <EOL> for ( value in listOf ( <NUM_LIT:0.0> , - <NUM_LIT:0.0> , Double . MIN_VALUE , - <NUM_LIT:1.0> , <NUM_LIT:2.0> . pow ( <NUM_LIT:10> ) ) ) { <EOL> val next = value . nextUp ( ) <EOL> if ( next > <NUM_LIT:0> ) { <EOL> assertEquals ( next , value + value . ulp ) <EOL> } else { <EOL> assertEquals ( value , next - next . ulp ) <EOL> } <EOL> val prev = value . nextDown ( ) <EOL> if ( prev > <NUM_LIT:0> ) { <EOL> assertEquals ( value , prev + prev . ulp ) <EOL> } else { <EOL> assertEquals ( prev , value - value . ulp ) <EOL> } <EOL> val toZero = value . nextTowards ( <NUM_LIT:0.0> ) <EOL> if ( toZero != <NUM_LIT:0.0> ) { <EOL> assertEquals ( value , toZero + toZero . ulp . withSign ( toZero ) ) <EOL> } <EOL> assertEquals ( Double . POSITIVE_INFINITY , Double . MAX_VALUE . nextUp ( ) ) <EOL> assertEquals ( Double . MAX_VALUE , Double . POSITIVE_INFINITY . nextDown ( ) ) <EOL> assertEquals ( Double . NEGATIVE_INFINITY , ( - Double . MAX_VALUE ) . nextDown ( ) ) <EOL> assertEquals ( ( - Double . MAX_VALUE ) , Double . NEGATIVE_INFINITY . nextUp ( ) ) <EOL> assertTrue ( Double . NaN . ulp . isNaN ( ) ) <EOL> assertTrue ( Double . NaN . nextDown ( ) . isNaN ( ) ) <EOL> assertTrue ( Double . NaN . nextUp ( ) . isNaN ( ) ) <EOL> assertTrue ( Double . NaN . nextTowards ( <NUM_LIT:0.0> ) . isNaN ( ) ) <EOL> assertEquals ( Double . MIN_VALUE , ( <NUM_LIT:0.0> ) . ulp ) <EOL> assertEquals ( Double . MIN_VALUE , ( - <NUM_LIT:0.0> ) . ulp ) <EOL> assertEquals ( Double . POSITIVE_INFINITY , Double . POSITIVE_INFINITY . ulp ) <EOL> assertEquals ( Double . POSITIVE_INFINITY , Double . NEGATIVE_INFINITY . ulp ) <EOL> val maxUlp = <NUM_LIT:2.0> . pow ( <NUM_LIT> ) <EOL> assertEquals ( maxUlp , Double . MAX_VALUE . ulp ) <EOL> assertEquals ( maxUlp , ( - Double . MAX_VALUE ) . ulp ) <EOL> } <EOL> }


@ Ignore <EOL> @ Test <EOL> fun floatRangeConversion ( )

{ <EOL> assertEquals ( kotlin . math . E . toFloat ( ) , E ) <EOL> assertEquals ( kotlin . math . PI . toFloat ( ) , PI ) <EOL> }


{ <EOL> assertEquals ( <NUM_LIT> , sin ( <NUM_LIT> ) ) <EOL> assertAlmostEquals ( <NUM_LIT> , sin ( PI ) ) <EOL> assertEquals ( <NUM_LIT> , asin ( <NUM_LIT> ) ) <EOL> assertAlmostEquals ( PI / <NUM_LIT:2> , asin ( <NUM_LIT> ) , <NUM_LIT> ) <EOL> assertEquals ( <NUM_LIT> , cos ( <NUM_LIT> ) ) <EOL> assertAlmostEquals ( - <NUM_LIT> , cos ( PI ) ) <EOL> assertEquals ( <NUM_LIT> , acos ( <NUM_LIT> ) ) <EOL> assertAlmostEquals ( PI / <NUM_LIT:2> , acos ( <NUM_LIT> ) ) <EOL> assertEquals ( <NUM_LIT> , tan ( <NUM_LIT> ) ) <EOL> assertAlmostEquals ( <NUM_LIT> , tan ( PI / <NUM_LIT:4> ) ) <EOL> assertAlmostEquals ( <NUM_LIT> , atan ( <NUM_LIT> ) ) <EOL> assertAlmostEquals ( PI / <NUM_LIT:4> , atan ( <NUM_LIT> ) ) <EOL> assertAlmostEquals ( PI / <NUM_LIT:4> , atan2 ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> assertAlmostEquals ( - PI / <NUM_LIT:4> , atan2 ( Float . NEGATIVE_INFINITY , Float . POSITIVE_INFINITY ) ) <EOL> assertAlmostEquals ( <NUM_LIT> , atan2 ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> assertAlmostEquals ( <NUM_LIT> , atan2 ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> assertAlmostEquals ( PI / <NUM_LIT:2> , atan2 ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> for ( angle in listOf ( Float . NaN , Float . POSITIVE_INFINITY , Float . NEGATIVE_INFINITY ) ) { <EOL> assertTrue ( sin ( angle ) . isNaN ( ) , "<STR_LIT>" ) <EOL> assertTrue ( cos ( angle ) . isNaN ( ) , "<STR_LIT>" ) <EOL> assertTrue ( tan ( angle ) . isNaN ( ) , "<STR_LIT>" ) <EOL> } <EOL> for ( value in listOf ( Float . NaN , <NUM_LIT> , - <NUM_LIT> ) ) { <EOL> assertTrue ( asin ( value ) . isNaN ( ) ) <EOL> assertTrue ( acos ( value ) . isNaN ( ) ) <EOL> } <EOL> assertTrue ( atan ( Float . NaN ) . isNaN ( ) ) <EOL> assertTrue ( atan2 ( Float . NaN , <NUM_LIT> ) . isNaN ( ) ) <EOL> assertTrue ( atan2 ( <NUM_LIT> , Float . NaN ) . isNaN ( ) ) <EOL> }


{ <EOL> assertEquals ( Float . POSITIVE_INFINITY , sinh ( Float . POSITIVE_INFINITY ) ) <EOL> assertEquals ( Float . NEGATIVE_INFINITY , sinh ( Float . NEGATIVE_INFINITY ) ) <EOL> assertTrue ( sinh ( Float . MIN_VALUE ) != <NUM_LIT> ) <EOL> assertTrue ( sinh ( <NUM_LIT> ) . isFinite ( ) ) <EOL> assertTrue ( sinh ( - <NUM_LIT> ) . isFinite ( ) ) <EOL> assertTrue ( sinh ( Float . NaN ) . isNaN ( ) ) <EOL> assertEquals ( Float . POSITIVE_INFINITY , cosh ( Float . POSITIVE_INFINITY ) ) <EOL> assertEquals ( Float . POSITIVE_INFINITY , cosh ( Float . NEGATIVE_INFINITY ) ) <EOL> assertTrue ( cosh ( <NUM_LIT> ) . isFinite ( ) ) <EOL> assertTrue ( cosh ( - <NUM_LIT> ) . isFinite ( ) ) <EOL> assertTrue ( cosh ( Float . NaN ) . isNaN ( ) ) <EOL> assertAlmostEquals ( <NUM_LIT> , tanh ( Float . POSITIVE_INFINITY ) ) <EOL> assertAlmostEquals ( - <NUM_LIT> , tanh ( Float . NEGATIVE_INFINITY ) ) <EOL> assertTrue ( tanh ( Float . MIN_VALUE ) != <NUM_LIT> ) <EOL> assertTrue ( tanh ( Float . NaN ) . isNaN ( ) ) <EOL> }


{ <EOL> for ( exact in listOf ( Float . POSITIVE_INFINITY , Float . NEGATIVE_INFINITY , <NUM_LIT> , Float . MIN_VALUE , - Float . MIN_VALUE , <NUM_LIT> ) ) { <EOL> assertEquals ( exact , asinh ( sinh ( exact ) ) ) <EOL> } <EOL> for ( approx in listOf ( Float . MIN_VALUE , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) ) { <EOL> assertAlmostEquals ( approx , asinh ( sinh ( approx ) ) ) <EOL> assertAlmostEquals ( - approx , asinh ( sinh ( - approx ) ) ) <EOL> } <EOL> assertTrue ( asinh ( Float . NaN ) . isNaN ( ) ) <EOL> }


{ <EOL> for ( exact in listOf ( Float . POSITIVE_INFINITY , Float . NEGATIVE_INFINITY , <NUM_LIT> ) ) { <EOL> assertEquals ( abs ( exact ) , acosh ( cosh ( exact ) ) ) <EOL> } <EOL> for ( approx in listOf ( Float . MIN_VALUE , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) ) { <EOL> assertAlmostEquals ( approx , acosh ( cosh ( approx ) ) ) <EOL> assertAlmostEquals ( approx , acosh ( cosh ( - approx ) ) ) <EOL> } <EOL> for ( invalid in listOf ( - <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , Float . NaN ) ) { <EOL> assertTrue ( acosh ( invalid ) . isNaN ( ) ) <EOL> } <EOL> }


{ <EOL> for ( exact in listOf ( Float . POSITIVE_INFINITY , Float . NEGATIVE_INFINITY , <NUM_LIT> , Float . MIN_VALUE , - Float . MIN_VALUE ) ) { <EOL> assertEquals ( exact , atanh ( tanh ( exact ) ) ) <EOL> } <EOL> for ( approx in listOf ( <NUM_LIT> ) ) { <EOL> assertAlmostEquals ( approx , atanh ( tanh ( approx ) ) ) <EOL> } <EOL> for ( invalid in listOf ( - <NUM_LIT> , <NUM_LIT> , Float . NaN , Float . MAX_VALUE , - Float . MAX_VALUE , Float . NEGATIVE_INFINITY , Float . POSITIVE_INFINITY ) ) { <EOL> assertTrue ( atanh ( invalid ) . isNaN ( ) ) <EOL> } <EOL> }


{ <EOL> val testingPairs = mapOf ( Float . NaN to Float . NaN , Float . POSITIVE_INFINITY to Float . POSITIVE_INFINITY , Float . NEGATIVE_INFINITY to Float . NEGATIVE_INFINITY , Float . fromBits ( <NUM_LIT> ) to <NUM_LIT> , Float . fromBits ( <NUM_LIT> ) to <NUM_LIT> , Float . MAX_VALUE to <NUM_LIT> , <NUM_LIT:0.0f> to <NUM_LIT:0.0f> , <NUM_LIT> to <NUM_LIT> , <NUM_LIT> to <NUM_LIT> , <NUM_LIT> to <NUM_LIT> , <NUM_LIT> to <NUM_LIT> , <NUM_LIT> to <NUM_LIT> , <NUM_LIT> to <NUM_LIT> , <NUM_LIT> to <NUM_LIT> ) <EOL> for ( ( x , result ) in testingPairs ) { <EOL> assertEquals ( result , cbrt ( x ) , if ( result . isFinite ( ) ) <NUM_LIT> * result . ulpCommon else <NUM_LIT:0.0f> ) <EOL> assertEquals ( cbrt ( - x ) , - cbrt ( x ) ) <EOL> } <EOL> }


{ <EOL> assertEquals ( <NUM_LIT> , hypot ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> assertEquals ( Float . POSITIVE_INFINITY , hypot ( Float . NEGATIVE_INFINITY , Float . NaN ) ) <EOL> assertEquals ( Float . POSITIVE_INFINITY , hypot ( Float . NaN , Float . POSITIVE_INFINITY ) ) <EOL> assertTrue ( hypot ( Float . NaN , <NUM_LIT> ) . isNaN ( ) ) <EOL> assertEquals ( <NUM_LIT> , Float . NaN . pow ( <NUM_LIT> ) ) <EOL> assertEquals ( <NUM_LIT> , Float . POSITIVE_INFINITY . pow ( <NUM_LIT:0> ) ) <EOL> assertEquals ( <NUM_LIT> , <NUM_LIT> . pow ( <NUM_LIT:2> ) ) <EOL> assertEquals ( <NUM_LIT> , <NUM_LIT> . pow ( - <NUM_LIT:2> ) ) <EOL> assertTrue ( <NUM_LIT> . pow ( Float . NaN ) . isNaN ( ) ) <EOL> assertTrue ( Float . NaN . pow ( - <NUM_LIT:1> ) . isNaN ( ) ) <EOL> assertTrue ( ( - <NUM_LIT> ) . pow ( <NUM_LIT:1> / <NUM_LIT> ) . isNaN ( ) ) <EOL> assertTrue ( <NUM_LIT> . pow ( Float . POSITIVE_INFINITY ) . isNaN ( ) ) <EOL> assertTrue ( ( - <NUM_LIT> ) . pow ( Float . NEGATIVE_INFINITY ) . isNaN ( ) ) <EOL> assertEquals ( <NUM_LIT> , sqrt ( <NUM_LIT> + <NUM_LIT> ) ) <EOL> assertTrue ( sqrt ( - <NUM_LIT> ) . isNaN ( ) ) <EOL> assertTrue ( sqrt ( Float . NaN ) . isNaN ( ) ) <EOL> assertTrue ( exp ( Float . NaN ) . isNaN ( ) ) <EOL> assertAlmostEquals ( kotlin . math . E . toFloat ( ) , exp ( <NUM_LIT> ) ) <EOL> assertEquals ( <NUM_LIT> , exp ( <NUM_LIT> ) ) <EOL> assertEquals ( <NUM_LIT> , exp ( Float . NEGATIVE_INFINITY ) ) <EOL> assertEquals ( Float . POSITIVE_INFINITY , exp ( Float . POSITIVE_INFINITY ) ) <EOL> assertEquals ( <NUM_LIT> , expm1 ( <NUM_LIT> ) ) <EOL> assertEquals ( - <NUM_LIT> , expm1 ( Float . NEGATIVE_INFINITY ) ) <EOL> assertEquals ( Float . POSITIVE_INFINITY , expm1 ( Float . POSITIVE_INFINITY ) ) <EOL> }


{ <EOL> assertTrue ( log ( <NUM_LIT> , Float . NaN ) . isNaN ( ) ) <EOL> assertTrue ( log ( Float . NaN , <NUM_LIT> ) . isNaN ( ) ) <EOL> assertTrue ( log ( - <NUM_LIT> , <NUM_LIT> ) . isNaN ( ) ) <EOL> assertTrue ( log ( <NUM_LIT> , - <NUM_LIT> ) . isNaN ( ) ) <EOL> assertTrue ( log ( <NUM_LIT> , <NUM_LIT> ) . isNaN ( ) ) <EOL> assertTrue ( log ( <NUM_LIT> , <NUM_LIT> ) . isNaN ( ) ) <EOL> assertTrue ( log ( Float . POSITIVE_INFINITY , Float . POSITIVE_INFINITY ) . isNaN ( ) ) <EOL> assertEquals ( - <NUM_LIT> , log ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> assertEquals ( - <NUM_LIT> , log ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> assertEquals ( Float . NEGATIVE_INFINITY , log ( Float . POSITIVE_INFINITY , <NUM_LIT> ) ) <EOL> assertEquals ( Float . POSITIVE_INFINITY , log ( Float . POSITIVE_INFINITY , <NUM_LIT> ) ) <EOL> assertEquals ( Float . NEGATIVE_INFINITY , log ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> assertEquals ( Float . POSITIVE_INFINITY , log ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> assertTrue ( ln ( Float . NaN ) . isNaN ( ) ) <EOL> assertTrue ( ln ( - <NUM_LIT> ) . isNaN ( ) ) <EOL> assertAlmostEquals ( <NUM_LIT> , ln ( E ) ) <EOL> assertEquals ( Float . NEGATIVE_INFINITY , ln ( <NUM_LIT> ) ) <EOL> assertEquals ( Float . POSITIVE_INFINITY , ln ( Float . POSITIVE_INFINITY ) ) <EOL> assertEquals ( <NUM_LIT> , log10 ( <NUM_LIT> ) ) <EOL> assertAlmostEquals ( - <NUM_LIT> , log10 ( <NUM_LIT> ) ) <EOL> assertAlmostEquals ( <NUM_LIT> , log2 ( <NUM_LIT> ) ) <EOL> assertEquals ( - <NUM_LIT> , log2 ( <NUM_LIT> ) ) <EOL> assertTrue ( ln1p ( Float . NaN ) . isNaN ( ) ) <EOL> assertTrue ( ln1p ( - <NUM_LIT> ) . isNaN ( ) ) <EOL> assertEquals ( <NUM_LIT> , ln1p ( <NUM_LIT> ) ) <EOL> assertEquals ( Float . NEGATIVE_INFINITY , ln1p ( - <NUM_LIT> ) ) <EOL> }


{ <EOL> for ( value in listOf ( Float . NaN , Float . POSITIVE_INFINITY , Float . NEGATIVE_INFINITY , <NUM_LIT> , <NUM_LIT> , - <NUM_LIT> ) ) { <EOL> assertEquals ( value , ceil ( value ) ) <EOL> assertEquals ( value , floor ( value ) ) <EOL> assertEquals ( value , truncate ( value ) ) <EOL> assertEquals ( value , round ( value ) ) <EOL> } <EOL> val data = arrayOf ( floatArrayOf ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) , floatArrayOf ( - <NUM_LIT> , - <NUM_LIT> , - <NUM_LIT> , - <NUM_LIT> , - <NUM_LIT> ) , floatArrayOf ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) , floatArrayOf ( - <NUM_LIT> , - <NUM_LIT> , - <NUM_LIT> , - <NUM_LIT> , - <NUM_LIT> ) , floatArrayOf ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) , floatArrayOf ( - <NUM_LIT> , - <NUM_LIT> , - <NUM_LIT> , - <NUM_LIT> , - <NUM_LIT> ) , floatArrayOf ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) , floatArrayOf ( - <NUM_LIT> , - <NUM_LIT> , - <NUM_LIT> , - <NUM_LIT> , - <NUM_LIT> ) , floatArrayOf ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) , floatArrayOf ( - <NUM_LIT> , - <NUM_LIT> , - <NUM_LIT> , - <NUM_LIT> , - <NUM_LIT> ) , floatArrayOf ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) , floatArrayOf ( - <NUM_LIT> , - <NUM_LIT> , - <NUM_LIT> , - <NUM_LIT> , - <NUM_LIT> ) ) <EOL> for ( ( v , f , t , r , c ) in data ) { <EOL> assertEquals ( f , floor ( v ) , "<STR_LIT>" ) <EOL> assertEquals ( t , truncate ( v ) , "<STR_LIT>" ) <EOL> assertEquals ( r , round ( v ) , "<STR_LIT>" ) <EOL> assertEquals ( c , ceil ( v ) , "<STR_LIT>" ) <EOL> } <EOL> }


{ <EOL> assertEquals ( <NUM_LIT:1L> , <NUM_LIT> . roundToLong ( ) ) <EOL> assertEquals ( <NUM_LIT:1L> , <NUM_LIT> . roundToLong ( ) ) <EOL> assertEquals ( <NUM_LIT> , <NUM_LIT> . roundToLong ( ) ) <EOL> assertEquals ( <NUM_LIT:3L> , <NUM_LIT> . roundToLong ( ) ) <EOL> assertEquals ( - <NUM_LIT> , ( - <NUM_LIT> ) . roundToLong ( ) ) <EOL> assertEquals ( - <NUM_LIT:3L> , ( - <NUM_LIT> ) . roundToLong ( ) ) <EOL> assertEquals ( Long . MAX_VALUE , Float . MAX_VALUE . roundToLong ( ) ) <EOL> assertEquals ( Long . MIN_VALUE , ( - Float . MAX_VALUE ) . roundToLong ( ) ) <EOL> assertEquals ( Long . MAX_VALUE , Float . POSITIVE_INFINITY . roundToLong ( ) ) <EOL> assertEquals ( Long . MIN_VALUE , Float . NEGATIVE_INFINITY . roundToLong ( ) ) <EOL> assertFails { Float . NaN . roundToLong ( ) } <EOL> assertEquals ( <NUM_LIT:1> , <NUM_LIT> . roundToInt ( ) ) <EOL> assertEquals ( <NUM_LIT:1> , <NUM_LIT> . roundToInt ( ) ) <EOL> assertEquals ( <NUM_LIT:2> , <NUM_LIT> . roundToInt ( ) ) <EOL> assertEquals ( <NUM_LIT:3> , <NUM_LIT> . roundToInt ( ) ) <EOL> assertEquals ( - <NUM_LIT:2> , ( - <NUM_LIT> ) . roundToInt ( ) ) <EOL> assertEquals ( - <NUM_LIT:3> , ( - <NUM_LIT> ) . roundToInt ( ) ) <EOL> assertEquals ( <NUM_LIT> , ( <NUM_LIT> ) . roundToInt ( ) ) <EOL> assertEquals ( Int . MAX_VALUE , Float . MAX_VALUE . roundToInt ( ) ) <EOL> assertEquals ( Int . MIN_VALUE , ( - Float . MAX_VALUE ) . roundToInt ( ) ) <EOL> assertEquals ( Int . MAX_VALUE , Float . POSITIVE_INFINITY . roundToInt ( ) ) <EOL> assertEquals ( Int . MIN_VALUE , Float . NEGATIVE_INFINITY . roundToInt ( ) ) <EOL> assertFails { Float . NaN . roundToInt ( ) } <EOL> }


{ <EOL> assertTrue ( abs ( Float . NaN ) . isNaN ( ) ) <EOL> assertTrue ( Float . NaN . absoluteValue . isNaN ( ) ) <EOL> for ( value in listOf ( <NUM_LIT> , Float . MIN_VALUE , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , Float . MAX_VALUE , Float . POSITIVE_INFINITY ) ) { <EOL> assertEquals ( value , value . absoluteValue ) <EOL> assertEquals ( value , ( - value ) . absoluteValue ) <EOL> assertEquals ( value , abs ( value ) ) <EOL> assertEquals ( value , abs ( - value ) ) <EOL> } <EOL> }


{ <EOL> assertTrue ( sign ( Float . NaN ) . isNaN ( ) ) <EOL> assertTrue ( Float . NaN . sign . isNaN ( ) ) <EOL> val negatives = listOf ( Float . NEGATIVE_INFINITY , - Float . MAX_VALUE , - <NUM_LIT> , - Float . MIN_VALUE ) <EOL> for ( value in negatives ) { <EOL> assertEquals ( - <NUM_LIT> , sign ( value ) ) <EOL> assertEquals ( - <NUM_LIT> , value . sign ) <EOL> } <EOL> val zeroes = listOf ( <NUM_LIT> , - <NUM_LIT> ) <EOL> for ( value in zeroes ) { <EOL> assertEquals ( value , sign ( value ) ) <EOL> assertEquals ( value , value . sign ) <EOL> } <EOL> val positives = listOf ( Float . POSITIVE_INFINITY , Float . MAX_VALUE , <NUM_LIT> , Float . MIN_VALUE ) <EOL> for ( value in positives ) { <EOL> assertEquals ( <NUM_LIT> , sign ( value ) ) <EOL> assertEquals ( <NUM_LIT> , value . sign ) <EOL> } <EOL> val allValues = negatives + positives <EOL> for ( a in allValues ) { <EOL> for ( b in allValues ) { <EOL> val r = a . withSign ( b ) <EOL> assertEquals ( a . absoluteValue , r . absoluteValue ) <EOL> assertEquals ( b . sign , r . sign ) <EOL> } <EOL> val rp0 = a . withSign ( <NUM_LIT> ) <EOL> assertEquals ( <NUM_LIT> , rp0 . sign ) <EOL> assertEquals ( a . absoluteValue , rp0 . absoluteValue ) <EOL> val rm0 = a . withSign ( - <NUM_LIT> ) <EOL> assertEquals ( - <NUM_LIT> , rm0 . sign ) <EOL> assertEquals ( a . absoluteValue , rm0 . absoluteValue ) <EOL> val ri = a . withSign ( - <NUM_LIT:1> ) <EOL> assertEquals ( - <NUM_LIT> , ri . sign ) <EOL> assertEquals ( a . absoluteValue , ri . absoluteValue ) <EOL> } <EOL> }


{ <EOL> val negatives = listOf ( Int . MIN_VALUE , - <NUM_LIT> , - <NUM_LIT:1> ) <EOL> val positives = listOf ( <NUM_LIT:1> , <NUM_LIT:100> , <NUM_LIT> , Int . MAX_VALUE ) <EOL> negatives . forEach { assertEquals ( - <NUM_LIT:1> , it . sign ) } <EOL> positives . forEach { assertEquals ( <NUM_LIT:1> , it . sign ) } <EOL> assertEquals ( <NUM_LIT:0> , <NUM_LIT:0> . sign ) <EOL> ( negatives - Int . MIN_VALUE ) . forEach { assertEquals ( - it , it . absoluteValue ) } <EOL> assertEquals ( Int . MIN_VALUE , Int . MIN_VALUE . absoluteValue ) <EOL> positives . forEach { assertEquals ( it , it . absoluteValue ) } <EOL> }


{ <EOL> val negatives = listOf ( Long . MIN_VALUE , - <NUM_LIT> , - <NUM_LIT:1L> ) <EOL> val positives = listOf ( <NUM_LIT:1L> , <NUM_LIT> , <NUM_LIT> , Long . MAX_VALUE ) <EOL> negatives . forEach { assertEquals ( - <NUM_LIT:1> , it . sign ) } <EOL> positives . forEach { assertEquals ( <NUM_LIT:1> , it . sign ) } <EOL> assertEquals ( <NUM_LIT:0> , <NUM_LIT:0L> . sign ) <EOL> ( negatives - Long . MIN_VALUE ) . forEach { assertEquals ( - it , it . absoluteValue ) } <EOL> assertEquals ( Long . MIN_VALUE , Long . MIN_VALUE . absoluteValue ) <EOL> positives . forEach { assertEquals ( it , it . absoluteValue ) } <EOL> }


override fun matches ( startIndex : Int , testString : CharSequence , matchResult : MatchResultImpl ) : Int

{ <EOL> if ( children . isEmpty ( ) ) { <EOL> return - <NUM_LIT:1> <EOL> } <EOL> val oldStart = matchResult . getStart ( groupIndex ) <EOL> matchResult . setStart ( groupIndex , startIndex ) <EOL> children . forEach { <EOL> val shift = it . matches ( startIndex , testString , matchResult ) <EOL> if ( shift >= <NUM_LIT:0> ) { <EOL> return shift <EOL> } <EOL> } <EOL> matchResult . setStart ( groupIndex , oldStart ) <EOL> return - <NUM_LIT:1> <EOL> }

/**
 * Returns startIndex+shift, the next position to match
 */


override fun first ( set : AbstractSet ) : Boolean

= children . any { it . first ( set ) }


override fun hasConsumed ( matchResult : MatchResultImpl ) : Boolean

{ <EOL> return ! ( matchResult . getEnd ( groupIndex ) >= <NUM_LIT:0> && matchResult . getStart ( groupIndex ) == matchResult . getEnd ( groupIndex ) ) <EOL> }


override fun processSecondPassInternal ( ) : AbstractSet

{ <EOL> val fSet = this . fSet <EOL> if ( ! fSet . secondPassVisited ) { <EOL> val newFSet = fSet . processSecondPass ( ) <EOL> @ OptIn ( ExperimentalNativeApi :: class ) <EOL> assert ( newFSet == fSet ) <EOL> } <EOL> @ OptIn ( ExperimentalNativeApi :: class ) <EOL> children . replaceAll { child -> if ( ! child . secondPassVisited ) child . processSecondPass ( ) else child } <EOL> return super . processSecondPassInternal ( ) <EOL> }


{ <EOL> if ( a != "<STR_LIT>" ) { <EOL> return "<STR_LIT>" <EOL> } <EOL> if ( aa != "<STR_LIT>" ) { <EOL> return "<STR_LIT>" <EOL> } <EOL> if ( b != "<STR_LIT>" ) { <EOL> return "<STR_LIT>" <EOL> } <EOL> if ( bb != "<STR_LIT>" ) { <EOL> return "<STR_LIT>" <EOL> } <EOL> if ( c != "<STR_LIT>" ) { <EOL> return "<STR_LIT>" <EOL> } <EOL> if ( cc != "<STR_LIT>" ) { <EOL> return "<STR_LIT>" <EOL> } <EOL> return "<STR_LIT:OK>" <EOL> }


operator fun invoke ( metadata : SerializedMetadata , typeResolver : CirTypeResolver ) : CirTreeModule

{ <EOL> val module = KlibModuleMetadata . read ( SerializedMetadataLibraryProvider ( metadata ) ) <EOL> val fragmentsByPackage : Map < CirPackageName , Collection < KmModuleFragment > > = module . fragments . foldToMap { fragment -> <EOL> fragment . fqName ? . let ( CirPackageName . Companion :: create ) <EOL> ? : error ( "<STR_LIT>" ) <EOL> } <EOL> val packages = fragmentsByPackage . map { ( packageName , fragments ) -> <EOL> packageDeserializer ( packageName , fragments , typeResolver ) <EOL> } <EOL> return CirTreeModule ( module = CirModule . create ( CirName . create ( module . name ) ) , packages = packages ) <EOL> }


{ <EOL> Assumptions . assumeFalse ( targets . hostTarget . family . isAppleFamily ) <EOL> }


@ BeforeEach <EOL> fun checkAssumptions ( )

{ <EOL> `check for KT-67454` ( ) <EOL> }


{ <EOL> Assumptions . assumeFalse ( targets . hostTarget . family . isAppleFamily && targets . testTarget . family . isAppleFamily ) <EOL> Assumptions . assumeFalse ( testRunSettings . get < GCScheduler > ( ) == GCScheduler . AGGRESSIVE ) <EOL> compileSimpleFile ( listOf ( "<STR_LIT>" , "<STR_LIT>" ) ) . let { <EOL> assertFalse ( it . stdout . contains ( "<STR_LIT>" ) , "<STR_LIT>" ) <EOL> } <EOL> compileSimpleFile ( listOf ( "<STR_LIT>" , "<STR_LIT>" ) ) . let { <EOL> assertTrue ( it . stdout . contains ( "<STR_LIT>" ) , "<STR_LIT>" ) <EOL> } <EOL> }


private fun compileSimpleFile ( flags : List < String > ) : RunProcessResult

{ <EOL> val kexe = buildDir . resolve ( "<STR_LIT>" ) . also { it . delete ( ) } <EOL> val args = mutableListOf ( "<STR_LIT>" , kexe . absolutePath ) . apply { <EOL> add ( "<STR_LIT>" ) <EOL> add ( targets . testTarget . visibleName ) <EOL> addAll ( flags ) <EOL> add ( "<STR_LIT>" ) <EOL> add ( "<STR_LIT>" ) <EOL> } <EOL> val compilationResult = runProcess ( konanc . absolutePath , source . absolutePath , * args . toTypedArray < String > ( ) ) { <EOL> timeout = konancTimeout <EOL> } <EOL> testRunSettings . executor . runProcess ( kexe . absolutePath ) <EOL> return compilationResult <EOL> }


@ Test <EOL> fun testDriverProducesRunnableBinaries ( )

{ <EOL> Assumptions . assumeFalse ( HostManager . hostIsMingw && testRunSettings . get < CacheMode > ( ) == CacheMode . WithoutCache && testRunSettings . get < OptimizationMode > ( ) == OptimizationMode . DEBUG ) <EOL> val module = TestModule . Exclusive ( "<STR_LIT>" , emptySet ( ) , emptySet ( ) , emptySet ( ) ) <EOL> val kexe = buildDir . resolve ( "<STR_LIT>" ) . also { it . delete ( ) } <EOL> val compilation = ExecutableCompilation ( settings = testRunSettings , freeCompilerArgs = TestCompilerArgs . EMPTY , sourceModules = listOf ( module ) , extras = TestCase . NoTestRunnerExtras ( "<STR_LIT:main>" ) , dependencies = emptyList ( ) , expectedArtifact = TestCompilationArtifact . Executable ( kexe ) , tryPassSystemCacheDirectory = true ) <EOL> runProcess ( konanc . absolutePath , source . absolutePath , * compilation . getCompilerArgs ( ) ) { <EOL> timeout = konancTimeout <EOL> } <EOL> val runResult : RunProcessResult = with ( testRunSettings ) { <EOL> executor . runProcess ( kexe . absolutePath ) { <EOL> timeout = Duration . parse ( "<STR_LIT>" ) <EOL> } <EOL> } <EOL> assertEquals ( "<STR_LIT>" , runResult . stdout ) <EOL> }


{ <EOL> Assumptions . assumeFalse ( HostManager . hostIsMingw && testRunSettings . get < CacheMode > ( ) == CacheMode . WithoutCache && testRunSettings . get < OptimizationMode > ( ) == OptimizationMode . DEBUG ) <EOL> Assumptions . assumeFalse ( testRunSettings . get < GCScheduler > ( ) == GCScheduler . AGGRESSIVE ) <EOL> val module = TestModule . Exclusive ( "<STR_LIT>" , emptySet ( ) , emptySet ( ) , emptySet ( ) ) <EOL> val kexe = buildDir . resolve ( "<STR_LIT>" ) . also { it . delete ( ) } <EOL> val compilation = ExecutableCompilation ( settings = testRunSettings , freeCompilerArgs = TestCompilerArgs ( listOf ( "<STR_LIT>" ) ) , sourceModules = listOf ( module ) , extras = TestCase . NoTestRunnerExtras ( "<STR_LIT:main>" ) , dependencies = emptyList ( ) , expectedArtifact = TestCompilationArtifact . Executable ( kexe ) , tryPassSystemCacheDirectory = true ) <EOL> runProcess ( konanc . absolutePath , source . absolutePath , * compilation . getCompilerArgs ( ) ) { <EOL> timeout = konancTimeout <EOL> } <EOL> assertFalse ( kexe . exists ( ) ) <EOL> }


@ Test <EOL> fun testOverrideKonanProperties ( )

{ <EOL> Assumptions . assumeFalse ( HostManager . hostIsMingw && testRunSettings . get < CacheMode > ( ) == CacheMode . WithoutCache && testRunSettings . get < OptimizationMode > ( ) == OptimizationMode . DEBUG ) <EOL> Assumptions . assumeFalse ( testRunSettings . get < GCScheduler > ( ) == GCScheduler . AGGRESSIVE ) <EOL> val module = TestModule . Exclusive ( "<STR_LIT>" , emptySet ( ) , emptySet ( ) , emptySet ( ) ) <EOL> val kexe = buildDir . resolve ( "<STR_LIT>" ) . also { it . delete ( ) } <EOL> val compilation = ExecutableCompilation ( settings = testRunSettings , freeCompilerArgs = TestCompilerArgs ( listOf ( "<STR_LIT>" , "<STR_LIT>" , if ( HostManager . hostIsMingw ) "<STR_LIT>" else "<STR_LIT>" ) ) , sourceModules = listOf ( module ) , extras = TestCase . NoTestRunnerExtras ( "<STR_LIT:main>" ) , dependencies = emptyList ( ) , expectedArtifact = TestCompilationArtifact . Executable ( kexe ) , tryPassSystemCacheDirectory = true ) <EOL> val compilationResult = runProcess ( konanc . absolutePath , source . absolutePath , * compilation . getCompilerArgs ( ) ) { <EOL> timeout = konancTimeout <EOL> } <EOL> val expected = "<STR_LIT>" <EOL> assertTrue ( compilationResult . stdout . contains ( expected ) , "<STR_LIT>" + "<STR_LIT>" ) <EOL> testRunSettings . executor . runProcess ( kexe . absolutePath ) <EOL> }


override fun pretrainedModel ( modelHub : ModelHub ) : ImageRecognitionModel

{ <EOL> return ImageRecognitionModel ( modelHub . loadModel ( this ) , channelsFirst , preprocessor , this :: class . simpleName ) <EOL> }


{ <EOL> return ImageRecognitionModel ( modelHub . loadModel ( this ) , channelsFirst , preprocessor , this :: class . simpleName , classLabels = Imagenet . V1001 . labels ( ) ) <EOL> }


override fun pretrainedModel ( modelHub : ModelHub ) : SinglePoseDetectionModel

{ <EOL> return SinglePoseDetectionModel ( modelHub . loadModel ( this ) , this :: class . simpleName ) <EOL> }


override fun pretrainedModel ( modelHub : ModelHub ) : SSDLikeModel

{ <EOL> return SSDLikeModel ( modelHub . loadModel ( this ) , METADATA , this :: class . simpleName ) <EOL> }


override fun pretrainedModel ( modelHub : ModelHub ) : FaceDetectionModel

{ <EOL> return FaceDetectionModel ( modelHub . loadModel ( this ) , this :: class . simpleName ) <EOL> }


override fun pretrainedModel ( modelHub : ModelHub ) : Fan2D106FaceAlignmentModel

{ <EOL> return Fan2D106FaceAlignmentModel ( modelHub . loadModel ( this ) , this :: class . simpleName ) <EOL> }


override fun getExtensionReceiver ( ) : ReceiverValue ?

= extensionReceiver


override fun getDispatchReceiver ( ) : ReceiverValue ?

= dispatchReceiver


override fun getContextReceivers ( ) : List < ReceiverValue >

= contextReceivers


@ Suppress ( "<STR_LIT:UNCHECKED_CAST>" ) <EOL> override fun getCandidateDescriptor ( ) : D

= resolvedCallAtom . candidateDescriptor as D


override fun getResultingDescriptor ( ) : D

= resultingDescriptor


override fun getExplicitReceiverKind ( ) : ExplicitReceiverKind

= resolvedCallAtom . explicitReceiverKind


override fun updateDispatchReceiverType ( newType : KotlinType )

{ <EOL> if ( dispatchReceiver ? . type == newType ) return <EOL> dispatchReceiver = dispatchReceiver ? . replaceType ( newType ) <EOL> }


override fun updateExtensionReceiverType ( newType : KotlinType )

{ <EOL> if ( extensionReceiver ? . type == newType ) return <EOL> extensionReceiver = extensionReceiver ? . replaceType ( newType ) <EOL> }


override fun updateContextReceiverTypes ( newTypes : List < KotlinType > )

{ <EOL> if ( contextReceivers . size != newTypes . size ) return <EOL> contextReceivers = contextReceivers . zip ( newTypes ) . map { ( receiver , type ) -> receiver . replaceType ( type ) } <EOL> }


override fun getStatus ( ) : ResolutionStatus

= getResultApplicability ( diagnostics ) . toResolutionStatus ( )


override fun getTypeArguments ( ) : Map < TypeParameterDescriptor , KotlinType >

{ <EOL> val typeParameters = candidateDescriptor . typeParameters . takeIf { it . isNotEmpty ( ) } ? : return emptyMap ( ) <EOL> return typeParameters . zip ( typeArguments ) . toMap ( ) <EOL> }


override fun containsOnlyOnlyInputTypesErrors ( )

= <EOL> diagnostics . all { it is KotlinConstraintSystemDiagnostic && it . error is OnlyInputTypesDiagnostic }


override fun getSmartCastDispatchReceiverType ( ) : KotlinType ?

= smartCastDispatchReceiverType


override fun setResultingSubstitutor ( substitutor : NewTypeSubstitutor ? )

{ <EOL> updateArgumentsMapping ( null ) <EOL> updateValueArguments ( null ) <EOL> substituteReceivers ( substitutor ) <EOL> @ Suppress ( "<STR_LIT:UNCHECKED_CAST>" ) <EOL> resultingDescriptor = substitutedResultingDescriptor ( substitutor ) as D <EOL> typeArguments = freshSubstitutor . freshVariables . map { <EOL> val substituted = ( substitutor ? : FreshVariableNewTypeSubstitutor . Empty ) . safeSubstitute ( it . defaultType ) <EOL> typeApproximator <EOL> . approximateToSuperType ( substituted , TypeApproximatorConfiguration . IntegerLiteralsTypesApproximation ) <EOL> ? : substituted <EOL> } <EOL> calculateExpectedTypeForSamConvertedArgumentMap ( substitutor ) <EOL> calculateExpectedTypeForSuspendConvertedArgumentMap ( substitutor ) <EOL> calculateExpectedTypeForUnitConvertedArgumentMap ( substitutor ) <EOL> calculateExpectedTypeForConstantConvertedArgumentMap ( ) <EOL> }


override fun argumentToParameterMap ( resultingDescriptor : CallableDescriptor , valueArguments : Map < ValueParameterDescriptor , ResolvedValueArgument > , ) : Map < ValueArgument , ArgumentMatchImpl >

{ <EOL> val argumentErrors = collectErrorPositions ( ) <EOL> return LinkedHashMap < ValueArgument , ArgumentMatchImpl > ( ) . also { result -> <EOL> for ( parameter in resultingDescriptor . valueParameters ) { <EOL> val resolvedArgument = valueArguments [ parameter ] ? : continue <EOL> for ( argument in resolvedArgument . arguments ) { <EOL> val status = argumentErrors [ argument ] ? . let { <EOL> ArgumentMatchStatus . TYPE_MISMATCH <EOL> } ? : ArgumentMatchStatus . SUCCESS <EOL> result [ argument ] = ArgumentMatchImpl ( parameter ) . apply { recordMatchStatus ( status ) } <EOL> } <EOL> } <EOL> } <EOL> }


fun updateExtensionReceiverWithSmartCastIfNeeded ( smartCastExtensionReceiverType : KotlinType )

{ <EOL> if ( extensionReceiver is ImplicitClassReceiver ) { <EOL> extensionReceiver = CastImplicitClassReceiver ( ( extensionReceiver as ImplicitClassReceiver ) . classDescriptor , smartCastExtensionReceiverType , ) <EOL> } <EOL> }


fun setSmartCastDispatchReceiverType ( smartCastDispatchReceiverType : KotlinType )

{ <EOL> this . smartCastDispatchReceiverType = smartCastDispatchReceiverType <EOL> }


fun updateDiagnostics ( completedDiagnostics : Collection < KotlinCallDiagnostic > )

{ <EOL> diagnostics = completedDiagnostics <EOL> }


fun getArgumentTypeForConstantConvertedArgument ( valueArgument : ValueArgument ) : IntegerValueTypeConstant ?

{ <EOL> val expression = valueArgument . getArgumentExpression ( ) ? : return null <EOL> return argumentTypeForConstantConvertedMap ? . get ( expression ) <EOL> }


fun getExpectedTypeForSamConvertedArgument ( valueArgument : ValueArgument ) : UnwrappedType ?

= <EOL> expectedTypeForSamConvertedArgumentMap ? . get ( valueArgument )


fun getExpectedTypeForSuspendConvertedArgument ( valueArgument : ValueArgument ) : UnwrappedType ?

= <EOL> expectedTypeForSuspendConvertedArgumentMap ? . get ( valueArgument )


fun getExpectedTypeForUnitConvertedArgument ( valueArgument : ValueArgument ) : UnwrappedType ?

= <EOL> expectedTypeForUnitConvertedArgumentMap ? . get ( valueArgument )


private fun calculateExpectedTypeForConvertedArguments ( arguments : Map < KotlinCallArgument , UnwrappedType > , substitutor : NewTypeSubstitutor ? , ) : Map < ValueArgument , UnwrappedType > ?

{ <EOL> if ( arguments . isEmpty ( ) ) return null <EOL> val expectedTypeForConvertedArguments = hashMapOf < ValueArgument , UnwrappedType > ( ) <EOL> for ( ( argument , convertedType ) in arguments ) { <EOL> val typeWithFreshVariables = resolvedCallAtom . freshVariablesSubstitutor . safeSubstitute ( convertedType ) <EOL> val expectedType = substitutor ? . safeSubstitute ( typeWithFreshVariables ) ? : typeWithFreshVariables <EOL> expectedTypeForConvertedArguments [ argument . psiCallArgument . valueArgument ] = expectedType <EOL> } <EOL> return expectedTypeForConvertedArguments <EOL> }


private fun calculateExpectedTypeForConstantConvertedArgumentMap ( )

{ <EOL> if ( resolvedCallAtom . argumentsWithConstantConversion . isEmpty ( ) ) return <EOL> val expectedTypeForConvertedArguments = hashMapOf < KtExpression , IntegerValueTypeConstant > ( ) <EOL> for ( ( argument , convertedConstant ) in resolvedCallAtom . argumentsWithConstantConversion ) { <EOL> val expression = argument . psiExpression ? : continue <EOL> expectedTypeForConvertedArguments [ expression ] = convertedConstant <EOL> } <EOL> argumentTypeForConstantConvertedMap = expectedTypeForConvertedArguments <EOL> }


private fun calculateExpectedTypeForSamConvertedArgumentMap ( substitutor : NewTypeSubstitutor ? )

{ <EOL> expectedTypeForSamConvertedArgumentMap = calculateExpectedTypeForConvertedArguments ( resolvedCallAtom . argumentsWithConversion . mapValues { it . value . convertedTypeByCandidateParameter } , substitutor ) <EOL> }


private fun calculateExpectedTypeForSuspendConvertedArgumentMap ( substitutor : NewTypeSubstitutor ? )

{ <EOL> expectedTypeForSuspendConvertedArgumentMap = calculateExpectedTypeForConvertedArguments ( resolvedCallAtom . argumentsWithSuspendConversion , substitutor ) <EOL> }


private fun calculateExpectedTypeForUnitConvertedArgumentMap ( substitutor : NewTypeSubstitutor ? )

{ <EOL> expectedTypeForUnitConvertedArgumentMap = calculateExpectedTypeForConvertedArguments ( resolvedCallAtom . argumentsWithUnitConversion , substitutor ) <EOL> }


private fun collectErrorPositions ( ) : Map < ValueArgument , List < KotlinCallDiagnostic > >

{ <EOL> val result = mutableListOf < Pair < ValueArgument , KotlinCallDiagnostic > > ( ) <EOL> fun ConstraintPosition . originalPosition ( ) : ConstraintPosition = <EOL> if ( this is IncorporationConstraintPosition ) { <EOL> from . originalPosition ( ) <EOL> } else { <EOL> this <EOL> } <EOL> diagnostics . forEach { <EOL> val position = when ( val error = it . constraintSystemError ) { <EOL> is NewConstraintError -> error . position . originalPosition ( ) <EOL> is CapturedTypeFromSubtyping -> error . position . originalPosition ( ) <EOL> is ConstrainingTypeIsError -> error . position . originalPosition ( ) <EOL> else -> null <EOL> } as? ArgumentConstraintPositionImpl ? : return@forEach <EOL> val argument = ( position . argument as? PSIKotlinCallArgument ) ? . valueArgument ? : return@forEach <EOL> result += argument to it <EOL> } <EOL> return result . groupBy ( { it . first } ) { it . second } <EOL> }


fun check ( metadata1 : T , metadata2 : T , report : MetadataPropertyReport )


override fun check ( metadata1 : T , metadata2 : T , report : MetadataPropertyReport )

{ <EOL> val value1 = getProperty ( metadata1 ) <EOL> val value2 = getProperty ( metadata2 ) <EOL> if ( ! areEqual ( value1 , value2 ) ) { <EOL> report . addPropertyDiff ( NamedDiffEntry ( name , value1 , value2 ) ) <EOL> } <EOL> }


@ OptIn ( UnstableMetadataApi :: class ) <EOL> fun moduleMetadataPropertyChecker ( name : String , propertyGetter : ( KmModule ) -> String )

= <EOL> object : GenericMetadataPropertyChecker < KmModule > ( "<STR_LIT>" ) { <EOL> override fun getProperty ( node : KmModule ) = propertyGetter ( node ) <EOL> }


@ OptIn ( UnstableMetadataApi :: class ) <EOL> fun packagePartsPropertyChecker ( name : String , propertyGetter : ( KmPackageParts ) -> String )

= <EOL> object : GenericMetadataPropertyChecker < KmPackageParts > ( "<STR_LIT>" ) { <EOL> override fun getProperty ( node : KmPackageParts ) = propertyGetter ( node ) <EOL> }


fun constructorMetadataPropertyChecker ( name : String , propertyGetter : ( KmConstructor ) -> String )

= <EOL> object : GenericMetadataPropertyChecker < KmConstructor > ( "<STR_LIT>" ) { <EOL> override fun getProperty ( node : KmConstructor ) = propertyGetter ( node ) <EOL> }


fun functionMetadataPropertyChecker ( name : String , propertyGetter : ( KmFunction ) -> String )

= <EOL> object : GenericMetadataPropertyChecker < KmFunction > ( "<STR_LIT>" ) { <EOL> override fun getProperty ( node : KmFunction ) = propertyGetter ( node ) <EOL> }


fun typeAliasMetadataPropertyChecker ( name : String , propertyGetter : ( KmTypeAlias ) -> String )

= <EOL> object : GenericMetadataPropertyChecker < KmTypeAlias > ( "<STR_LIT>" ) { <EOL> override fun getProperty ( node : KmTypeAlias ) = propertyGetter ( node ) <EOL> }


fun propertyMetadataPropertyChecker ( name : String , propertyGetter : ( KmProperty ) -> String )

= <EOL> object : GenericMetadataPropertyChecker < KmProperty > ( "<STR_LIT>" ) { <EOL> override fun getProperty ( node : KmProperty ) = propertyGetter ( node ) <EOL> }


@ TestAnn ( <NUM_LIT:42> ) fun testSimpleFunction ( )


fun registerIfAbsent ( project : Project ) : Provider < KotlinNativeBundleBuildService >

= <EOL> project . gradle . sharedServices . registerIfAbsent ( "<STR_LIT>" , KotlinNativeBundleBuildService :: class . java ) { } . also { serviceProvider -> <EOL> SingleActionPerProject . run ( project , UsesKotlinNativeBundleBuildService :: class . java . name ) { <EOL> project . tasks . withType < UsesKotlinNativeBundleBuildService > ( ) . configureEach { task -> <EOL> task . kotlinNativeBundleBuildService . value ( serviceProvider ) . disallowChanges ( ) <EOL> task . usesService ( serviceProvider ) <EOL> } <EOL> } <EOL> }


internal fun prepareKotlinNativeBundle ( project : Project , kotlinNativeBundleConfiguration : ConfigurableFileCollection , kotlinNativeVersion : String , bundleDir : File , reinstallFlag : Boolean , konanTargets : Set < KonanTarget > , overriddenKonanHome : String ? , )

{ <EOL> if ( overriddenKonanHome != null ) { <EOL> project . logger . info ( "<STR_LIT>" ) <EOL> } else { <EOL> processToolchain ( bundleDir , project , reinstallFlag , kotlinNativeVersion , kotlinNativeBundleConfiguration ) <EOL> } <EOL> project . setupKotlinNativePlatformLibraries ( konanTargets ) <EOL> }

/**
 * This function downloads and installs a Kotlin Native bundle if needed
 * and then prepares its platform libraries if needed.
 *
 * @param project The Gradle project object.
 * @param kotlinNativeBundleConfiguration Gradle configuration for Kotlin Native Bundle
 * @param kotlinNativeVersion The version of Kotlin/Native to install
 * @param bundleDir The directory to store the Kotlin/Native bundle.
 * @param reinstallFlag A flag indicating whether to reinstall the bundle.
 * @param konanTargets The set of KonanTarget objects representing the targets for the Kotlin/Native bundle.
 * @param overriddenKonanHome Overridden konan home if present.
 * @return kotlin native version if toolchain was used, path to konan home if konan home was used
 */


private fun processToolchain ( bundleDir : File , project : Project , reinstallFlag : Boolean , kotlinNativeVersion : String , kotlinNativeBundleConfiguration : ConfigurableFileCollection , )

{ <EOL> val lock = <EOL> NativeDistributionCommonizerLock ( bundleDir ) { message -> project . logger . info ( "<STR_LIT>" ) } <EOL> lock . withLock { <EOL> val needToReinstall = KotlinToolingVersion ( project . konanVersion ) . maturity == KotlinToolingVersion . Maturity . SNAPSHOT <EOL> if ( needToReinstall ) { <EOL> project . logger . debug ( "<STR_LIT>" ) <EOL> } <EOL> removeBundleIfNeeded ( reinstallFlag || needToReinstall , bundleDir ) <EOL> if ( ! bundleDir . resolve ( MARKER_FILE ) . exists ( ) ) { <EOL> val gradleCachesKotlinNativeDir = <EOL> resolveKotlinNativeConfiguration ( kotlinNativeVersion , kotlinNativeBundleConfiguration ) <EOL> project . logger . info ( "<STR_LIT>" ) <EOL> fso . copy { <EOL> it . from ( gradleCachesKotlinNativeDir ) <EOL> it . into ( bundleDir ) <EOL> } <EOL> createSuccessfulInstallationFile ( bundleDir ) <EOL> project . logger . info ( "<STR_LIT>" ) <EOL> } <EOL> } <EOL> }


internal fun downloadNativeDependencies ( bundleDir : File , konanDataDir : String ? , konanTargets : Set < KonanTarget > , logger : Logger , ) : Set < String >

{ <EOL> val requiredDependencies = mutableSetOf < String > ( ) <EOL> val distribution = Distribution ( bundleDir . absolutePath , konanDataDir = konanDataDir ) <EOL> konanTargets . forEach { konanTarget -> <EOL> if ( konanTarget . enabledOnCurrentHostForBinariesCompilation ( ) ) { <EOL> val konanPropertiesLoader = loadConfigurables ( konanTarget , distribution . properties , distribution . dependenciesDir , progressCallback = { url , currentBytes , totalBytes -> <EOL> logger . info ( "<STR_LIT>" ) <EOL> } ) as KonanPropertiesLoader <EOL> requiredDependencies . addAll ( konanPropertiesLoader . dependencies ) <EOL> konanPropertiesLoader . downloadDependencies ( DependencyExtractor ( ) ) <EOL> } <EOL> } <EOL> return requiredDependencies <EOL> }

/**
 * Downloads native dependencies for Kotlin Native based on the provided configuration.
 * @return A set of required dependencies that were downloaded.
 */


private fun removeBundleIfNeeded ( reinstallFlag : Boolean , bundleDir : File , )

{ <EOL> if ( reinstallFlag && canBeReinstalled ) { <EOL> bundleDir . deleteRecursively ( ) <EOL> canBeReinstalled = false <EOL> } <EOL> }


private fun resolveKotlinNativeConfiguration ( kotlinNativeVersion : String , kotlinNativeCompilerConfiguration : ConfigurableFileCollection , ) : File

{ <EOL> val resolutionErrorMessage = "<STR_LIT>" + <EOL> "<STR_LIT>" <EOL> val gradleCachesKotlinNativeDir = kotlinNativeCompilerConfiguration <EOL> . singleOrNull ( ) <EOL> ? . resolve ( kotlinNativeVersion ) <EOL> ? : error ( resolutionErrorMessage ) <EOL> if ( ! gradleCachesKotlinNativeDir . exists ( ) ) { <EOL> throw IllegalArgumentException ( resolutionErrorMessage ) <EOL> } <EOL> return gradleCachesKotlinNativeDir <EOL> }


private fun Project . setupKotlinNativePlatformLibraries ( konanTargets : Set < KonanTarget > )

{ <EOL> val distributionType = NativeDistributionTypeProvider ( this ) . getDistributionType ( ) <EOL> if ( distributionType . mustGeneratePlatformLibs ) { <EOL> konanTargets . forEach { konanTarget -> <EOL> PlatformLibrariesGenerator ( project , konanTarget ) . generatePlatformLibsIfNeeded ( ) <EOL> } <EOL> } <EOL> }


override fun extract ( archive : File , targetDirectory : File , archiveType : ArchiveType )

{ <EOL> when ( archiveType ) { <EOL> ArchiveType . ZIP -> archiveOperations . zipTree ( archive ) <EOL> ArchiveType . TAR_GZ -> unzipTarGz ( archive , targetDirectory ) <EOL> else -> error ( "<STR_LIT>" ) <EOL> } <EOL> }


private fun unzipTarGz ( archive : File , targetDir : File )

{ <EOL> GZIPInputStream ( BufferedInputStream ( archive . inputStream ( ) ) ) . use { gzipInputStream -> <EOL> val hardLinks = HashMap < Path , Path > ( ) <EOL> TarArchiveInputStream ( gzipInputStream ) . use { tarInputStream -> <EOL> generateSequence { <EOL> tarInputStream . nextEntry <EOL> } . forEach { entry : TarArchiveEntry -> <EOL> val outputFile = File ( "<STR_LIT>" ) <EOL> if ( entry . isDirectory ) { <EOL> outputFile . mkdirs ( ) <EOL> } else { <EOL> if ( entry . isSymbolicLink ) { <EOL> Files . createSymbolicLink ( outputFile . toPath ( ) , Paths . get ( entry . linkName ) ) <EOL> } else if ( entry . isLink ) { <EOL> hardLinks . put ( outputFile . toPath ( ) , targetDir . resolve ( entry . linkName ) . toPath ( ) ) <EOL> } else { <EOL> outputFile . outputStream ( ) . use { <EOL> tarInputStream . copyTo ( it ) <EOL> } <EOL> Files . setPosixFilePermissions ( outputFile . toPath ( ) , getPosixFilePermissions ( entry . mode ) ) <EOL> } <EOL> } <EOL> } <EOL> } <EOL> hardLinks . forEach { <EOL> Files . createLink ( it . key , it . value ) <EOL> } <EOL> } <EOL> }


private fun getPosixFilePermissions ( mode : Int ) : Set < PosixFilePermission >

{ <EOL> val permissions : MutableSet < PosixFilePermission > = mutableSetOf ( ) <EOL> permissions . addPermission ( mode , <NUM_LIT> , PosixFilePermission . OWNER_READ ) <EOL> permissions . addPermission ( mode , <NUM_LIT> , PosixFilePermission . OWNER_WRITE ) <EOL> permissions . addPermission ( mode , <NUM_LIT> , PosixFilePermission . OWNER_EXECUTE ) <EOL> permissions . addPermission ( mode , <NUM_LIT> , PosixFilePermission . GROUP_READ ) <EOL> permissions . addPermission ( mode , <NUM_LIT> , PosixFilePermission . GROUP_WRITE ) <EOL> permissions . addPermission ( mode , <NUM_LIT> , PosixFilePermission . GROUP_EXECUTE ) <EOL> permissions . addPermission ( mode , <NUM_LIT> , PosixFilePermission . OTHERS_READ ) <EOL> permissions . addPermission ( mode , <NUM_LIT> , PosixFilePermission . OTHERS_WRITE ) <EOL> permissions . addPermission ( mode , <NUM_LIT> , PosixFilePermission . OTHERS_EXECUTE ) <EOL> return permissions <EOL> }


private fun MutableSet < PosixFilePermission > . addPermission ( mode : Int , permissionBitMask : Int , permission : PosixFilePermission )

{ <EOL> if ( ( mode and permissionBitMask ) > <NUM_LIT:0> ) { <EOL> add ( permission ) <EOL> } <EOL> }


private fun createSuccessfulInstallationFile ( bundleDir : File )

{ <EOL> bundleDir . resolve ( MARKER_FILE ) . createNewFile ( ) <EOL> }


override fun apply ( project : Project )

{ <EOL> MultiplePluginDeclarationDetector . detect ( project ) <EOL> project . plugins . apply ( BasePlugin :: class . java ) <EOL> check ( project == project . rootProject ) { <EOL> "<STR_LIT>" <EOL> } <EOL> val settings = project . extensions . create ( EXTENSION_NAME , D8RootExtension :: class . java , project ) <EOL> project . registerTask < D8SetupTask > ( D8SetupTask . NAME ) { <EOL> it . group = TASKS_GROUP_NAME <EOL> it . description = "<STR_LIT>" <EOL> it . configuration = project . provider { <EOL> project . configurations . detachedConfiguration ( project . dependencies . create ( it . ivyDependency ) ) <EOL> . also { conf -> conf . isTransitive = false } <EOL> } <EOL> } <EOL> project . registerTask < CleanDataTask > ( "<STR_LIT>" + CleanDataTask . NAME_SUFFIX ) { <EOL> it . cleanableStoreProvider = project . provider { settings . requireConfigured ( ) . cleanableStore } <EOL> it . group = TASKS_GROUP_NAME <EOL> it . description = "<STR_LIT>" <EOL> } <EOL> }


fun apply ( rootProject : Project ) : D8RootExtension

{ <EOL> check ( rootProject == rootProject . rootProject ) <EOL> rootProject . plugins . apply ( D8RootPlugin :: class . java ) <EOL> return rootProject . extensions . getByName ( EXTENSION_NAME ) as D8RootExtension <EOL> }


fun retrieve ( collector : FileStructureElementDiagnosticsCollector ) : FileStructureElementDiagnosticList

{ <EOL> val sessionHolder = SessionHolderImpl ( moduleComponents . session , moduleComponents . scopeSessionProvider . getScopeSession ( ) ) <EOL> val context = if ( declaration is FirFile ) { <EOL> PersistentCheckerContextFactory . createEmptyPersistenceCheckerContext ( sessionHolder ) <EOL> } else { <EOL> PersistenceContextCollector . collectContext ( sessionHolder , file , declaration ) <EOL> } <EOL> return withSourceCodeAnalysisExceptionUnwrapping { <EOL> collector . collectForStructureElement ( declaration ) { components -> <EOL> createVisitor ( context , components ) <EOL> } <EOL> } <EOL> }


abstract fun createVisitor ( context : CheckerContextForProvider , components : DiagnosticCollectorComponents ) : LLFirDiagnosticVisitor


override fun createVisitor ( context : CheckerContextForProvider , components : DiagnosticCollectorComponents ) : LLFirDiagnosticVisitor

{ <EOL> return Visitor ( declaration , context , components ) <EOL> }


override fun shouldVisitDeclaration ( declaration : FirDeclaration ) : Boolean

= when { <EOL> declaration === structureElementDeclaration -> true <EOL> insideFakeDeclaration -> true <EOL> declaration . isImplicitConstructor -> true <EOL> else -> false <EOL> }


override fun visitNestedElements ( element : FirElement )

{ <EOL> if ( element . isImplicitConstructor ) { <EOL> insideFakeDeclaration = true <EOL> try { <EOL> super . visitNestedElements ( element ) <EOL> } finally { <EOL> insideFakeDeclaration = false <EOL> } <EOL> } else { <EOL> super . visitNestedElements ( element ) <EOL> } <EOL> }


fun shouldDiagnosticsAlwaysBeCheckedOn ( firElement : FirElement )

= when ( firElement . source ? . kind ) { <EOL> KtFakeSourceElementKind . PropertyFromParameter -> true <EOL> KtFakeSourceElementKind . ImplicitConstructor -> true <EOL> else -> false <EOL> }


{ <EOL> return Visitor ( context , components ) <EOL> }


override fun visitConstructor ( constructor : FirConstructor , data : Nothing ? )

{ <EOL> super . visitConstructor ( constructor , data ) <EOL> if ( constructor is FirPrimaryConstructor ) { <EOL> for ( valueParameter in constructor . valueParameters ) { <EOL> valueParameter . correspondingProperty ? . let { <EOL> visitProperty ( it , data ) <EOL> } <EOL> } <EOL> } <EOL> }


override fun visitFile ( file : FirFile , data : Nothing ? )

{ <EOL> withAnnotationContainer ( file ) { <EOL> visitWithFile ( file ) { <EOL> file . annotations . forEach { it . accept ( this , data ) } <EOL> file . packageDirective . accept ( this , data ) <EOL> file . imports . forEach { it . accept ( this , data ) } <EOL> } <EOL> } <EOL> }


override fun visitScript ( script : FirScript , data : Nothing ? )

{ <EOL> withAnnotationContainer ( script ) { <EOL> checkElement ( script ) <EOL> withDeclaration ( script ) { <EOL> visitScriptDependentElements ( script , this , data ) <EOL> } <EOL> } <EOL> }


public fun String . toJsString ( ) : JsString

= <EOL> kotlinToJsStringAdapter ( this ) ! !


{ <EOL> assert ( "<STR_LIT>" . hashCode ( ) == "<STR_LIT>" . hashCode ( ) ) <EOL> when ( x ) { <EOL> "<STR_LIT>" , "<STR_LIT>" -> return "<STR_LIT>" <EOL> "<STR_LIT>" , "<STR_LIT>" -> return "<STR_LIT>" <EOL> } <EOL> return "<STR_LIT:other>" <EOL> }


{ <EOL> pool . close ( ) <EOL> }


@ Test <EOL> fun testInvokedExactlyOnce ( )

= runBlocking { <EOL> runStressTest ( TestChannelKind . BUFFERED_1 ) <EOL> }


@ Test <EOL> fun testInvokedExactlyOnceBroadcast ( )

= runBlocking { <EOL> runStressTest ( TestChannelKind . CONFLATED_BROADCAST ) <EOL> }


private suspend fun runStressTest ( kind : TestChannelKind )

{ <EOL> repeat ( iterations ) { <EOL> val counter = AtomicInteger ( <NUM_LIT:0> ) <EOL> val channel = kind . create < Int > ( ) <EOL> val latch = CountDownLatch ( <NUM_LIT:1> ) <EOL> val j1 = async { <EOL> latch . await ( ) <EOL> channel . close ( ) <EOL> } <EOL> val j2 = async { <EOL> latch . await ( ) <EOL> channel . invokeOnClose { counter . incrementAndGet ( ) } <EOL> } <EOL> val j3 = async { <EOL> latch . await ( ) <EOL> channel . invokeOnClose { counter . incrementAndGet ( ) } <EOL> } <EOL> latch . countDown ( ) <EOL> joinAll ( j1 , j2 , j3 ) <EOL> assertEquals ( <NUM_LIT:1> , counter . get ( ) ) <EOL> } <EOL> }


override fun set ( name : String , data : Constraint )

{ <EOL> allProperties [ name ] = data <EOL> }


override fun get ( name : String ) : Constraint ?

{ <EOL> val constraint = allProperties [ name ] <EOL> return if ( constraint != null ) { <EOL> constraint <EOL> } else { <EOL> val newConstraint = CompositeConstraint ( owner ) <EOL> neededProperties [ name ] = newConstraint <EOL> allProperties [ name ] = newConstraint <EOL> newConstraint <EOL> } <EOL> }


override operator fun plusAssign ( other : Constraint )

{ <EOL> constraints += other <EOL> }


override operator fun plusAssign ( others : Collection < Constraint > )

{ <EOL> constraints . addAll ( others ) <EOL> }


private fun getFlatConstraints ( ) : List < Constraint >

{ <EOL> return constraints . flatMap { constraint -> <EOL> if ( constraint is CompositeConstraint ) { <EOL> constraint . getFlatConstraints ( ) <EOL> } else { <EOL> listOf ( constraint ) <EOL> } <EOL> } <EOL> }


override fun resolve ( resolveAsInput : Boolean ) : Constraint

{ <EOL> val properties = if ( resolveAsInput ) neededProperties else allProperties <EOL> val resolvedConstraints = getFlatConstraints ( ) . map { it . resolve ( resolveAsInput ) } <EOL> val callableConstraints = resolvedConstraints . filterIsInstance < CallableConstraint > ( ) <EOL> return if ( properties . isNotEmpty ( ) || callableConstraints . isNotEmpty ( ) ) { <EOL> var parameterCount = - <NUM_LIT:1> <EOL> val callsCanBeUnified = callableConstraints . all { <EOL> if ( parameterCount < <NUM_LIT:0> ) { <EOL> parameterCount = it . parameterCount <EOL> } <EOL> it . parameterCount == parameterCount <EOL> } <EOL> val resultConstraint : PropertyOwnerConstraint = if ( callableConstraints . isNotEmpty ( ) && callsCanBeUnified ) { <EOL> FunctionConstraint ( owner = owner , overloads = callableConstraints . map { callable -> <EOL> FunctionConstraint . Overload ( callable . returnConstraints , List ( parameterCount ) { i -> "<STR_LIT>" to NoTypeConstraint } ) <EOL> } ) <EOL> } else { <EOL> ObjectConstraint ( owner ) . apply { <EOL> callableConstraints . forEach { <EOL> callSignatureConstraints . add ( it . resolve ( resolveAsInput ) ) <EOL> } <EOL> } <EOL> } <EOL> properties . forEach { ( name , value ) -> <EOL> resultConstraint [ name ] = value <EOL> } <EOL> resultConstraint . resolve ( resolveAsInput ) <EOL> } else { <EOL> when { <EOL> resolvedConstraints . contains ( NumberTypeConstraint ) -> NumberTypeConstraint <EOL> resolvedConstraints . contains ( BigIntTypeConstraint ) -> BigIntTypeConstraint <EOL> resolvedConstraints . contains ( BooleanTypeConstraint ) -> BooleanTypeConstraint <EOL> resolvedConstraints . contains ( StringTypeConstraint ) -> StringTypeConstraint <EOL> else -> NoTypeConstraint <EOL> } <EOL> } <EOL> }


fun get ( ) : String


= i . get ( )


{ <EOL> val mh = MethodHandles . lookup ( ) . findVirtual ( C :: class . java , "<STR_LIT>" , MethodType . methodType ( String :: class . java , I :: class . java ) ) <EOL> try { <EOL> return mh . invokeExact ( C ( ) , object : I { <EOL> override fun get ( ) : String = "<STR_LIT:Fail>" <EOL> } ) as String <EOL> } catch ( e : WrongMethodTypeException ) { <EOL> } <EOL> return mh . invoke ( C ( ) , object : I { <EOL> override fun get ( ) : String = "<STR_LIT:OK>" <EOL> } ) as String <EOL> }


{ <EOL> return "<STR_LIT:fail>" <EOL> }


abstract override fun test ( ) : String


{ <EOL> return "<STR_LIT:OK>" <EOL> }


{ <EOL> return super . test ( ) <EOL> }


{ <EOL> return TestClass2 ( ) . test ( ) <EOL> }


private fun < T : Annotation > foo ( annotationClass : Class < T > )

= w1 . getAnnotation ( annotationClass ) ? : w2 . getAnnotation ( annotationClass )


{ <EOL> val x : Any = foo ( RunsInActiveStoreMode :: class . java ) <EOL> }


= arrayOf ( A )


= when ( e ) { <EOL> E . A -> "<STR_LIT:OK>" <EOL> }


{ <EOL> return f ( E . A ) <EOL> }


{ <EOL> class C < S > { <EOL> fun f ( ) { <EOL> fun g ( t : T ) : S ? = null <EOL> } <EOL> } <EOL> }


{ <EOL> var x : String ? = "<STR_LIT>" <EOL> if ( x != null ) { <EOL> y ? . let { x != y } <EOL> x . length <EOL> } <EOL> }


fun existingMethod ( )


internal fun < T : Any > NamedDomainObjectCollection < T > . whenAdded ( condition : ( T ) -> Boolean , action : ( T ) -> Unit , )

{ <EOL> val element = find ( condition ) <EOL> if ( element != null ) { <EOL> action ( element ) <EOL> return <EOL> } <EOL> whenObjectAdded { <EOL> val addedElement = this <EOL> if ( condition ( addedElement ) ) action ( addedElement ) <EOL> } <EOL> }


{ <EOL> if ( ! ( a && b && c ) ) { <EOL> "<STR_LIT>" <EOL> } else { <EOL> "<STR_LIT>" <EOL> } <EOL> }


{ <EOL> fun < T > foo ( t : ( ) -> T ) : T = t ( ) <EOL> return foo { "<STR_LIT:OK>" } <EOL> }


{ <EOL> val current = _preHandler <EOL> if ( current !== this ) return current as Method ? <EOL> val declared = try { <EOL> Thread :: class . java . getDeclaredMethod ( "<STR_LIT>" ) . takeIf { <EOL> Modifier . isPublic ( it . modifiers ) && Modifier . isStatic ( it . modifiers ) <EOL> } <EOL> } catch ( e : Throwable ) { <EOL> null <EOL> } <EOL> _preHandler = declared <EOL> return declared <EOL> }


override fun handleException ( context : CoroutineContext , exception : Throwable )

{ <EOL> if ( Build . VERSION . SDK_INT in <NUM_LIT> .. <NUM_LIT> ) { <EOL> ( preHandler ( ) ? . invoke ( null ) as? Thread . UncaughtExceptionHandler ) <EOL> ? . uncaughtException ( Thread . currentThread ( ) , exception ) <EOL> } <EOL> }


fun getJvmModuleNameForDeserializedDescriptor ( descriptor : DeclarationDescriptor ) : String ?

{ <EOL> val parent = DescriptorUtils . getParentOfType ( descriptor , ClassOrPackageFragmentDescriptor :: class . java , false ) <EOL> when { <EOL> parent is DeserializedClassDescriptor -> { <EOL> val classProto = parent . classProto <EOL> val nameResolver = parent . c . nameResolver <EOL> return classProto . getExtensionOrNull ( JvmProtoBuf . classModuleName ) <EOL> ? . let ( nameResolver :: getString ) <EOL> ? : JvmProtoBufUtil . DEFAULT_MODULE_NAME <EOL> } <EOL> descriptor is DeserializedMemberDescriptor -> { <EOL> val source = descriptor . containerSource <EOL> if ( source is JvmPackagePartSource ) { <EOL> return source . moduleName <EOL> } <EOL> } <EOL> } <EOL> return null <EOL> }


@ PublishedApi <EOL> internal actual inline fun < T : Any > dataTypeOf ( type : KClass < out T > ) : DataType

= <EOL> when ( type ) { <EOL> Byte :: class -> ByteDataType <EOL> Short :: class -> ShortDataType <EOL> Int :: class -> IntDataType <EOL> Long :: class -> LongDataType <EOL> Float :: class -> FloatDataType <EOL> Double :: class -> DoubleDataType <EOL> ComplexFloat :: class -> ComplexFloatDataType <EOL> ComplexDouble :: class , NativeComplexDouble :: class -> ComplexDoubleDataType <EOL> else -> throw IllegalStateException ( "<STR_LIT>" ) <EOL> }


fun Project . addAllBuildRepositories ( )

{ <EOL> val kotlinVersion = rootProject . defaultVersionCatalog . versions . devKotlin <EOL> repositories { <EOL> mavenCentral ( ) <EOL> gradlePluginPortal ( ) <EOL> maven ( "<STR_LIT>" ) <EOL> for ( teamcity in listOf ( INTERNAL_KOTLIN_TEAMCITY , PUBLIC_KOTLIN_TEAMCITY ) ) { <EOL> val locator = "<STR_LIT>" <EOL> maven ( "<STR_LIT>" ) <EOL> } <EOL> val m2LocalPath = file ( "<STR_LIT>" ) <EOL> if ( m2LocalPath . exists ( ) ) { <EOL> maven ( m2LocalPath . toURI ( ) ) <EOL> } <EOL> } <EOL> }


internal fun CirProvided . ClassOrTypeAliasType . toCirClassOrTypeAliasTypeOrNull ( classifiers : CirProvidedClassifiers ) : CirClassOrTypeAliasType ?

{ <EOL> return when ( this ) { <EOL> is CirProvided . ClassType -> this . toCirClassTypeOrNull ( classifiers ) <EOL> is CirProvided . TypeAliasType -> this . toCirTypeAliasTypeOrNull ( classifiers ) <EOL> } <EOL> }


internal fun CirProvided . TypeAliasType . toCirTypeAliasTypeOrNull ( classifiers : CirProvidedClassifiers ) : CirTypeAliasType ?

{ <EOL> val typeAlias = classifiers . classifier ( classifierId ) as? CirProvided . TypeAlias ? : return null <EOL> return CirTypeAliasType . createInterned ( typeAliasId = classifierId , isMarkedNullable = isMarkedNullable , arguments = arguments . map { it . toCirTypeProjectionOrNull ( classifiers ) ? : return null } , underlyingType = typeAlias . underlyingType . toCirClassOrTypeAliasTypeOrNull ( classifiers ) ? : return null ) <EOL> }


internal fun CirProvided . ClassType . toCirClassTypeOrNull ( classifiers : CirProvidedClassifiers ) : CirClassType ?

{ <EOL> return CirClassType . createInterned ( classId = classifierId , outerType = outerType ? . let { it . toCirClassTypeOrNull ( classifiers ) ? : return null } , isMarkedNullable = isMarkedNullable , arguments = arguments . map { it . toCirTypeProjectionOrNull ( classifiers ) ? : return null } , ) <EOL> }


internal fun CirProvided . TypeProjection . toCirTypeProjectionOrNull ( classifiers : CirProvidedClassifiers ) : CirTypeProjection ?

{ <EOL> return when ( this ) { <EOL> is CirProvided . StarTypeProjection -> CirStarTypeProjection <EOL> is CirProvided . RegularTypeProjection -> this . toCirRegularTypeProjectionOrNull ( classifiers ) <EOL> } <EOL> }


internal fun CirProvided . RegularTypeProjection . toCirRegularTypeProjectionOrNull ( classifiers : CirProvidedClassifiers ) : CirRegularTypeProjection ?

{ <EOL> return CirRegularTypeProjection ( projectionKind = variance , type = when ( val type = type ) { <EOL> is CirProvided . ClassOrTypeAliasType -> type . toCirClassOrTypeAliasTypeOrNull ( classifiers ) ? : return null <EOL> is CirProvided . TypeParameterType -> CirTypeParameterType . createInterned ( type . index , type . isMarkedNullable ) <EOL> } ) <EOL> }


public fun < R > foo ( x : MutableCollection < in R > , block : ( ) -> R )

{ <EOL> x . add ( block ( ) ) <EOL> }


abstract fun foo ( )


= fun ( ) { }


override fun remove ( element : Any ? ) : Boolean

{ <EOL> return true <EOL> }


override fun removeAll ( elements : Collection < Any > ) : Boolean

{ <EOL> return false <EOL> }


{ <EOL> return <NUM_LIT:1> <EOL> }


{ <EOL> return <NUM_LIT:10> <EOL> }


{ <EOL> a . size <EOL> a . first ( ) <EOL> a . last ( ) <EOL> a . add ( <NUM_LIT:1> ) <EOL> a . add ( null ) <EOL> a . remove ( <NUM_LIT:1> ) <EOL> a . remove ( null ) <EOL> b . size <EOL> b . first ( ) <EOL> b . last ( ) <EOL> b . add ( <NUM_LIT:1> ) <EOL> b . add ( null ) <EOL> b . remove ( null ) <EOL> }


override fun conversionDefinitelyNotNeeded ( candidate : ResolutionCandidate , argument : KotlinCallArgument , expectedParameterType : UnwrappedType ) : Boolean

{ <EOL> val callComponents = candidate . callComponents <EOL> if ( ! callComponents . languageVersionSettings . supportsFeature ( LanguageFeature . SamConversionPerArgument ) ) return true <EOL> if ( expectedParameterType . isNothing ( ) ) return true <EOL> if ( expectedParameterType . isFunctionType ) return true <EOL> val samConversionOracle = callComponents . samConversionOracle <EOL> if ( ! callComponents . languageVersionSettings . supportsFeature ( LanguageFeature . SamConversionForKotlinFunctions ) ) { <EOL> if ( ! samConversionOracle . shouldRunSamConversionForFunction ( candidate . resolvedCall . candidateDescriptor ) ) return true <EOL> } <EOL> val declarationDescriptor = expectedParameterType . constructor . declarationDescriptor <EOL> if ( declarationDescriptor is ClassDescriptor && declarationDescriptor . isDefinitelyNotSamInterface ) return true <EOL> return false <EOL> }


override fun conversionIsNeededBeforeSubtypingCheck ( argument : KotlinCallArgument , areSuspendOnlySamConversionsSupported : Boolean ) : Boolean

{ <EOL> return when ( argument ) { <EOL> is SubKotlinCallArgument -> { <EOL> val stableType = argument . receiver . stableType <EOL> if ( stableType . isFunctionType || ( areSuspendOnlySamConversionsSupported && stableType . isFunctionOrKFunctionTypeWithAnySuspendability ) ) return true <EOL> hasNonAnalyzedLambdaAsReturnType ( argument . callResult . subResolvedAtoms , stableType ) <EOL> } <EOL> is SimpleKotlinCallArgument -> argument . receiver . stableType . run { <EOL> isFunctionType || ( areSuspendOnlySamConversionsSupported && isFunctionOrKFunctionTypeWithAnySuspendability ) <EOL> } <EOL> is LambdaKotlinCallArgument , is CallableReferenceKotlinCallArgument -> true <EOL> else -> false <EOL> } <EOL> }


private fun hasNonAnalyzedLambdaAsReturnType ( subResolvedAtoms : List < ResolvedAtom > ? , type : UnwrappedType ) : Boolean

{ <EOL> subResolvedAtoms ? . forEach { <EOL> if ( it is LambdaWithTypeVariableAsExpectedTypeAtom ) { <EOL> if ( it . expectedType . constructor == type . constructor ) return true <EOL> } <EOL> val hasNonAnalyzedLambda = hasNonAnalyzedLambdaAsReturnType ( it . subResolvedAtoms , type ) <EOL> if ( hasNonAnalyzedLambda ) return true <EOL> } <EOL> return false <EOL> }


override fun conversionIsNeededAfterSubtypingCheck ( argument : KotlinCallArgument ) : Boolean

{ <EOL> return argument is SimpleKotlinCallArgument && argument . receiver . stableType . isFunctionTypeOrSubtype <EOL> }


override fun convertParameterType ( candidate : ResolutionCandidate , argument : KotlinCallArgument , parameter : ParameterDescriptor , expectedParameterType : UnwrappedType ) : UnwrappedType ?

{ <EOL> val callComponents = candidate . callComponents <EOL> val originalExpectedType = argument . getExpectedType ( parameter . original , callComponents . languageVersionSettings ) <EOL> val convertedTypeByCandidate = <EOL> callComponents . samConversionResolver . getFunctionTypeForPossibleSamType ( expectedParameterType , callComponents . samConversionOracle ) ? : return null <EOL> val convertedTypeByOriginal = <EOL> if ( expectedParameterType . constructor == originalExpectedType . constructor ) <EOL> callComponents . samConversionResolver . getFunctionTypeForPossibleSamType ( originalExpectedType , callComponents . samConversionOracle ) <EOL> else <EOL> convertedTypeByCandidate <EOL> assert ( convertedTypeByCandidate . constructor == convertedTypeByOriginal ? . constructor ) { <EOL> "<STR_LIT>" + <EOL> "<STR_LIT>" + <EOL> "<STR_LIT>" <EOL> } <EOL> candidate . resolvedCall . registerArgumentWithSamConversion ( argument , SamConversionDescription ( convertedTypeByOriginal ! ! , convertedTypeByCandidate , expectedParameterType ) ) <EOL> if ( needCompatibilityResolveForSAM ( candidate , expectedParameterType ) ) { <EOL> candidate . markCandidateForCompatibilityResolve ( ) <EOL> } <EOL> val samDescriptor = originalExpectedType . constructor . declarationDescriptor <EOL> if ( samDescriptor is ClassDescriptor ) { <EOL> callComponents . lookupTracker . record ( candidate . scopeTower . location , samDescriptor , SAM_LOOKUP_NAME ) <EOL> } <EOL> return convertedTypeByCandidate <EOL> }


private fun needCompatibilityResolveForSAM ( candidate : ResolutionCandidate , typeToConvert : UnwrappedType ) : Boolean

{ <EOL> val descriptor = typeToConvert . constructor . declarationDescriptor <EOL> if ( descriptor is ClassDescriptor && descriptor . isFun ) return false <EOL> return ! candidate . callComponents . samConversionOracle . isJavaApplicableCandidate ( candidate . resolvedCall . candidateDescriptor ) <EOL> }


fun isJavaParameterCanBeConverted ( candidate : ResolutionCandidate , expectedParameterType : UnwrappedType ) : Boolean

{ <EOL> val callComponents = candidate . callComponents <EOL> val samConversionOracle = callComponents . samConversionOracle <EOL> if ( ! samConversionOracle . isJavaApplicableCandidate ( candidate . resolvedCall . candidateDescriptor ) ) return false <EOL> val declarationDescriptor = expectedParameterType . constructor . declarationDescriptor <EOL> if ( declarationDescriptor is ClassDescriptor && declarationDescriptor . isDefinitelyNotSamInterface ) return false <EOL> val convertedType = <EOL> callComponents . samConversionResolver . getFunctionTypeForPossibleSamType ( expectedParameterType , callComponents . samConversionOracle ) <EOL> return convertedType != null <EOL> }


fun foo ( x : ( suspend ( ) -> Unit ) ? ) : ( suspend ( ) -> Unit ) ?


override fun foo ( x : ( suspend ( ) -> Unit ) ? )

= x


= runTest { <EOL> expect ( <NUM_LIT:1> ) <EOL> val state = MutableStateFlow < Int ? > ( <NUM_LIT:0> ) <EOL> val job = launch ( start = CoroutineStart . UNDISPATCHED ) { <EOL> expect ( <NUM_LIT:2> ) <EOL> assertFailsWith < CancellationException > { <EOL> state . collect { value -> <EOL> when ( value ) { <EOL> <NUM_LIT:0> -> expect ( <NUM_LIT:3> ) <EOL> <NUM_LIT:1> -> expect ( <NUM_LIT:5> ) <EOL> null -> expect ( <NUM_LIT:8> ) <EOL> <NUM_LIT:2> -> expect ( <NUM_LIT:10> ) <EOL> else -> expectUnreached ( ) <EOL> } <EOL> } <EOL> } <EOL> expect ( <NUM_LIT:12> ) <EOL> } <EOL> expect ( <NUM_LIT:4> ) <EOL> state . value = <NUM_LIT:1> <EOL> assertEquals ( <NUM_LIT:1> , state . value ) <EOL> yield ( ) <EOL> expect ( <NUM_LIT:6> ) <EOL> state . value = <NUM_LIT:1> <EOL> yield ( ) <EOL> expect ( <NUM_LIT:7> ) <EOL> state . value = null <EOL> assertNull ( state . value ) <EOL> yield ( ) <EOL> expect ( <NUM_LIT:9> ) <EOL> state . value = <NUM_LIT:2> <EOL> assertEquals ( <NUM_LIT:2> , state . value ) <EOL> yield ( ) <EOL> expect ( <NUM_LIT:11> ) <EOL> job . cancel ( ) <EOL> yield ( ) <EOL> finish ( <NUM_LIT> ) <EOL> }


@ Test <EOL> fun testEqualsConflation ( )

= runTest { <EOL> expect ( <NUM_LIT:1> ) <EOL> val state = MutableStateFlow ( Data ( <NUM_LIT:0> ) ) <EOL> val job = launch ( start = CoroutineStart . UNDISPATCHED ) { <EOL> expect ( <NUM_LIT:2> ) <EOL> assertFailsWith < CancellationException > { <EOL> state . collect { value -> <EOL> when ( value . i ) { <EOL> <NUM_LIT:0> -> expect ( <NUM_LIT:3> ) <EOL> <NUM_LIT:2> -> expect ( <NUM_LIT:5> ) <EOL> <NUM_LIT:4> -> expect ( <NUM_LIT:7> ) <EOL> else -> error ( "<STR_LIT>" ) <EOL> } <EOL> } <EOL> } <EOL> expect ( <NUM_LIT:9> ) <EOL> } <EOL> state . value = Data ( <NUM_LIT:1> ) <EOL> state . value = Data ( <NUM_LIT:0> ) <EOL> yield ( ) <EOL> state . value = Data ( <NUM_LIT:3> ) <EOL> state . value = Data ( <NUM_LIT:2> ) <EOL> expect ( <NUM_LIT:4> ) <EOL> yield ( ) <EOL> state . value = Data ( <NUM_LIT:2> ) <EOL> yield ( ) <EOL> state . value = Data ( <NUM_LIT:5> ) <EOL> state . value = Data ( <NUM_LIT:4> ) <EOL> expect ( <NUM_LIT:6> ) <EOL> yield ( ) <EOL> expect ( <NUM_LIT:8> ) <EOL> job . cancel ( ) <EOL> yield ( ) <EOL> finish ( <NUM_LIT:10> ) <EOL> }


= runTest { <EOL> val s = CounterModel ( ) <EOL> launch { <EOL> val sum = s . counter . take ( <NUM_LIT:11> ) . sum ( ) <EOL> assertEquals ( <NUM_LIT> , sum ) <EOL> } <EOL> repeat ( <NUM_LIT:10> ) { <EOL> yield ( ) <EOL> s . inc ( ) <EOL> } <EOL> }


{ <EOL> _counter . value ++ <EOL> }


@ Test <EOL> public fun testOnSubscriptionWithException ( )

= runTest { <EOL> expect ( <NUM_LIT:1> ) <EOL> val state = MutableStateFlow ( "<STR_LIT:A>" ) <EOL> state <EOL> . onSubscription { <EOL> emit ( "<STR_LIT>" ) <EOL> state . value = "<STR_LIT:A>" <EOL> } <EOL> . onSubscription { <EOL> emit ( "<STR_LIT>" ) <EOL> state . value = "<STR_LIT:B>" <EOL> throw TestException ( ) <EOL> } <EOL> . onStart { <EOL> emit ( "<STR_LIT>" ) <EOL> state . value = "<STR_LIT:C>" <EOL> } <EOL> . onStart { <EOL> emit ( "<STR_LIT>" ) <EOL> state . value = "<STR_LIT:D>" <EOL> } <EOL> . onEach { <EOL> when ( it ) { <EOL> "<STR_LIT>" -> expect ( <NUM_LIT:2> ) <EOL> "<STR_LIT>" -> expect ( <NUM_LIT:3> ) <EOL> "<STR_LIT>" -> expect ( <NUM_LIT:4> ) <EOL> "<STR_LIT>" -> expect ( <NUM_LIT:5> ) <EOL> else -> expectUnreached ( ) <EOL> } <EOL> } <EOL> . catch { e -> <EOL> assertIs < TestException > ( e ) <EOL> expect ( <NUM_LIT:6> ) <EOL> } <EOL> . launchIn ( this ) <EOL> . join ( ) <EOL> assertEquals ( <NUM_LIT:0> , state . subscriptionCount . value ) <EOL> finish ( <NUM_LIT:7> ) <EOL> }


{ <EOL> val state = MutableStateFlow ( String ) <EOL> assertSame ( state , ( state as Flow < * > ) . cancellable ( ) ) <EOL> assertSame ( state , ( state as Flow < * > ) . distinctUntilChanged ( ) ) <EOL> assertSame ( state , ( state as Flow < * > ) . flowOn ( Dispatchers . Default ) ) <EOL> assertSame ( state , ( state as Flow < * > ) . conflate ( ) ) <EOL> assertSame ( state , state . buffer ( Channel . CONFLATED ) ) <EOL> assertSame ( state , state . buffer ( Channel . RENDEZVOUS ) ) <EOL> }


@ Test <EOL> fun testResetUnsupported ( )

{ <EOL> val state = MutableStateFlow ( <NUM_LIT:42> ) <EOL> assertFailsWith < UnsupportedOperationException > { state . resetReplayCache ( ) } <EOL> assertEquals ( <NUM_LIT:42> , state . value ) <EOL> assertEquals ( listOf ( <NUM_LIT:42> ) , state . replayCache ) <EOL> }


= runTest { <EOL> val state = MutableStateFlow ( <NUM_LIT:0> ) <EOL> state . update { it + <NUM_LIT:2> } <EOL> assertEquals ( <NUM_LIT:2> , state . value ) <EOL> state . update { it + <NUM_LIT:3> } <EOL> assertEquals ( <NUM_LIT:5> , state . value ) <EOL> }


@ Test <EOL> fun testSubscriptionByFirstSuspensionInStateFlow ( )

= runTest { <EOL> testSubscriptionByFirstSuspensionInCollect ( MutableStateFlow ( <NUM_LIT:0> ) ) { value = it ; yield ( ) } <EOL> }


{ <EOL> global = S ( "<STR_LIT>" ) <EOL> assertEquals ( S ( "<STR_LIT:42>" ) , S :: nonNullTest . call ( S ( "<STR_LIT:42>" ) ) ) <EOL> assertEquals ( S ( "<STR_LIT:42>" ) , S ( "<STR_LIT:42>" ) :: nonNullTest . call ( ) ) <EOL> assertEquals ( S ( "<STR_LIT:42>" ) , S :: nonNullTest . getter . call ( S ( "<STR_LIT:42>" ) ) ) <EOL> assertEquals ( S ( "<STR_LIT:42>" ) , S ( "<STR_LIT:42>" ) :: nonNullTest . getter . call ( ) ) <EOL> S :: nonNullTest . setter . call ( S ( "<STR_LIT:42>" ) , S ( "<STR_LIT>" ) ) <EOL> assertEquals ( S ( "<STR_LIT>" ) , global ) <EOL> S ( "<STR_LIT:42>" ) :: nonNullTest . setter . call ( S ( "<STR_LIT>" ) ) <EOL> assertEquals ( S ( "<STR_LIT>" ) , global ) <EOL> global = S ( "<STR_LIT>" ) <EOL> assertEquals ( S ( "<STR_LIT:42>" ) , S :: nullableTest . call ( S ( "<STR_LIT:42>" ) ) ) <EOL> assertEquals ( S ( "<STR_LIT:42>" ) , S ( "<STR_LIT:42>" ) :: nullableTest . call ( ) ) <EOL> assertEquals ( S ( "<STR_LIT:42>" ) , S :: nullableTest . getter . call ( S ( "<STR_LIT:42>" ) ) ) <EOL> assertEquals ( S ( "<STR_LIT:42>" ) , S ( "<STR_LIT:42>" ) :: nullableTest . getter . call ( ) ) <EOL> S :: nullableTest . setter . call ( S ( "<STR_LIT:42>" ) , S ( "<STR_LIT>" ) ) <EOL> assertEquals ( S ( "<STR_LIT>" ) , global ) <EOL> S ( "<STR_LIT:42>" ) :: nullableTest . setter . call ( S ( "<STR_LIT>" ) ) <EOL> assertEquals ( S ( "<STR_LIT>" ) , global ) <EOL> global = S ( "<STR_LIT>" ) <EOL> assertEquals ( S ( "<STR_LIT:42>" ) , Z :: nonNullTest . call ( Z ( <NUM_LIT:42> ) ) ) <EOL> assertEquals ( S ( "<STR_LIT:42>" ) , Z ( <NUM_LIT:42> ) :: nonNullTest . call ( ) ) <EOL> assertEquals ( S ( "<STR_LIT:42>" ) , Z :: nonNullTest . getter . call ( Z ( <NUM_LIT:42> ) ) ) <EOL> assertEquals ( S ( "<STR_LIT:42>" ) , Z ( <NUM_LIT:42> ) :: nonNullTest . getter . call ( ) ) <EOL> Z :: nonNullTest . setter . call ( Z ( <NUM_LIT:42> ) , S ( "<STR_LIT>" ) ) <EOL> assertEquals ( S ( "<STR_LIT>" ) , global ) <EOL> Z ( <NUM_LIT:42> ) :: nonNullTest . setter . call ( S ( "<STR_LIT>" ) ) <EOL> assertEquals ( S ( "<STR_LIT>" ) , global ) <EOL> global = S ( "<STR_LIT>" ) <EOL> assertEquals ( S ( "<STR_LIT:42>" ) , Z :: nullableTest . call ( Z ( <NUM_LIT:42> ) ) ) <EOL> assertEquals ( S ( "<STR_LIT:42>" ) , Z ( <NUM_LIT:42> ) :: nullableTest . call ( ) ) <EOL> assertEquals ( S ( "<STR_LIT:42>" ) , Z :: nullableTest . getter . call ( Z ( <NUM_LIT:42> ) ) ) <EOL> assertEquals ( S ( "<STR_LIT:42>" ) , Z ( <NUM_LIT:42> ) :: nullableTest . getter . call ( ) ) <EOL> Z :: nullableTest . setter . call ( Z ( <NUM_LIT:42> ) , S ( "<STR_LIT>" ) ) <EOL> assertEquals ( S ( "<STR_LIT>" ) , global ) <EOL> Z ( <NUM_LIT:42> ) :: nullableTest . setter . call ( S ( "<STR_LIT>" ) ) <EOL> assertEquals ( S ( "<STR_LIT>" ) , global ) <EOL> global = S ( "<STR_LIT>" ) <EOL> assertEquals ( S ( "<STR_LIT:42>" ) , A :: nonNullTest . call ( A ( <NUM_LIT:42> ) ) ) <EOL> assertEquals ( S ( "<STR_LIT:42>" ) , A ( <NUM_LIT:42> ) :: nonNullTest . call ( ) ) <EOL> assertEquals ( S ( "<STR_LIT:42>" ) , A :: nonNullTest . getter . call ( A ( <NUM_LIT:42> ) ) ) <EOL> assertEquals ( S ( "<STR_LIT:42>" ) , A ( <NUM_LIT:42> ) :: nonNullTest . getter . call ( ) ) <EOL> A :: nonNullTest . setter . call ( A ( <NUM_LIT:42> ) , S ( "<STR_LIT>" ) ) <EOL> assertEquals ( S ( "<STR_LIT>" ) , global ) <EOL> A ( <NUM_LIT:42> ) :: nonNullTest . setter . call ( S ( "<STR_LIT>" ) ) <EOL> assertEquals ( S ( "<STR_LIT>" ) , global ) <EOL> global = S ( "<STR_LIT>" ) <EOL> assertEquals ( S ( "<STR_LIT:42>" ) , A :: nullableTest . call ( A ( <NUM_LIT:42> ) ) ) <EOL> assertEquals ( S ( "<STR_LIT:42>" ) , A ( <NUM_LIT:42> ) :: nullableTest . call ( ) ) <EOL> assertEquals ( S ( "<STR_LIT:42>" ) , A :: nullableTest . getter . call ( A ( <NUM_LIT:42> ) ) ) <EOL> assertEquals ( S ( "<STR_LIT:42>" ) , A ( <NUM_LIT:42> ) :: nullableTest . getter . call ( ) ) <EOL> A :: nullableTest . setter . call ( A ( <NUM_LIT:42> ) , S ( "<STR_LIT>" ) ) <EOL> assertEquals ( S ( "<STR_LIT>" ) , global ) <EOL> A ( <NUM_LIT:42> ) :: nullableTest . setter . call ( S ( "<STR_LIT>" ) ) <EOL> assertEquals ( S ( "<STR_LIT>" ) , global ) <EOL> return "<STR_LIT:OK>" <EOL> }


fun IrElement . dumpKotlinLike ( options : String = "<STR_LIT>" ) : String

= "<STR_LIT>"


fun IrElement . dump ( normalizeNames : Boolean = false ) : String

= "<STR_LIT>"


{ <EOL> val dump : IrElement . ( ) -> String = if ( dumpStrategy == "<STR_LIT>" ) IrElement :: dumpKotlinLike else IrElement :: dump <EOL> }


{ <EOL> return this :: class . simpleName ! ! <EOL> }


= toString ( ) . hashCode ( )


= "<STR_LIT:OK>"


= A ( ) . instanceof ( )


= foo ( )


override fun doTestByMainFile ( mainFile : KtFile , mainModule : KtTestModule , testServices : TestServices )

{ <EOL> val contextElement = testServices . expressionMarkerProvider . getElementOfTypeAtCaret < KtElement > ( mainFile ) <EOL> val fragmentText = mainModule . testModule . files . single ( ) . originalFile <EOL> . run { File ( parent , "<STR_LIT>" ) } <EOL> . readText ( ) <EOL> val isBlockFragment = fragmentText . any { it == '<CHAR_LIT:\n>' } <EOL> val project = mainFile . project <EOL> val factory = KtPsiFactory ( project , markGenerated = false ) <EOL> val codeFragment = when { <EOL> isBlockFragment -> factory . createBlockCodeFragment ( fragmentText , contextElement ) <EOL> else -> factory . createExpressionCodeFragment ( fragmentText , contextElement ) <EOL> } <EOL> super . doTestByMainFile ( codeFragment , mainModule , testServices ) <EOL> }


{ <EOL> val buildee = when ( "<STR_LIT>" ) { <EOL> "<STR_LIT:true>" -> build { setTypeVariable ( TargetType ( ) ) } <EOL> "<STR_LIT:false>" -> build { } <EOL> else -> Buildee ( ) <EOL> } <EOL> checkExactType < Buildee < TargetType > > ( buildee ) <EOL> }


{ storage = value }


fun < PTV > build ( instructions : Buildee < PTV > . ( ) -> Unit ) : Buildee < PTV >

{ <EOL> return Buildee < PTV > ( ) . apply ( instructions ) <EOL> }


= Other ( )


fun foo ( x : java . io . Serializable )


{ <EOL> foo ( "<STR_LIT>" ) <EOL> }


override fun check ( resolvedCall : ResolvedCall < * > , reportOn : PsiElement , context : CallCheckerContext )

{ <EOL> val descriptor = resolvedCall . resultingDescriptor as? ConstructorDescriptor ? : return <EOL> val constructorOwner = descriptor . containingDeclaration . original <EOL> val scopeOwner = context . scope . ownerDescriptor <EOL> val actualConstructor = ( descriptor as? TypeAliasConstructorDescriptor ) ? . underlyingConstructorDescriptor ? : descriptor <EOL> if ( actualConstructor . visibility . normalize ( ) != DescriptorVisibilities . PROTECTED ) return <EOL> if ( ! DescriptorVisibilityUtils . isVisibleWithAnyReceiver ( descriptor , scopeOwner , context . languageVersionSettings ) ) return <EOL> val calleeExpression = resolvedCall . call . calleeExpression <EOL> when ( calleeExpression ) { <EOL> is KtConstructorCalleeExpression -> if ( calleeExpression . parent is KtSuperTypeCallEntry ) return <EOL> is KtConstructorDelegationReferenceExpression -> return <EOL> } <EOL> if ( scopeOwner . parentsWithSelf . any { it . original === constructorOwner } ) return <EOL> @ Suppress ( "<STR_LIT:DEPRECATION>" ) <EOL> if ( DescriptorVisibilityUtils . findInvisibleMember ( DescriptorVisibilities . FALSE_IF_PROTECTED , descriptor , scopeOwner , context . languageVersionSettings ) == actualConstructor . original ) { <EOL> context . trace . report ( Errors . PROTECTED_CONSTRUCTOR_NOT_IN_SUPER_CALL . on ( reportOn , descriptor ) ) <EOL> } <EOL> }


{ <EOL> return data . toList ( ) <EOL> }


{ <EOL> val list = ArrayList < Value > ( data . size ) <EOL> for ( item in data ) { <EOL> list . add ( item ) <EOL> } <EOL> return list <EOL> }


{ <EOL> return data . filter { filterLoad ( it ) } . count ( ) <EOL> }


{ <EOL> return data . filter { it . value % <NUM_LIT:2> == <NUM_LIT:0> } . count ( ) <EOL> }


fun filterWithLambda ( ) : List < Value >

{ <EOL> return data . filter { it . value % <NUM_LIT:2> == <NUM_LIT:0> } <EOL> }


{ <EOL> return data . map { it . toString ( ) } <EOL> }


{ <EOL> return data . count { it . value % <NUM_LIT:2> == <NUM_LIT:0> } <EOL> }


fun filterAndMapWithLambda ( ) : List < String >

{ <EOL> return data . filter { it . value % <NUM_LIT:2> == <NUM_LIT:0> } . map { it . toString ( ) } <EOL> }


fun filterAndMapWithLambdaAsSequence ( ) : List < String >

{ <EOL> return data . asSequence ( ) . filter { it . value % <NUM_LIT:2> == <NUM_LIT:0> } . map { it . toString ( ) } . toList ( ) <EOL> }


{ <EOL> return data . filter { filterLoad ( it ) } . map { mapLoad ( it ) } <EOL> }


fun filterAndMapManual ( ) : ArrayList < String >

{ <EOL> val list = ArrayList < String > ( ) <EOL> for ( it in data ) { <EOL> if ( filterLoad ( it ) ) { <EOL> val value = mapLoad ( it ) <EOL> list . add ( value ) <EOL> } <EOL> } <EOL> return list <EOL> }


{ <EOL> return data . filter { filterLoad ( it ) } <EOL> }


{ <EOL> val list = ArrayList < Value > ( ) <EOL> for ( it in data ) { <EOL> if ( filterLoad ( it ) ) <EOL> list . add ( it ) <EOL> } <EOL> return list <EOL> }


{ <EOL> var count = <NUM_LIT:0> <EOL> for ( it in data ) { <EOL> if ( filterLoad ( it ) ) <EOL> count ++ <EOL> } <EOL> return count <EOL> }


{ <EOL> return data . count { filterLoad ( it ) } <EOL> }


{ <EOL> return data . fold ( <NUM_LIT:0> ) { acc , it -> if ( filterLoad ( it ) ) acc + <NUM_LIT:1> else acc } <EOL> }


override fun putSelector ( type : Type , kotlinType : KotlinType ? , v : InstructionAdapter )

{ <EOL> value . putSelector ( value . type , value . kotlinType , v ) <EOL> StackValue . coerce ( value . type , value . kotlinType , castType , underlyingKotlinType ? : castKotlinType , v ) <EOL> StackValue . coerce ( castType , castKotlinType , type , kotlinType , v ) <EOL> }


override fun storeSelector ( topOfStackType : Type , topOfStackKotlinType : KotlinType ? , v : InstructionAdapter )

{ <EOL> value . storeSelector ( topOfStackType , topOfStackKotlinType , v ) <EOL> }


override fun putReceiver ( v : InstructionAdapter , isRead : Boolean )

{ <EOL> value . putReceiver ( v , isRead ) <EOL> }


override fun isNonStaticAccess ( isRead : Boolean ) : Boolean

{ <EOL> return value . isNonStaticAccess ( isRead ) <EOL> }


{ <EOL> stackValue . putReceiver ( v , isRead ) <EOL> }


{ <EOL> stackValue . putSelector ( type , kotlinType , v ) <EOL> leaveTasks ( stackValue ) <EOL> }


{ <EOL> lambda ( v ) <EOL> coerceTo ( type , kotlinType , v ) <EOL> }


{ <EOL> checkSubtype < Int > ( a . component1 ( ) ) <EOL> checkSubtype < String > ( a . component2 ( ) ) <EOL> }


{ <EOL> fun check ( path : String , name : String , nameNoExt : String , extension : String ) { <EOL> val p = Path ( path ) <EOL> assertEquals ( name , p . name , "<STR_LIT:name>" ) <EOL> assertEquals ( nameNoExt , p . nameWithoutExtension , "<STR_LIT>" ) <EOL> assertEquals ( extension , p . extension , "<STR_LIT>" ) <EOL> } <EOL> check ( path = "<STR_LIT>" , name = "<STR_LIT>" , nameNoExt = "<STR_LIT:aaa>" , extension = "<STR_LIT>" ) <EOL> check ( path = "<STR_LIT:aaa>" , name = "<STR_LIT:aaa>" , nameNoExt = "<STR_LIT:aaa>" , extension = "<STR_LIT>" ) <EOL> check ( path = "<STR_LIT>" , name = "<STR_LIT>" , nameNoExt = "<STR_LIT:aaa>" , extension = "<STR_LIT>" ) <EOL> check ( path = "<STR_LIT>" , name = "<STR_LIT>" , nameNoExt = "<STR_LIT>" , extension = "<STR_LIT:aaa>" ) <EOL> check ( path = "<STR_LIT>" , name = "<STR_LIT>" , nameNoExt = "<STR_LIT:aaa>" , extension = "<STR_LIT>" ) <EOL> check ( path = "<STR_LIT>" , name = "<STR_LIT:aaa>" , nameNoExt = "<STR_LIT:aaa>" , extension = "<STR_LIT>" ) <EOL> check ( path = "<STR_LIT:/>" , name = "<STR_LIT>" , nameNoExt = "<STR_LIT>" , extension = "<STR_LIT>" ) <EOL> check ( path = "<STR_LIT>" , name = "<STR_LIT>" , nameNoExt = "<STR_LIT>" , extension = "<STR_LIT>" ) <EOL> }


@ Test <EOL> fun invariantSeparators ( )

{ <EOL> val path = Path ( "<STR_LIT>" ) / "<STR_LIT>" / "<STR_LIT>" <EOL> assertEquals ( "<STR_LIT>" , path . invariantSeparatorsPathString ) <EOL> val path2 = Path ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) <EOL> assertEquals ( "<STR_LIT>" , path2 . invariantSeparatorsPathString ) <EOL> }


{ <EOL> val dir = createTempDirectory ( ) . cleanupRecursively ( ) <EOL> val file = dir / "<STR_LIT>" <EOL> assertTrue ( file . notExists ( ) ) <EOL> file . createFile ( ) <EOL> assertTrue ( file . exists ( ) ) <EOL> assertTrue ( file . isRegularFile ( ) ) <EOL> assertFailsWith < FileAlreadyExistsException > { file . createFile ( ) } <EOL> }


@ Test <EOL> fun createParentDirectories ( )

{ <EOL> val dir = createTempDirectory ( ) . cleanupRecursively ( ) <EOL> val file = dir / "<STR_LIT>" / "<STR_LIT>" / "<STR_LIT>" <EOL> val parent = file . parent ! ! <EOL> assertTrue ( file . notExists ( ) ) <EOL> assertTrue ( parent . notExists ( ) ) <EOL> val result = file . createParentDirectories ( ) <EOL> assertTrue ( file . notExists ( ) ) <EOL> assertTrue ( parent . isDirectory ( ) ) <EOL> assertEquals ( file , result ) <EOL> file . createFile ( ) <EOL> file . createParentDirectories ( ) <EOL> assertTrue ( file . exists ( ) ) <EOL> assertTrue ( parent . isDirectory ( ) ) <EOL> }


@ Test <EOL> fun createParentDirectoriesRelativePath ( )

{ <EOL> run { <EOL> val path = Path ( "<STR_LIT>" ) <EOL> path . createParentDirectories ( ) <EOL> assertTrue ( path . toAbsolutePath ( ) . parent ! ! . isDirectory ( ) ) <EOL> } <EOL> run { <EOL> val path = Path ( "<STR_LIT>" ) <EOL> val parent = path . parent ! ! <EOL> assertTrue ( parent . notExists ( ) ) <EOL> parent . cleanupRecursively ( ) <EOL> path . createParentDirectories ( ) <EOL> assertTrue ( path . notExists ( ) ) <EOL> assertTrue ( parent . isDirectory ( ) ) <EOL> } <EOL> }


@ Test <EOL> fun createParentDirectoriesOverExistingSymlink ( )

{ <EOL> val root = createTempDirectory ( "<STR_LIT>" ) . cleanupRecursively ( ) <EOL> val dir = ( root / "<STR_LIT>" ) . createDirectory ( ) <EOL> val link = ( root / "<STR_LIT>" ) . tryCreateSymbolicLinkTo ( dir ) ? : return <EOL> val file = ( link / "<STR_LIT>" ) <EOL> file . createParentDirectories ( ) . writeText ( "<STR_LIT>" ) <EOL> assertTrue ( ( dir / "<STR_LIT>" ) . isRegularFile ( ) ) <EOL> }


@ Test <EOL> fun createTempFileDefaultDir ( )

{ <EOL> val file1 = createTempFile ( ) . cleanup ( ) <EOL> val file2 = createTempFile ( directory = null ) . cleanup ( ) <EOL> assertEquals ( file1 . parent , file2 . parent ) <EOL> }


@ Test <EOL> fun createTempDirectoryDefaultDir ( )

{ <EOL> val dir1 = createTempDirectory ( ) . cleanup ( ) <EOL> val dir2 = createTempDirectory ( directory = null ) . cleanupRecursively ( ) <EOL> val dir3 = createTempDirectory ( dir2 ) <EOL> assertEquals ( dir1 . parent , dir2 . parent ) <EOL> assertNotEquals ( dir2 . parent , dir3 . parent ) <EOL> }


{ <EOL> val root = createTempDirectory ( "<STR_LIT>" ) . cleanupRecursively ( ) <EOL> val srcFile = createTempFile ( root , "<STR_LIT:src>" ) <EOL> val dstFile = createTempFile ( root , "<STR_LIT>" ) <EOL> srcFile . writeText ( "<STR_LIT>" ) <EOL> assertFailsWith < FileAlreadyExistsException > ( "<STR_LIT>" ) { <EOL> srcFile . copyTo ( dstFile ) <EOL> } <EOL> var dst = srcFile . copyTo ( dstFile , overwrite = true ) <EOL> assertSame ( dst , dstFile ) <EOL> compareFiles ( srcFile , dst , "<STR_LIT>" ) <EOL> srcFile . copyTo ( srcFile ) <EOL> srcFile . copyTo ( srcFile , overwrite = true ) <EOL> compareFiles ( dst , srcFile , "<STR_LIT>" ) <EOL> assertTrue ( dstFile . deleteIfExists ( ) ) <EOL> dst = srcFile . copyTo ( dstFile ) <EOL> compareFiles ( srcFile , dst , "<STR_LIT>" ) <EOL> val subDst = dstFile . resolve ( "<STR_LIT>" ) <EOL> assertFailsWith < FileSystemException > { srcFile . copyTo ( subDst ) } <EOL> assertFailsWith < FileSystemException > { srcFile . copyTo ( subDst , overwrite = true ) } <EOL> assertTrue ( dstFile . deleteIfExists ( ) ) <EOL> assertFailsWith < FileSystemException > { srcFile . copyTo ( subDst ) } <EOL> dstFile . createDirectory ( ) <EOL> val child = dstFile . resolve ( "<STR_LIT>" ) . createFile ( ) <EOL> assertFailsWith < DirectoryNotEmptyException > ( "<STR_LIT>" ) { <EOL> srcFile . copyTo ( dstFile , overwrite = true ) <EOL> } <EOL> child . deleteExisting ( ) <EOL> srcFile . copyTo ( dstFile , overwrite = true ) <EOL> assertEquals ( srcFile . readText ( ) , dstFile . readText ( ) , "<STR_LIT>" ) <EOL> assertTrue ( srcFile . deleteIfExists ( ) ) <EOL> assertTrue ( dstFile . deleteIfExists ( ) ) <EOL> assertFailsWith < NoSuchFileException > { <EOL> srcFile . copyTo ( dstFile ) <EOL> } <EOL> srcFile . createDirectory ( ) <EOL> srcFile . resolve ( "<STR_LIT>" ) . writeText ( "<STR_LIT>" ) <EOL> dstFile . writeText ( "<STR_LIT>" ) <EOL> assertFailsWith < FileAlreadyExistsException > ( "<STR_LIT>" ) { <EOL> srcFile . copyTo ( dstFile ) <EOL> } <EOL> srcFile . copyTo ( dstFile , overwrite = true ) <EOL> assertTrue ( dstFile . isDirectory ( ) ) <EOL> assertTrue ( dstFile . listDirectoryEntries ( ) . isEmpty ( ) , "<STR_LIT>" ) <EOL> assertFailsWith < FileAlreadyExistsException > ( "<STR_LIT>" ) { <EOL> srcFile . copyTo ( dstFile ) <EOL> } <EOL> srcFile . copyTo ( dstFile , overwrite = true ) <EOL> assertTrue ( dstFile . isDirectory ( ) ) <EOL> assertTrue ( dstFile . listDirectoryEntries ( ) . isEmpty ( ) , "<STR_LIT>" ) <EOL> dstFile . resolve ( "<STR_LIT>" ) . writeText ( "<STR_LIT>" ) <EOL> assertFailsWith < DirectoryNotEmptyException > ( "<STR_LIT>" ) { <EOL> srcFile . copyTo ( dstFile , overwrite = true ) <EOL> } <EOL> }