prompt
stringlengths 1
924
| completion
stringlengths 14
937
|
---|---|
* Depending on its magnitude, the value is rounded to an integer number of nanoseconds or milliseconds.
*
* @throws IllegalArgumentException if this [Double] value is `NaN`.
*/
@kotlin.internal.InlineOnly
public inline val Double.milliseconds: Duration get() = toDuration(DurationUnit.MILLISECONDS) | /** Returns a [Duration] equal to this [Int] number of seconds. */
@kotlin.internal.InlineOnly
public inline val Int.seconds: Duration get() = toDuration(DurationUnit.SECONDS)
/** Returns a [Duration] equal to this [Long] number of seconds. */
@kotlin.internal.InlineOnly<|endoftext|> |
}
return -1
}
override fun lastIndexOf(element: E): Int {
checkForComodification()
var i = length - 1
while (i >= 0) {
if (backing[offset + i] == element) return i
i--
}
return -1
} | override fun iterator(): MutableIterator<E> = listIterator(0)
override fun listIterator(): MutableListIterator<E> = listIterator(0)
override fun listIterator(index: Int): MutableListIterator<E> {
checkForComodification()
AbstractList.checkPositionIndex(index, length)
return Itr(this, index)
}<|endoftext|> |
fun box(): String {
val a = A(23)
assertEquals(23, a.x)
assertEquals(65, a.foo(42))
assertEquals(123, B.x)
assertEquals(265, B.foo(142))
assertEquals(365, foo(42))
assertEquals(423, bar) | assertEquals(12345, C.f())
mbar = 523
assertEquals(523, mbar)
return "OK"
}<|endoftext|> |
// if combined, we perform the more expensive normalization process
}
}
val parameters = mutableSetOf<IrTypeParameterSymbol>()
val parts = mutableListOf<Stability>()
val stack = mutableListOf<Stability>(this)
while (stack.isNotEmpty()) {
when (val stability: Stability = stack.removeAt(stack.size - 1)) { | is Stability.Combined -> {
stack.addAll(stability.elements)
}
is Stability.Certain -> {
if (!stability.stable)
return Stability.Unstable
}
is Stability.Parameter -> {
if (stability.parameter.symbol !in parameters) {
parameters.add(stability.parameter.symbol)<|endoftext|> |
if (statement.returnTypeRef.let { (it.isUnit || it.isNothing || it.isNullableNothing) }) {
statement.initializer!!.toIrStatement()
} else {
(statement.accept(this@Fir2IrVisitor, null) as? IrDeclaration)?.also {
irScript.resultProperty = (it as? IrProperty)?.symbol | }
}
}
statement is FirVariable && statement.isDestructuringDeclarationContainerVariable == true -> {
statement.convertWithOffsets { startOffset, endOffset ->
IrCompositeImpl(
startOffset, endOffset,
irBuiltIns.unitType, IrStatementOrigin.DESTRUCTURING_DECLARATION
).also {<|endoftext|> |
newOwner, original, annotations, newModality, newVisibility, isVar, newName, kind, isLateInit, isConst, isExternal,
isDelegated, isExpect, proto, nameResolver, typeTable, versionRequirementTable, containerSource
)
}
override fun isExternal() = Flags.IS_EXTERNAL_PROPERTY.get(proto.flags)
} | class DeserializedClassConstructorDescriptor(
containingDeclaration: ClassDescriptor,
original: ConstructorDescriptor?,
annotations: Annotations,
isPrimary: Boolean,
kind: CallableMemberDescriptor.Kind,
override val proto: ProtoBuf.Constructor,
override val nameResolver: NameResolver,
override val typeTable: TypeTable,<|endoftext|> |
// TARGET_BACKEND: JVM
// FULL_JDK
// WITH_STDLIB
// WITH_COROUTINES
// CHECK_TAIL_CALL_OPTIMIZATION
// JVM_ABI_K1_K2_DIFF: KT-63864
import helpers.*
import kotlin.coroutines.*
import kotlin.coroutines.intrinsics.* | fun assert(value: () -> Boolean) {}
class ChannelSegment<E>(val id: Long)
suspend fun suspendHere() = suspendCoroutineUninterceptedOrReturn<Unit> { x ->
TailCallOptimizationChecker.saveStackTrace(x)
COROUTINE_SUSPENDED
}
private const val RESULT_SUSPEND_NO_WAITER = 3<|endoftext|> |
ownerClass: ClassDescriptor
): SyntheticPropertyHolder {
val possibleGetMethodNames = possibleGetMethodNames(name)
if (possibleGetMethodNames.isEmpty()) return SyntheticPropertyHolder.EMPTY
val memberScope = ownerClass.getRefinedUnsubstitutedMemberScopeIfPossible(typeRefiner)
val getMethod = possibleGetMethodNames | .flatMap { memberScope.getContributedFunctions(it, NoLookupLocation.FROM_SYNTHETIC_SCOPE) }
.singleOrNull {
it.hasJavaOriginInHierarchy() && isGoodGetMethod(it)
} ?: return createSyntheticPropertyHolder(null, possibleGetMethodNames)<|endoftext|> |
val moduleName: org.gradle.api.provider.Property<kotlin.String>
/**
* Don't automatically include the default Kotlin/JS stdlib in compilation dependencies.
*
* Default value: true
*/
@Deprecated(message = "Only for legacy backend.", level = DeprecationLevel.WARNING)
@get:org.gradle.api.tasks.Input | val noStdlib: org.gradle.api.provider.Property<kotlin.Boolean>
/**
* Generate a source map.
*
* Default value: false
*/
@get:org.gradle.api.tasks.Input
val sourceMap: org.gradle.api.provider.Property<kotlin.Boolean>
/**<|endoftext|> |
val CONTRACT_NOT_ALLOWED: KtDiagnosticFactory1<String> by error1<KtElement, String>(SourceElementPositioningStrategies.REFERENCED_NAME_BY_QUALIFIED)
// Conventions
val NO_GET_METHOD: KtDiagnosticFactory0 by error0<KtArrayAccessExpression>(SourceElementPositioningStrategies.ARRAY_ACCESS) | val NO_SET_METHOD: KtDiagnosticFactory0 by error0<KtArrayAccessExpression>(SourceElementPositioningStrategies.ARRAY_ACCESS)
val ITERATOR_MISSING: KtDiagnosticFactory0 by error0<KtExpression>()
val HAS_NEXT_MISSING: KtDiagnosticFactory0 by error0<KtExpression>()<|endoftext|> |
fun postMessage(message: JsAny?, transfer: JsArray<JsAny> = definedExternally)
fun start()
fun close()
}
/**
* Exposes the JavaScript [BroadcastChannel](https://developer.mozilla.org/en/docs/Web/API/BroadcastChannel) to Kotlin
*/
public external open class BroadcastChannel(name: String) : EventTarget, JsAny { | open val name: String
var onmessage: ((MessageEvent) -> Unit)?
fun postMessage(message: JsAny?)
fun close()
}
/**
* Exposes the JavaScript [WorkerGlobalScope](https://developer.mozilla.org/en/docs/Web/API/WorkerGlobalScope) to Kotlin
*/<|endoftext|> |
fun <T> valuesT(map: MutableMap<Int, T>, newValue: T) {
map.<caret>compute(1) { k, v -> null }
}
fun <T : Any> valuesTNotNull(map: MutableMap<Int, T>, newValue: T) {
map.<caret>compute(1) { k, v -> null }
} | fun <T : Any> valuesTNullable(map: MutableMap<Int, T?>, newValue: T?) {
map.<caret>compute(1) { k, v -> null }
}<|endoftext|> |
classOrObjectSymbol: KtNamedClassOrObjectSymbol,
manager: PsiManager
) : super(
ktAnalysisSession = ktAnalysisSession,
ktModule = ktModule,
classOrObjectSymbol = classOrObjectSymbol,
manager = manager,
) {
val classKind = classOrObjectSymbol.classKind | require(classKind == KtClassKind.INTERFACE || classKind == KtClassKind.ANNOTATION_CLASS)
}
constructor(
classOrObject: KtClassOrObject,
ktModule: KtModule,
) : this(
classOrObjectDeclaration = classOrObject,
classOrObjectSymbolPointer = classOrObject.symbolPointerOfType(),<|endoftext|> |
get() = DFS.ifAny(superTypes, { it.getClass()?.superTypes ?: listOf() }) { it.isCollection() }
private fun IrType.isArrayOrNullableArrayOf(context: JvmBackendContext, element: IrClassifierSymbol): Boolean = | this is IrSimpleType && (isArray() || isNullableArray()) && arguments.size == 1 && element == when (val it = arguments[0]) {
is IrStarProjection -> context.irBuiltIns.anyClass
is IrTypeProjection -> if (it.variance == Variance.IN_VARIANCE) context.irBuiltIns.anyClass else it.type.classifierOrNull
}<|endoftext|> |
}
return parent.parentsWithSelf
.filterIsInstance<KtElement>()
.firstNotNullOf { it.getOrBuildFir(firResolveSession) }
}
private fun computeDefaultExpression(
defaultStatement: KtExpression,
firDefaultStatement: FirElement,
firValuedReturnExpressions: List<FirReturnExpression> | ): DefaultExpressionInfo? {
if (firDefaultStatement in firValuedReturnExpressions) {
return null
}
val defaultConeType = computeOrdinaryDefaultType(defaultStatement, firDefaultStatement)
?: computeOperationDefaultType(defaultStatement)
?: computeAssignmentTargetDefaultType(defaultStatement, firDefaultStatement)<|endoftext|> |
assertEquals(true, 7540113804746346429L > 20, "Long.compareTo(Int)")
assertEquals(false, 7540113804746346429L < 20, "Long.compareTo(Int)")
assertEquals(true, 10L < 20.toShort(), "Long.compareTo(Short)") | assertEquals(true, 7540113804746346429L > 20.toShort(), "Long.compareTo(Short)")
assertEquals(false, 7540113804746346429L < 20.toShort(), "Long.compareTo(Short)")
assertEquals(true, 10L < 20.toByte(), "Long.compareTo(Byte)")<|endoftext|> |
val a4: Long? = 1 + 1
val a5: Double? = 1.0 + 1
val a6: Float? = 1f + 1
val a7: Char? = 'A' + 1
val a8: Int? = 'B' - 'A'
if (a1!! != 2.toByte()) return "fail 1" | if (a2!! != 2.toShort()) return "fail 2"
if (a3!! != 2) return "fail 3"
if (a4!! != 2L) return "fail 4"
if (a5!! != 2.0) return "fail 5"
if (a6!! != 2f) return "fail 6"
if (a7!! != 'B') return "fail 7"<|endoftext|> |
// TARGET_BACKEND: JVM_IR
// IMPORTANT!
// Please, when your changes cause failures in bytecodeText tests for 'for' loops,
// examine the resulting bytecode shape carefully.
// Range and progression-based loops generated with Kotlin compiler should be
// as close as possible to Java counter loops ('for (int i = a; i < b; ++i) { ... }'). | // Otherwise it may result in performance regression due to missing HotSpot optimizations.
// Run Kotlin compiler benchmarks (https://github.com/Kotlin/kotlin-benchmarks)
// with compiler built from your changes if you are not sure.
fun box(): String {
for (i in 1..7 step 2) {
}
return "OK"
}<|endoftext|> |
fun f(s: String?, t: String): String {
return s.plus(t)
}
fun g(s: String, t: Any?): String {
return "$s$t"
}
fun h(s: String, t: Any?): String {
return s + t
}
fun box(): String { | if (f("O", "K") != "OK") return "Fail 1"
if (g("O", "K") != "OK") return "Fail 2"
if (h("O", "K") != "OK") return "Fail 3"
return "OK"
}<|endoftext|> |
import org.jetbrains.kotlin.fir.declarations.FirProperty
import org.jetbrains.kotlin.fir.diagnostics.DiagnosticKind
import org.jetbrains.kotlin.fir.expressions.FirFunctionCall
import org.jetbrains.kotlin.fir.expressions.FirImplicitInvokeCall | import org.jetbrains.kotlin.fir.expressions.arguments
import org.jetbrains.kotlin.fir.references.isError
import org.jetbrains.kotlin.fir.resolve.diagnostics.*
import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol<|endoftext|> |
// WITH_STDLIB
// WORKS_WHEN_VALUE_CLASS
// LANGUAGE: +ValueClasses, +GenericInlineClassParameter
interface IQ {
fun ok(): String
}
OPTIONAL_JVM_INLINE_ANNOTATION
value class X<T: IQ>(val t: T): IQ {
override fun ok(): String = t.ok()
} | interface IFoo1 {
fun foo(): Any
}
interface IFoo2 {
fun foo(): IQ
}
object OK : IQ {
override fun ok(): String = "OK"
}
class Test : IFoo1, IFoo2 {
override fun foo(): X<IQ> = X(OK)
}
fun box(): String {
val t1: IFoo1 = Test()<|endoftext|> |
* Could be used as an overview to default values of the options (as they are implementation-specific).
*/
public fun makeJvmCompilationConfiguration(): JvmCompilationConfiguration
/**
* Compiles Kotlin code targeting JVM platform and using specified options.
*
* The [finishProjectCompilation] must be called with the same [projectId] after the entire project is compiled. | * @param projectId The unique identifier of the project to be compiled. It may be the same for different modules of the project.
* @param strategyConfig an instance of [CompilerExecutionStrategyConfiguration] initially obtained from [makeCompilerExecutionStrategyConfiguration]
* @param compilationConfig an instance of [JvmCompilationConfiguration] initially obtained from [makeJvmCompilationConfiguration]<|endoftext|> |
// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER
// !CHECK_TYPE
fun <T: Any> bar(a: Array<T>): Array<T?> = null!!
fun test1(a: Array<out Int>) { | val r: Array<out Int?> = <!TYPE_MISMATCH!><!UNSUPPORTED!>bar<!>(a)<!>
val t = <!UNSUPPORTED!>bar<!>(a)<|endoftext|> |
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any? & T")!>x<!>.get(0)
}
}
// TESTCASE NUMBER: 4
inline fun <reified T : CharSequence>case_4(x: Any?) {
(x as? T)!! | if (<!USELESS_IS_CHECK!>x is T?<!>) {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any? & T?!!")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any? & T?!!")!>x<!>.length<|endoftext|> |
// Most notably, the runtime type mapper does not perform inline class name mangling. This is usually not
// a problem, since we will produce a getter signature as part of the Kotlin metadata, except when there
// is no getter method in the bytecode. In that case we need to avoid inline class mangling for the
// function reference used in the <signature-string> intrinsic.
// | // Note that we cannot compute the signature at this point, since we still need to mangle the names of
// private properties in multifile-part classes.
val needsDummySignature = getter.owner.correspondingPropertySymbol?.owner?.needsAccessor(getter.owner) == false ||
// Internal underlying vals of inline classes have no getter method<|endoftext|> |
val arg = not.arg.accept(this) ?: return null
return CallComputation(ESBooleanType, not.functor.invokeWithArguments(arg))
}
override fun visitEqual(equal: ESEqual): Computation? {
val left = equal.left.accept(this) ?: return null
val right = equal.right.accept(this) ?: return null | return CallComputation(ESBooleanType, equal.functor.invokeWithArguments(listOf(left, right), typeSubstitution, reducer))
}
override fun visitAnd(and: ESAnd): Computation? {
val left = and.left.accept(this) ?: return null
val right = and.right.accept(this) ?: return null<|endoftext|> |
// IGNORE_BACKEND: JS_IR
// IGNORE_BACKEND: JS_IR_ES6
// WITH_STDLIB
class A() {
infix fun <T> ArrayList<T>.add3(el: T) = add(el)
fun test(list: ArrayList<Int>) {
for (i in 1..10) {
list add3 i
}
} | }
infix fun <T> ArrayList<T>.add2(el: T) = add(el)
fun box() : String{
var list = ArrayList<Int>()
for (i in 1..10) {
list.add(i)
list add2 i
}
A().test(list)
println(list)
return "OK"
}<|endoftext|> |
return invokeImpl(prioritizedHistory(thiz::class, thiz), name, args)
}
private fun invokeImpl(prioritizedCallOrder: List<EvalClassWithInstanceAndLoader>, name: String, args: Array<out Any?>): Any? {
// TODO: cache the method lookups? | val (fn, mapping, invokeWrapper) = prioritizedCallOrder.asSequence().map { (klass, instance, _, invokeWrapper) ->
val candidates = klass.functions.filter { it.name == name }
candidates.findMapping(listOf(instance) + args)?.let {
Triple(it.first, it.second, invokeWrapper)
}<|endoftext|> |
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int? & kotlin.Int")!>x<!>.inv()
}
}
/*
* TESTCASE NUMBER: 3
* UNEXPECTED BEHAVIOUR
* ISSUES: KT-28760
*/
fun Int?.case_3() {
val x = this
this!! | <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int? & kotlin.Int")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int? & kotlin.Int")!>x<!>.inv()
}
/*
* TESTCASE NUMBER: 4
* UNEXPECTED BEHAVIOUR<|endoftext|> |
p22 + " " + p23 + " " + p24 + " " + p25 + " " + p26 + " " + p27 + " " + p28 + " " +
p29 + " " + p30 + " " + p31 + " " + p32
}
// FILE: 2.kt
import test.*
fun box(): String { | if (test() != "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32")
return "fail 1: ${test()}"
if (test(p20 = "OK") != "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 OK 21 22 23 24 25 26 27 28 29 30 31 32")<|endoftext|> |
package test.text
import kotlin.test.*
class RegexJsTest {
@Test
fun replace() {
// js capturing group name can contain Unicode letters, $, _, and digits (0-9), but may not start with a digit.
// jvm capturing group name can contain a-z, A-Z, and 0-9, but may not start with a digit. | // make sure reference to capturing group name in K/JS Regex.replace(input, replacement) obeys K/JVM rules
val input = "123-456"
Regex("(?<first_part>\\d+)-(?<second_part>\\d+)").let { regex ->
assertEquals("123/456", regex.replace(input, "$1/$2"))<|endoftext|> |
* Returns an array containing all elements of the original array and then all elements of the given [elements] collection.
*/
public expect operator fun ShortArray.plus(elements: Collection<Short>): ShortArray
/**
* Returns an array containing all elements of the original array and then all elements of the given [elements] collection.
*/
public expect operator fun IntArray.plus(elements: Collection<Int>): IntArray
/** | * Returns an array containing all elements of the original array and then all elements of the given [elements] collection.
*/
public expect operator fun LongArray.plus(elements: Collection<Long>): LongArray
/**
* Returns an array containing all elements of the original array and then all elements of the given [elements] collection.
*/
public expect operator fun FloatArray.plus(elements: Collection<Float>): FloatArray
/**<|endoftext|> |
val thenBranch = expression.then
if (thenBranch != null) {
branches.add(thenBranch)
generateInstructions(thenBranch)
} else {
builder.loadUnit(expression)
}
val resultLabel = builder.createUnboundLabel("'if' expression result")
builder.jump(resultLabel, expression)
builder.bindLabel(elseLabel) | val elseBranch = expression.`else`
if (elseBranch != null) {
branches.add(elseBranch)
generateInstructions(elseBranch)
} else {
builder.loadUnit(expression)
}
builder.bindLabel(resultLabel)
mergeValues(branches, expression)
}<|endoftext|> |
if (2.toByte() in 3 until 1 != range1.contains(2.toByte())) throw AssertionError()
if (2.toByte() !in 3 until 1 != !range1.contains(2.toByte())) throw AssertionError() | if (!(2.toByte() in 3 until 1) != !range1.contains(2.toByte())) throw AssertionError()
if (!(2.toByte() !in 3 until 1) != range1.contains(2.toByte())) throw AssertionError()
// no local optimizations<|endoftext|> |
internal val ConfigureBuildSideEffect = KotlinTargetSideEffect { target ->
val project = target.project
val buildNeeded = project.tasks.named(JavaBasePlugin.BUILD_NEEDED_TASK_NAME)
val buildDependent = project.tasks.named(JavaBasePlugin.BUILD_DEPENDENTS_TASK_NAME) | val testCompilation = target.compilations.findByName(KotlinCompilation.TEST_COMPILATION_NAME)
if (testCompilation is DeprecatedKotlinCompilationToRunnableFiles) {
addDependsOnTaskInOtherProjects(project, buildNeeded, true, testCompilation.runtimeDependencyConfigurationName)<|endoftext|> |
* optimal discovery and definitions loading performance.
*
* @param displayName script definition display name, stored as {@link ScriptCompilationConfigurationKeys#displayName},
* default - empty - use annotated class name
* @param fileExtension distinct filename extension for the script type being defined, stored in the configuration
* as {@link ScriptCompilationConfigurationKeys#fileExtension},
* default - "kts" | * @param filePathPattern additional (to the filename extension) RegEx pattern with that the script file path is checked
* as {@link ScriptCompilationConfigurationKeys#filePathPattern},
* default - empty - pattern is not used
* @param compilationConfiguration an object or a class with default constructor containing initial script compilation configuration
* default - {@link ScriptCompilationConfiguration#Default}<|endoftext|> |
): Iterable<File> {
val cache = caches.platformCache
val result = HashSet<File>()
fun partsByFacadeName(facadeInternalName: String): List<File> {
val parts = cache.getStableMultifileFacadeParts(facadeInternalName) ?: emptyList()
return parts.flatMap { cache.sourcesByInternalName(it) }
} | for (generatedFile in generatedFiles) {
if (generatedFile !is GeneratedJvmClass) continue
val outputClass = generatedFile.outputClass
when (outputClass.classHeader.kind) {
KotlinClassHeader.Kind.CLASS -> {
val fqName = outputClass.className.fqNameForClassNameWithoutDollars<|endoftext|> |
override fun String.write(parcel: Parcel, flags: Int) {
parcel.writeInt(length)
}
}
typealias Parceler2 = Parceler1
object Parceler3 : Parceler<String> {
override fun create(parcel: Parcel) = parcel.readString().uppercase() | override fun String.write(parcel: Parcel, flags: Int) {
parcel.writeString(this)
}
}
@Parcelize
@TypeParceler<String, Parceler2>
data class Test(
val a: String,
@<!REDUNDANT_TYPE_PARCELER!>TypeParceler<!><String, Parceler1> val b: String,<|endoftext|> |
// FIR_IDENTICAL
interface Foo
class Bar(f: Foo) : Foo by f {
// Backing field is renamed to `$$delegate_0$1` in JVM_IR
val `$$delegate_0`: Foo? = null
}
class Bar2(f: Foo) :
// Backing field for delegate is renamed to `$$delegate_0$1` in JVM_IR | Foo by f {
lateinit var `$$delegate_0`: Foo
}<|endoftext|> |
}
fun cleanUpField(suspension: SuspensionPoint, fieldIndex: Int) {
with(instructions) {
insertBefore(suspension.suspensionCallBegin, withInstructionAdapter {
load(continuationIndex, AsmTypes.OBJECT_TYPE)
aconst(null)
putfield(
classBuilderForCoroutineState.thisName, | "L\$$fieldIndex",
AsmTypes.OBJECT_TYPE.descriptor
)
})
}
}
for (suspensionPointIndex in suspensionPoints.indices) {
val suspension = suspensionPoints[suspensionPointIndex]
for ((slot, referenceToSpill) in referencesToSpillBySuspensionPointIndex[suspensionPointIndex]) {<|endoftext|> |
public inline fun <T> Iterable<T>.first(predicate: (T) -> Boolean): T {
for (element in this) if (predicate(element)) return element
throw NoSuchElementException("Collection contains no element matching the predicate.")
}
/**
* Returns the first non-null value produced by [transform] function being applied to elements of this collection in iteration order, | * or throws [NoSuchElementException] if no non-null value was produced.
*
* @sample samples.collections.Collections.Transformations.firstNotNullOf
*/
@SinceKotlin("1.5")
@kotlin.internal.InlineOnly
public inline fun <T, R : Any> Iterable<T>.firstNotNullOf(transform: (T) -> R?): R {<|endoftext|> |
if (!isSafeCast(value, typeInsn.desc)) {
markValueAsDirty(value)
}
}
processOperationWithBoxedValue(value, insn)
return super.unaryOperation(insn, value)
}
override fun binaryOperation(insn: AbstractInsnNode, value1: BasicValue, value2: BasicValue): BasicValue? { | processOperationWithBoxedValue(value1, insn)
processOperationWithBoxedValue(value2, insn)
return super.binaryOperation(insn, value1, value2)
}
override fun ternaryOperation(insn: AbstractInsnNode, value1: BasicValue, value2: BasicValue, value3: BasicValue): BasicValue? {<|endoftext|> |
// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER -TOPLEVEL_TYPEALIASES_ONLY
abstract class AbstractClass
typealias Test1 = AbstractClass
val test1 = <!CREATING_AN_INSTANCE_OF_ABSTRACT_CLASS!>Test1()<!> | val test1a = <!CREATING_AN_INSTANCE_OF_ABSTRACT_CLASS!>AbstractClass()<!>
annotation class AnnotationClass
typealias Test2 = AnnotationClass
val test2 = Test2()
val test2a = AnnotationClass()
enum class EnumClass { VALUE1, VALUE2 }
typealias Test3 = EnumClass<|endoftext|> |
0xc000468a8ace592aUL, 0xc0056c6e739800e1UL, 0xbffd0d6a1369ca62UL, 0xc0072c43f4b16ba1UL, | 0xc00921fb54442d18UL, 0x8000000000000000UL, 0xbff921fb54442d18UL, 0x800c90fdaa224287UL,
0x7ff8000000000000UL, 0x95746cad8f401678UL, 0xbff921fb54442d18UL, 0xbff921fb5443f519UL,<|endoftext|> |
extension: GeneratedMessageLite.GeneratedExtension<MessageType, Int>,
) {
declarationFileId(this)?.let { proto.setExtension(extension, it) }
}
private fun declarationFileId(declaration: FirDeclaration): Int? {
val file = when (val symbol = declaration.symbol) { | is FirCallableSymbol<*> -> firProvider.getFirCallableContainerFile(symbol)
is FirClassLikeSymbol<*> -> firProvider.getFirClassifierContainerFileIfAny(symbol)
else -> null
} ?: return null
return stringTable.getStringIndex(file.name)
}
}<|endoftext|> |
val collisions: List<Result.Collision<FileTreeToCopy>> =
fileSystem.walk(resource).map<File, Result.Collision<FileTreeToCopy>?>{ child ->
if (fileSystem.isDirectory(child)) {
return@map null
}
val relativePath = child.toRelativeString(resourcesDirectory) | relativePathsSeenAtThisLevel[relativePath]?.let { alreadySeenFile ->
return@map Result.Collision(
child,
alreadySeenFile,
)
}
relativePathsSeenAtThisLevel[relativePath] = child
return@map null
}.mapNotNull { it }.toList()
if (collisions.isNotEmpty()) {<|endoftext|> |
// EXPECTED_REACHABLE_NODES: 1288
// FILE: main.kt
package foo
@JsName("A")
external open class B(foo: String) {
val foo: String
}
class C(s: String) : B(s)
fun box(): String {
return C("OK").foo
}
// FILE: test.js
function A(foo) { | this.foo = foo;
}<|endoftext|> |
if (arguments.useOldBackend) {
messageCollector.report(WARNING, "-Xuse-old-backend is no longer supported. Please migrate to the new JVM IR backend")
}
if (arguments.script || arguments.expression != null) { | val scriptingEvaluator = ScriptEvaluationExtension.getInstances(projectEnvironment.project).find { it.isAccepted(arguments) }
if (scriptingEvaluator == null) {
messageCollector.report(ERROR, "Unable to evaluate script, no scripting plugin loaded")
return COMPILATION_ERROR
}<|endoftext|> |
public inline fun <T> flow(crossinline block: suspend FlowCollector<T>.() -> Unit) = object : Flow<T> {
override suspend fun collect(collector: FlowCollector<T>) = collector.block()
}
suspend inline fun <T> Flow<T>.collect(crossinline action: suspend (T) -> Unit): Unit =
collect(object : FlowCollector<T> { | override suspend fun emit(value: T) = action(value)
})
public inline fun <T, R> Flow<T>.transform(crossinline transformer: suspend FlowCollector<R>.(value: T) -> Unit): Flow<R> {
return flow {
collect { value ->
transformer(value)
}
}
}<|endoftext|> |
if (!(1.toShort() !in 3 until 1) != range1.contains(1.toShort())) throw AssertionError()
// no local optimizations
if (element9 in 3 until 1 != range1.contains(element9)) throw AssertionError()
if (element9 !in 3 until 1 != !range1.contains(element9)) throw AssertionError() | if (!(element9 in 3 until 1) != !range1.contains(element9)) throw AssertionError()
if (!(element9 !in 3 until 1) != range1.contains(element9)) throw AssertionError()
}
fun testR1xE10() {
// with possible local optimizations<|endoftext|> |
fun <T : <!FINAL_UPPER_BOUND!>Int<!>> fooInt(s: T) {}
open class Wrapper<T>(val value: T)
fun <T, R : Wrapper<in T>> createWrapper(s: T): R = TODO()
fun <T> Wrapper<T>.baz(transform: (T) -> Unit): T = TODO() | fun test() {
takeFun<String>(::foo)
takeFun<String>(::<!INAPPLICABLE_CANDIDATE!>fooInt<!>)
callFun<String, Wrapper<String>>(::createWrapper)
callFun<Int, Wrapper<Number>>(::createWrapper)
callFun<String, Wrapper<*>>(::createWrapper)<|endoftext|> |
package org.jetbrains.kotlin.cfg
import com.intellij.psi.PsiElement
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.config.LanguageFeature
import org.jetbrains.kotlin.config.LanguageVersionSettings | import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.ClassKind
import org.jetbrains.kotlin.descriptors.Modality
import org.jetbrains.kotlin.diagnostics.DiagnosticSink
import org.jetbrains.kotlin.diagnostics.Errors<|endoftext|> |
is CirRegularTypeProjection -> "${renderVariance(typeArgument.projectionKind)}${renderTypeForUnsafeNumberAnnotation(typeArgument.type)}"
CirStarTypeProjection -> STAR_PROJECTION
}
}
private fun renderVariance(variance: Variance): String = "$variance ".takeIf { it.isNotBlank() }.orEmpty() | private fun CirSimpleType.renderNullable(): String = isMarkedNullable.ifTrue { NULLABLE }.orEmpty()
private const val NULLABLE: String = "?"
private const val STAR_PROJECTION: String = "*"
private const val TYPE_PARAMETER_TYPE_PREFIX = "#"<|endoftext|> |
catch (t: Throwable) {
throw Exception("Error loading class $mainLineClassName: known classes: ${compiledClassesNames()}", t)
}
return Pair(classLoader, scriptClass)
}
}
private open class HistoryActionsForRepeatRecentOnly(state: GenericReplEvaluatorState) : HistoryActionsForNoRepeat(state) { | val currentLast = state.history.peek()!!
override val effectiveHistory: List<EvalClassWithInstanceAndLoader> get() = super.effectiveHistory.dropLast(1)
override fun firstMismatch(other: Sequence<ILineId>): Pair<ReplHistoryRecord<EvalClassWithInstanceAndLoader>?, ILineId?>? =<|endoftext|> |
package templates
import templates.DocExtensions.collection
import templates.Family.*
import templates.Ordering.appendStableSortNote
import templates.Ordering.stableSortNote
object ArrayOps : TemplateGroupBase() {
init {
defaultBuilder {
specialFor(ArraysOfUnsigned) {
sinceAtLeast("1.3")
annotation("@ExperimentalUnsignedTypes") | }
}
}
val f_isEmpty = fn("isEmpty()") {
include(ArraysOfObjects, ArraysOfPrimitives)
} builder {
inlineOnly()
doc { "Returns `true` if the array is empty." }
returns("Boolean")
body {
"return size == 0"
}
}<|endoftext|> |
package org.jetbrains.kotlin.commonizer.cir
import org.jetbrains.kotlin.descriptors.Visibility
interface CirClassConstructor :
CirDeclaration,
CirHasAnnotations,
CirHasTypeParameters,
CirHasVisibility,
CirMaybeCallableMemberOfClass,
CirCallableMemberWithParameters { | val isPrimary: Boolean
override val containingClass: CirContainingClass // non-nullable
override fun withContainingClass(containingClass: CirContainingClass): CirClassConstructor
companion object {
@Suppress("NOTHING_TO_INLINE")
inline fun create(
annotations: List<CirAnnotation>,
typeParameters: List<CirTypeParameter>,<|endoftext|> |
* @throws IllegalArgumentException if [fromIndex] is greater than [toIndex].
*/
@SinceKotlin("1.3")
@Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS")
public actual fun BooleanArray.fill(element: Boolean, fromIndex: Int = 0, toIndex: Int = size): Unit { | AbstractList.checkRangeIndexes(fromIndex, toIndex, size)
nativeFill(element, fromIndex, toIndex)
}
/**
* Fills this array or its subrange with the specified [element] value.
*
* @param fromIndex the start of the range (inclusive) to fill, 0 by default.<|endoftext|> |
internal val javaScope = LazyJavaPackageScope(c, jPackage, packageFragment)
private val kotlinScopes by c.storageManager.createLazyValue {
listOfNonEmptyScopes(
packageFragment.binaryClasses.values.mapNotNull { partClass -> | c.components.deserializedDescriptorResolver.createKotlinPackagePartScope(packageFragment, partClass)
}
).toTypedArray()
}
override fun getContributedClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? {
recordLookup(name, location)<|endoftext|> |
checkExactType<Buildee<Nothing?>>(buildee)
}
// test 2: PTV is in producing position (materialize-case)
fun testMaterialize() {
fun consume(arg: Nothing?) {}
val buildee = build {
consume(materialize())
}
checkExactType<Buildee<Nothing?>>(buildee)
}
fun box(): String { | testYield()
testMaterialize()
return "OK"
}<|endoftext|> |
@getSetAndParamAnn <!INAPPLICABLE_TARGET_ON_PROPERTY, REPEATED_ANNOTATION!>@get:getSetAndParamAnn<!> get() = 0
// See KT-15470: fake INAPPLICABLE_TARGET_ON_PROPERTY | @getSetAndParamAnn <!INAPPLICABLE_TARGET_ON_PROPERTY, REPEATED_ANNOTATION!>@set:getSetAndParamAnn<!> set(arg) {}
}<|endoftext|> |
package org.jetbrains.kotlin.backend.common.lower.loops
import org.jetbrains.kotlin.backend.common.CommonBackendContext
import org.jetbrains.kotlin.backend.common.ir.Symbols
import org.jetbrains.kotlin.backend.common.lower.loops.handlers.* | import org.jetbrains.kotlin.ir.IrElement
import org.jetbrains.kotlin.ir.IrStatement
import org.jetbrains.kotlin.ir.declarations.IrVariable
import org.jetbrains.kotlin.ir.expressions.IrCall
import org.jetbrains.kotlin.ir.expressions.IrExpression<|endoftext|> |
package org.jetbrains.kotlin.fir.analysis.checkers.extended
import org.jetbrains.kotlin.KtFakeSourceElementKind
import org.jetbrains.kotlin.diagnostics.DiagnosticReporter
import org.jetbrains.kotlin.diagnostics.reportOn | import org.jetbrains.kotlin.fir.analysis.checkers.MppCheckerKind
import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext
import org.jetbrains.kotlin.fir.analysis.checkers.expression.FirFunctionCallChecker<|endoftext|> |
class FirNameAwareOnlyCallablesScope(val delegate: FirContainingNamesAwareScope) : FirContainingNamesAwareScope() {
// We want to *avoid* delegation to certain scope functions, so we delegate explicitly instead of using
// `FirDelegatingContainingNamesAwareScope`. | override fun processFunctionsByName(name: Name, processor: (FirNamedFunctionSymbol) -> Unit) {
return delegate.processFunctionsByName(name, processor)
}
override fun processPropertiesByName(name: Name, processor: (FirVariableSymbol<*>) -> Unit) {
return delegate.processPropertiesByName(name, processor)
}<|endoftext|> |
0x05bf..0x05bf,
0x05c1..0x05c2,
0x05c4..0x05c5,
0x05c7..0x05c7,
0x05f4..0x05f4,
0x0600..0x0605,
0x0610..0x061a, | 0x061c..0x061c,
0x0640..0x0640,
0x064b..0x065f,
0x0670..0x0670,
0x06d6..0x06dc,
0x06dd..0x06dd,
0x06df..0x06e4,<|endoftext|> |
0x3fcf5b75f92c80ddUL, 0x4002d97c7f3321d2UL, 0x4002d97c7f3313d2UL, 0x4002d97c7f332fd2UL, | 0x4000468a8ace4df6UL, 0x40056c6e7397f5aeUL, 0x3ffd0d6a1369bd34UL, 0x40072c43f4b1650aUL,<|endoftext|> |
class A(x : Int = <!UNINITIALIZED_PARAMETER!>y<!>, y : Int = x) { // None of the references is resolved, no types checked
constructor(x : Int = <!UNINITIALIZED_PARAMETER!>x<!>) : this(x, x) | fun foo(bool: Boolean, a: Int = <!TYPE_MISMATCH, UNINITIALIZED_PARAMETER!>b<!>, b: String = <!TYPE_MISMATCH!>a<!>) {}
}
val z = 3<|endoftext|> |
// FILE: 1.kt
public inline fun <R> runTest(f: () -> R): R {
return f()
}
public inline fun <R> minByTest(f: (Int) -> R): R {
var minValue = f(1)
val v = f(1)
return v
}
// FILE: 2.kt
fun box(): String { | val result = runTest{minByTest<Int> { it }}
if (result != 1) return "test1: ${result}"
return "OK"
}<|endoftext|> |
// TODO: go through javaClass's class loader
return findKotlinClass(javaClass.fqName?.asString() ?: return null)
}
// TODO
override fun findMetadata(classId: ClassId): InputStream? = null
// TODO | override fun findMetadataTopLevelClassesInPackage(packageFqName: FqName): Set<String>? = null
// TODO
override fun hasMetadataPackage(fqName: FqName): Boolean = false
override fun findBuiltInsData(packageFqName: FqName): InputStream? {<|endoftext|> |
if (!(1uL !in 1uL downTo 3uL) != range0.contains(1uL)) throw AssertionError()
// no local optimizations
if (element1 in 1uL downTo 3uL != range0.contains(element1)) throw AssertionError() | if (element1 !in 1uL downTo 3uL != !range0.contains(element1)) throw AssertionError()
if (!(element1 in 1uL downTo 3uL) != !range0.contains(element1)) throw AssertionError()<|endoftext|> |
// TODO: find out how it's implemented in other jsr223 engines for typed languages, since this approach prevent certain usage scenarios, e.g. assigning back value of a "sibling" type
updatedProperties[k] = if (v == null) KotlinType(Any::class, isNullable = true) else KotlinType(v::class)
}
} | ScriptCompilationConfiguration(context.compilationConfiguration) {
providedProperties(updatedProperties)
}.asSuccess()
} else context.compilationConfiguration.asSuccess()
}
fun configureProvidedPropertiesFromJsr223Context(context: ScriptEvaluationConfigurationRefinementContext): ResultWithDiagnostics<ScriptEvaluationConfiguration> {<|endoftext|> |
* @throws IndexOutOfBoundsException if [fromIndex] is less than zero or [toIndex] is greater than the size of this array.
* @throws IllegalArgumentException if [fromIndex] is greater than [toIndex].
*/
@Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS") | public actual fun <T> Array<T>.fill(element: T, fromIndex: Int = 0, toIndex: Int = size): Unit {
java.util.Arrays.fill(this, fromIndex, toIndex, element)
}
/**
* Fills this array or its subrange with the specified [element] value.
*<|endoftext|> |
// !SKIP_JAVAC
// !LANGUAGE: -ProhibitUsingNullableTypeParameterAgainstNotNullAnnotated
// !RENDER_DIAGNOSTICS_FULL_TEXT
// FILE: SLRUMap.java
import org.jetbrains.annotations.NotNull;
import java.util.List;
public interface SLRUMap<V> { | void takeV(@NotNull V value);
<E> void takeE(@NotNull E value);
void takeVList(@NotNull List<@NotNull V> value);
<E> void takeEList(@NotNull List<@NotNull E> value);
public <K> K id(K value) { return null; }
}
// FILE: main.kt<|endoftext|> |
override fun reportElementWithErrorType(expression: KtReferenceExpression) {
newDiagnostic(
expression,
DebugInfoDiagnosticFactory0.ELEMENT_WITH_ERROR_TYPE
)
}
override fun reportMissingUnresolved(expression: KtReferenceExpression) {
newDiagnostic(
expression, | DebugInfoDiagnosticFactory0.MISSING_UNRESOLVED
)
}
override fun reportUnresolvedWithTarget(
expression: KtReferenceExpression,
target: String
) {
newDiagnostic(expression, DebugInfoDiagnosticFactory0.UNRESOLVED_WITH_TARGET)
}
override fun reportDynamicCall(<|endoftext|> |
var empty = true
lookupTracker?.recordCallLookup(info, scope.scopeOwnerLookupNames)
scope.processPropertiesByName(info.name) { candidate ->
lookupTracker?.recordCallableCandidateAsLookup(candidate, info.callSite.source, info.containingFile.source)
empty = false
consumeCallableCandidate(candidate, info, processor) | }
return if (empty) ProcessResult.SCOPE_EMPTY else ProcessResult.FOUND
}
override fun processObjectsByName(
info: CallInfo,
processor: TowerScopeLevelProcessor<FirBasedSymbol<*>>
): ProcessResult {
var empty = true
session.lookupTracker?.recordCallLookup(info, scope.scopeOwnerLookupNames)<|endoftext|> |
private val counterToCallStackMapThreadLocal = ThreadLocal<MutableMap<CounterWithExclude, CallStackWithTime>>()
private fun getCallStack(counter: CounterWithExclude) =
PerformanceCounter.getOrPut(counterToCallStackMapThreadLocal) { HashMap() }.getOrPut(counter) { CallStackWithTime() }
}
init { | excludedCounters.forEach { it.excludedFrom.add(this) }
}
private val callStack: CallStackWithTime
get() = getCallStack(this)
override fun <T> countTime(block: () -> T): T {
incrementTime(callStack.push(true))
try {
return block()
} finally {<|endoftext|> |
import org.jetbrains.kotlin.light.classes.symbol.modifierLists.GranularModifiersBox
import org.jetbrains.kotlin.light.classes.symbol.modifierLists.SymbolLightClassModifierList
import org.jetbrains.kotlin.load.java.JvmAbi | import org.jetbrains.kotlin.name.JvmStandardClassIds
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.resolve.DataClassResolver
import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOriginKind<|endoftext|> |
0x7ff8000000000000UL, 0x7ff8000000000000UL, 0x4010000000000000UL, 0x7ff8000000000000UL,
0x4030000000000000UL, 0xbfe0000000000000UL, 0x7ff8000000000000UL, 0x7ff8000000000000UL, | 0x7ff8000000000000UL, 0x3fd0000000000000UL, 0x7ff8000000000000UL, 0x3fb0000000000000UL,
0x7ff0000000000000UL, 0x0UL, 0x7ff8000000000000UL, 0x0UL,<|endoftext|> |
assertEquals(-2, subject.notNullReadWriteB)
}
@Test
fun `test - factoryProperty`() {
run {
val subject = Subject()
assertNotNull(subject.factoryList)
assertSame(subject.factoryList, subject.factoryList)
assertSame(subject.extras[keyList], subject.factoryList)
} | run {
val subject = Subject()
val list = mutableListOf(Dummy())
subject.extras[keyList] = list
assertSame(list, subject.factoryList)
}
}
@Test
fun `test - lazyProperty`() {
run {
val subject = Subject()
assertNotNull(subject.lazyList)<|endoftext|> |
* HELPERS: contractFunctions
*/
// FILE: contracts.kt
package contracts
import kotlin.contracts.*
// TESTCASE NUMBER: 1
fun case_1(x: Any?): Boolean {
contract { returns(true) implies (x !is Number) }
return x !is Number
}
// TESTCASE NUMBER: 2 | fun case_2(x: Any?): Boolean {
contract { returns(true) implies (x !is Number?) }
return x !is Number?
}
// TESTCASE NUMBER: 15
fun case_15_1(value_1: Any?, value_2: Any?): Boolean {
contract { returns(true) implies (value_1 !is String || value_2 !is Number) }<|endoftext|> |
override val analysisContext: Fe10AnalysisContext
) : KtSyntheticJavaPropertySymbol(), KtFe10DescMemberSymbol<JavaForKotlinOverridePropertyDescriptor> {
override val name: Name
get() = withValidityAssertion { descriptor.name }
override val isFromPrimaryConstructor: Boolean | get() = withValidityAssertion { descriptor.containingDeclaration is ConstructorDescriptor }
override val isOverride: Boolean
get() = withValidityAssertion { descriptor.isExplicitOverride }
override val isStatic: Boolean
get() = withValidityAssertion { DescriptorUtils.isStaticDeclaration(descriptor) }<|endoftext|> |
firAccessor = fir.setter, isSetter = true,
firParentProperty = fir,
firParentClass = containingClass,
symbol = symbols.setterSymbol,
parent = this@Fir2IrLazyProperty.parent,
isFakeOverride = isFakeOverride,
correspondingPropertySymbol = this.symbol
).apply { | classifiersGenerator.setTypeParameters(this, this@Fir2IrLazyProperty.fir, ConversionTypeOrigin.SETTER)
}
}
override var overriddenSymbols: List<IrPropertySymbol> by symbolsMappingForLazyClasses.lazyMappedPropertyListVar(lock) {
when (configuration.useFirBasedFakeOverrideGenerator) {<|endoftext|> |
get() = DPoint(-x, -y)
}
class DSegment(var p1: DPoint, var p2: DPoint) {
val center: DPoint
get() = DPoint(p1.x / 2 + p2.x / 2, p1.y / 2 + p2.y / 2)
var notImplemented: DPoint | get() = TODO()
set(_) = TODO()
var point1WithBackingFieldAndDefaultGetter: DPoint = p1
var point2WithBackingFieldAndDefaultGetter: DPoint = p1
get() = field
set(value) {
field = value
require("${2 + 2}" == "4")
}<|endoftext|> |
typeVariable.originalTypeParameter.shouldBeFlexible() -> createFlexibleType()
else -> type
}
}
private fun createKnownParametersFromFreshVariablesSubstitutor(
freshVariableSubstitutor: FreshVariableNewTypeSubstitutor,
knownTypeParametersSubstitutor: TypeSubstitutor,
): NewTypeSubstitutor { | if (knownTypeParametersSubstitutor.isEmpty)
return EmptySubstitutor
val knownTypeParameterByTypeVariable = mutableMapOf<TypeConstructor, UnwrappedType>().let { map ->
for (typeVariable in freshVariableSubstitutor.freshVariables) {
val typeParameterType = typeVariable.originalTypeParameter.defaultType<|endoftext|> |
package org.jetbrains.kotlin.fir.analysis.checkers.syntax
import com.intellij.lang.LighterASTNode
import com.intellij.psi.PsiElement
import com.intellij.psi.tree.IElementType
import com.intellij.util.diff.FlyweightCapableTreeStructure
import org.jetbrains.kotlin.* | import org.jetbrains.kotlin.KtNodeTypes.BINARY_EXPRESSION
import org.jetbrains.kotlin.diagnostics.DiagnosticReporter
import org.jetbrains.kotlin.diagnostics.reportOn
import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext<|endoftext|> |
KotlinBuiltIns.isUShort(notNullExpected) && value == value.toShort().fromUShortToLong() -> UShortValue(value.toShort())
KotlinBuiltIns.isUInt(notNullExpected) && value == value.toInt().fromUIntToLong() -> UIntValue(value.toInt()) | KotlinBuiltIns.isULong(notNullExpected) -> ULongValue(value)
else -> null
}
} else {
when {
KotlinBuiltIns.isLong(notNullExpected) -> LongValue(value)
KotlinBuiltIns.isInt(notNullExpected) && value == value.toInt().toLong() -> IntValue(value.toInt())<|endoftext|> |
// no local optimizations
if (element10 in 1.0..3.0 != range0.contains(element10)) throw AssertionError()
if (element10 !in 1.0..3.0 != !range0.contains(element10)) throw AssertionError() | if (!(element10 in 1.0..3.0) != !range0.contains(element10)) throw AssertionError()
if (!(element10 !in 1.0..3.0) != range0.contains(element10)) throw AssertionError()
}
fun testR0xE11() {
// with possible local optimizations<|endoftext|> |
}
}
incorporateBound(bound)
}
private fun generateTypeParameterBound(
parameterType: KotlinType,
constrainingType: KotlinType,
boundKind: TypeBounds.BoundKind,
constraintContext: ConstraintContext
) {
val typeVariable = getMyTypeVariable(parameterType)!! | var newConstrainingType = constrainingType
// Here we are handling the case when T! gets a bound Foo (or Foo?)
// In this case, type parameter T is supposed to get the bound Foo!
// Example:
// val c: Collection<Foo> = Collections.singleton(null : Foo?)
// Constraints for T are:
// Foo? <: T!<|endoftext|> |
public inline operator fun rem(other: Short): Int =
this.toInt() % other.toInt()
/**
* Calculates the remainder of truncating division of this value (dividend) by the other value (divisor).
*
* The result is either zero or has the same sign as the _dividend_ and has the absolute value less than the absolute value of the divisor. | */
@SinceKotlin("1.1")
@kotlin.internal.IntrinsicConstEvaluation
public inline operator fun rem(other: Int): Int =
this.toInt() % other
/**
* Calculates the remainder of truncating division of this value (dividend) by the other value (divisor).
*<|endoftext|> |
// FILE: 1.kt
package test
class A {
fun call() = inlineFun2 { stub() }
internal inline fun inlineFun2(p: () -> Unit): String {
p()
return inlineFun {
test()
}
}
private fun stub() = "fail"
private fun test() = "OK" | inline internal fun inlineFun(p: () -> String): String {
return p()
}
}
// FILE: 2.kt
import test.*
fun box(): String {
return A().call()
}<|endoftext|> |
val config = generationState.config
val binaryOption = config.configuration.get(BinaryOptions.linkRuntime)
return when {
binaryOption == RuntimeLinkageStrategyBinaryOption.Raw -> Raw(runtimeLlvmModules)
binaryOption == RuntimeLinkageStrategyBinaryOption.Optimize -> LinkAndOptimize(generationState, runtimeLlvmModules) | config.debug -> LinkAndOptimize(generationState, runtimeLlvmModules)
else -> Raw(runtimeLlvmModules)
}
}
}
}
enum class RuntimeLinkageStrategyBinaryOption {
Raw,
Optimize
}<|endoftext|> |
public actual fun insert(index: Int, value: Long): StringBuilder = insert(index, value.toString())
/**
* Inserts the string representation of the specified float [value] into this string builder at the specified [index] and returns this instance.
*
* The overall effect is exactly as if the [value] were converted to a string by the `value.toString()` method, | * and then that string was inserted into this string builder at the specified [index].
*
* @throws IndexOutOfBoundsException if [index] is less than zero or greater than the length of this string builder.
*/
public actual fun insert(index: Int, value: Float): StringBuilder = insert(index, value.toString())
/**<|endoftext|> |
package org.jetbrains.kotlin.allopen
import org.jetbrains.kotlin.test.FirParser
import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder
import org.jetbrains.kotlin.test.runners.AbstractDiagnosticTest
import org.jetbrains.kotlin.test.runners.AbstractFirDiagnosticTestBase | import org.jetbrains.kotlin.test.runners.codegen.AbstractFirPsiBytecodeListingTest
import org.jetbrains.kotlin.test.runners.codegen.AbstractIrBytecodeListingTest
import org.jetbrains.kotlin.test.runners.configurationForClassicAndFirTestsAlongside
// ---------------------------- diagnostic ----------------------------<|endoftext|> |
init {
require(alignment.countOneBits() == 1) { "Alignment should be power of 2" }
}
}
/**
* All fields of the class instance.
* The order respects the class hierarchy, i.e. a class [fields] contains superclass [fields] as a prefix.
*/ | fun getFields(llvm: CodegenLlvmHelpers): List<FieldInfo> = getFieldsInternal(llvm).map { fieldInfo ->
val mappedField = fieldInfo.irField?.let { context.mapping.lateInitFieldToNullableField[it] ?: it }
if (mappedField == fieldInfo.irField)
fieldInfo
else<|endoftext|> |
) : AnnotationBasedExtension, IrElementVisitorVoid {
override fun getAnnotationFqNames(modifierListOwner: KtModifierListOwner?): List<String> = annotations
override fun visitElement(element: IrElement) {
element.acceptChildren(this, null)
}
override fun visitClass(declaration: IrClass) { | super.visitClass(declaration)
if (needsNoargConstructor(declaration)) {
declaration.declarations.add(getOrGenerateNoArgConstructor(declaration))
}
}
private val noArgConstructors = mutableMapOf<IrClass, IrConstructor>()<|endoftext|> |
a2.foo(<!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>null<!>)
a2.foo(1)
// jspecify_nullness_mismatch, jspecify_nullness_mismatch | a1.bar(<!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>null<!>, <!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>null<!>)
// jspecify_nullness_mismatch<|endoftext|> |
val ktExpectedReturnType = callableReferenceType.arguments.last().type
return KotlinBuiltIns.isUnit(ktExpectedReturnType) && !KotlinBuiltIns.isUnit(descriptor.returnType!!)
}
private fun requiresSuspendConversion(descriptor: CallableDescriptor, callableReferenceType: KotlinType): Boolean = | descriptor is FunctionDescriptor &&
!descriptor.isSuspend &&
callableReferenceType.isKSuspendFunctionType
private fun generateAdaptedCallableReference(
ktCallableReference: KtCallableReferenceExpression,
callBuilder: CallBuilder,
callableReferenceType: KotlinType
): IrExpression {<|endoftext|> |
* [Long.MAX_VALUE] if it's bigger than `Long.MAX_VALUE`.
*/
@kotlin.internal.IntrinsicConstEvaluation
public override fun toLong(): Long
/** Returns this value. */
@kotlin.internal.IntrinsicConstEvaluation
public override fun toFloat(): Float
/** | * Converts this [Float] value to [Double].
*
* The resulting `Double` value represents the same numerical value as this `Float`.
*/
@kotlin.internal.IntrinsicConstEvaluation
public override fun toDouble(): Double
@kotlin.internal.IntrinsicConstEvaluation
public override fun toString(): String<|endoftext|> |
class Local : @SuperType SuperClass<@NestedSuperType A<@NestedNestedSuperType B>>(), @SuperInterfaceType SuperInterface<@NestedSuperInterfaceType A<@NestedNestedSuperInterfaceType B>>, @SuperDelegateType SuperInterface<@NestedSuperDelegateType A<@NestedNestedSuperDelegateType B>> by Component {
@Anno | class LocalNested : @SuperType SuperClass<@NestedSuperType A<@NestedNestedSuperType B>>(), @SuperInterfaceType SuperInterface<@NestedSuperInterfaceType A<@NestedNestedSuperInterfaceType B>>, @SuperDelegateType SuperInterface<@NestedSuperDelegateType A<@NestedNestedSuperDelegateType B>> by Component {
}
@Fun<|endoftext|> |
* so it's plausible to have a reduced copy here in the test pipeline.
*/
private fun transformToNativeIr(module: TestModule, inputArtifact: ClassicFrontendOutputArtifact): IrBackendInput {
val (psiFiles, analysisResult, project, _) = inputArtifact
val configuration = testServices.compilerConfigurationProvider.getCompilerConfiguration(module) | val sourceFiles: List<KtFile> = psiFiles.values.toList()
val translator = Psi2IrTranslator(
configuration.languageVersionSettings,
Psi2IrConfiguration(
ignoreErrors = CodegenTestDirectives.IGNORE_ERRORS in module.directives,
configuration.partialLinkageConfig.isEnabled
),<|endoftext|> |
override fun visitModuleFragment(declaration: IrModuleFragment, data: ScriptToClassTransformerContext): IrModuleFragment =
unexpectedElement(declaration)
override fun visitExternalPackageFragment(declaration: IrExternalPackageFragment, data: ScriptToClassTransformerContext) =
unexpectedElement(declaration) | override fun visitFile(declaration: IrFile, data: ScriptToClassTransformerContext): IrFile = unexpectedElement(declaration)
override fun visitScript(declaration: IrScript, data: ScriptToClassTransformerContext): IrStatement = unexpectedElement(declaration)
override fun visitDeclaration(declaration: IrDeclarationBase, data: ScriptToClassTransformerContext): IrStatement = declaration.apply {<|endoftext|> |