-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Commit
…er crashes This diagnostic is reported in rare situations when StubTypeForBuilderInference is kept as a parameter type of for loop or lambda. Before this commit, we had in K1 "Could not load module <error module>" from IrLinker instead. Related to: KT-52757, KT-53109, KT-63841, KT-64066 #KT-53478 Fixed (cherry picked from commit 678816f)
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors. | ||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. | ||
*/ | ||
|
||
package org.jetbrains.kotlin.resolve.checkers | ||
|
||
import org.jetbrains.kotlin.config.LanguageFeature | ||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor | ||
import org.jetbrains.kotlin.descriptors.ValueDescriptor | ||
import org.jetbrains.kotlin.diagnostics.Errors | ||
import org.jetbrains.kotlin.psi.KtDeclaration | ||
import org.jetbrains.kotlin.psi.KtParameter | ||
import org.jetbrains.kotlin.types.StubTypeForBuilderInference | ||
|
||
object StubForBuilderInferenceParameterTypeChecker : DeclarationChecker { | ||
override fun check(declaration: KtDeclaration, descriptor: DeclarationDescriptor, context: DeclarationCheckerContext) { | ||
if (declaration !is KtParameter || | ||
descriptor !is ValueDescriptor || | ||
descriptor.returnType !is StubTypeForBuilderInference | ||
) return | ||
if (context.languageVersionSettings.supportsFeature(LanguageFeature.NoBuilderInferenceWithoutAnnotationRestriction)) return | ||
|
||
context.trace.report(Errors.BUILDER_INFERENCE_STUB_PARAMETER_TYPE.on(declaration, declaration.nameAsSafeName)) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// ISSUE: KT-53478 | ||
// IGNORE_BACKEND_K1: ANY | ||
// Reason: red code | ||
|
||
class UncompilingClass<T : Any>( | ||
val block: (UncompilingClass<T>.() -> Unit)? = null, | ||
) { | ||
|
||
var uncompilingFun: ((T) -> Unit)? = null | ||
} | ||
|
||
fun handleInt(arg: Int) = Unit | ||
|
||
fun box(): String { | ||
val obj = UncompilingClass { | ||
uncompilingFun = { handleInt(it) } | ||
} | ||
return "OK" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// WITH_STDLIB | ||
// ISSUE: KT-64066 | ||
// IGNORE_BACKEND_K1: ANY | ||
// Reason: red code | ||
|
||
fun box(): String { | ||
val map = buildMap { | ||
put(1, 1) | ||
for (v in values) {} | ||
} | ||
if (map[1] != 1) return "FAIL" | ||
return "OK" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// ISSUE: KT-53478 | ||
|
||
class UncompilingClass<T : Any>( | ||
val block: (UncompilingClass<T>.() -> Unit)? = null, | ||
) { | ||
|
||
var uncompilingFun: ((T) -> Unit)? = null | ||
} | ||
|
||
fun handleInt(arg: Int) = Unit | ||
|
||
fun box() { | ||
val obj = UncompilingClass { | ||
uncompilingFun = { handleInt(it) } | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// ISSUE: KT-53478 | ||
|
||
class UncompilingClass<T : Any>( | ||
val block: (UncompilingClass<T>.() -> Unit)? = null, | ||
) { | ||
|
||
var uncompilingFun: ((T) -> Unit)? = null | ||
} | ||
|
||
fun handleInt(arg: Int) = Unit | ||
|
||
fun box() { | ||
val obj = UncompilingClass { | ||
uncompilingFun = <!BUILDER_INFERENCE_STUB_PARAMETER_TYPE!>{ handleInt(it) }<!> | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// WITH_STDLIB | ||
// ISSUE: KT-64066 | ||
|
||
fun box() { | ||
val map = buildMap { | ||
put(1, 1) | ||
for (v in values) {} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// WITH_STDLIB | ||
// ISSUE: KT-64066 | ||
|
||
fun box() { | ||
val map = buildMap { | ||
put(1, 1) | ||
for (<!BUILDER_INFERENCE_STUB_PARAMETER_TYPE!>v<!> in values) {} | ||
} | ||
} |