Files
kotlin-fork/compiler/testData/diagnostics/testsWithStdLib/resolve/kt4711.kt
T
Dmitriy Novozhilov e6b5cb5216 [TD] Update diagnostics test data due to new test runners
Update includes:
- Changing syntax of `OI/`NI` tags from `<!NI;TAG!>` to `<!TAG{NI}!>`
- Fix some incorrect directives
- Change order of diagnostics in some places
- Remove ignored diagnostics from FIR test data (previously `DIAGNOSTICS` didn't work)
- Update FIR dumps in some places and add `FIR_IDENTICAL` if needed
- Replace all JAVAC_SKIP with SKIP_JAVAC directive
2020-12-16 19:52:25 +03:00

22 lines
754 B
Kotlin
Vendored

// !WITH_NEW_INFERENCE
//KT-4711 Error type with no error reported from type inference
fun main() {
val n = 100
val delta = 1.0 / n
val startTimeNanos = System.nanoTime()
// the problem sits on the next line:
val pi = 4.0.toDouble() * delta <!OVERLOAD_RESOLUTION_AMBIGUITY{OI}!>*<!> (1..n).<!TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS{OI}!>reduce<!>(
{t, i ->
val x = (i - 0.5) * delta
<!TYPE_MISMATCH{NI}, TYPE_MISMATCH{NI}, TYPE_MISMATCH{NI}!>t + 1.0 / (1.0 + x * x)<!>
})
// !!! pi has error type here
val elapseTime = (System.nanoTime() - startTimeNanos) / 1e9
println("pi_sequential_reduce $<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE{OI}!>pi<!> $n $elapseTime")
}