prompt
stringlengths 1
924
| completion
stringlengths 14
937
|
|---|---|
class CompatibilityWarning(val candidate: CallableDescriptor) : KotlinCallDiagnostic(RESOLVED) {
override fun report(reporter: DiagnosticReporter) {
reporter.onCall(this)
}
}
class CompatibilityWarningOnArgument(
val argument: KotlinCallArgument,
val candidate: CallableDescriptor
|
) : KotlinCallDiagnostic(RESOLVED) {
override fun report(reporter: DiagnosticReporter) {
reporter.onCallArgument(argument, this)
}
}
class NoContextReceiver(val receiverDescriptor: ReceiverParameterDescriptor) : KotlinCallDiagnostic(INAPPLICABLE) {<|endoftext|>
|
if (element != <!DEBUG_INFO_CONSTANT!>implicitNullableNothingProperty<!> && true && true && true) else { break }
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int & kotlin.Int?")!>element<!>
|
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int & kotlin.Int?"), DEBUG_INFO_SMARTCAST!>element<!>.inv()
}
}
// TESTCASE NUMBER: 10
fun case_10(x: Float?) {
while (false) {
if (true && true && true && x !== null) else break<|endoftext|>
|
fun testMaterialize() {
fun testLocalClassOutsideBuilderArgument() {
class Local<T>
reference = Local<UserKlass>()
fun consume(arg: Local<UserKlass>) {}
val buildee = build {
consume(materialize())
}
checkExactType<Buildee<Local<UserKlass>>>(buildee)
}
|
fun testLocalClassInsideBuilderArgument() {
val buildee = build {
class Local<T> { fun localOnlyFunc(): T = UserKlass() as T }
reference = Local<UserKlass>()
fun consume(arg: Local<UserKlass>) {}
consume(materialize())
}
val result = buildee.typeArgumentValue.localOnlyFunc()<|endoftext|>
|
suspend fun useSuspendFunStringString(fn: suspend (String, String) -> String) = fn("O", "K")
open class Test : () -> String, (Int) -> String {
override fun invoke(): String = "OKEmpty"
override fun invoke(p: Int) = "OK$p"
}
class Sub : Test(), (String, String) -> String {
|
override fun invoke(p1: String, p2: String) = p1 + p2
}
fun box(): String {
var test = "Failed"
builder {
test = useSuspendFun(Test())
}
if (test != "OKEmpty") return "failed 1"
builder {
test = useSuspendFunInt(Sub())
}<|endoftext|>
|
import org.jetbrains.kotlin.types.*
import org.jetbrains.kotlin.types.error.ErrorUtils
import org.jetbrains.kotlin.types.model.*
import org.jetbrains.kotlin.types.typeUtil.*
import org.jetbrains.kotlin.utils.SmartList
|
import org.jetbrains.kotlin.utils.addToStdlib.compactIfPossible
internal object CheckVisibility : ResolutionPart() {
override fun ResolutionCandidate.process(workIndex: Int) {
val containingDescriptor = scopeTower.lexicalScope.ownerDescriptor
val dispatchReceiverArgument = resolvedCall.dispatchReceiverArgument<|endoftext|>
|
return KotlinScriptDefinitionFromAnnotatedTemplate(cls.kotlin, emptyMap())
}
private val scriptDef = makeScriptDefinition(templateClasspath, templateClassName)
val replCompiler : GenericReplCompiler by lazy {
|
GenericReplCompiler(disposable, scriptDef, configuration, PrintingMessageCollector(System.out, MessageRenderer.WITHOUT_PATHS, false))
}
val compiledEvaluator: ReplEvaluator by lazy {
GenericReplEvaluator(baseClasspath, Thread.currentThread().contextClassLoader, emptyScriptArgs, repeatingMode)
}<|endoftext|>
|
var min = this[0]
for (i in 1..lastIndex) {
val e = this[i]
if (min > e) min = e
}
return min
}
/**
* Returns the smallest element.
*
* @throws NoSuchElementException if the array is empty.
*/
@SinceKotlin("1.7")
|
@kotlin.jvm.JvmName("minOrThrow-U")
@ExperimentalUnsignedTypes
@Suppress("CONFLICTING_OVERLOADS")
public fun UByteArray.min(): UByte {
if (isEmpty()) throw NoSuchElementException()
var min = this[0]
for (i in 1..lastIndex) {
val e = this[i]<|endoftext|>
|
// CHECK_FUNCTION_EXISTS: minus_za3lpa$ TARGET_BACKENDS=JS
// CHECK_NOT_CALLED_IN_SCOPE: function=minus_za3lpa$ scope=box TARGET_BACKENDS=JS
// CHECK_FUNCTION_EXISTS: invoke_dqglrj$ TARGET_BACKENDS=JS
|
// CHECK_NOT_CALLED_IN_SCOPE: function=invoke_dqglrj$ scope=test TARGET_BACKENDS=JS
class A {
inline operator fun plus(a: Int) = a + 10
}
class B
inline operator fun B.plus(b: Int) = b + 20
object O {
inline operator fun invoke() = 42<|endoftext|>
|
1f <!CAST_NEVER_SUCCEEDS!>as<!> Short
1f <!CAST_NEVER_SUCCEEDS!>as<!> Long
1f <!CAST_NEVER_SUCCEEDS!>as<!> Char
1f <!CAST_NEVER_SUCCEEDS!>as<!> Double
|
1f <!USELESS_CAST!>as Float<!>
}
fun asSafe() {
1 <!USELESS_CAST!>as? Int<!>
1 <!CAST_NEVER_SUCCEEDS!>as?<!> Byte
1 <!CAST_NEVER_SUCCEEDS!>as?<!> Short<|endoftext|>
|
@file:JvmName("MyFacadeKt")
@file:JvmMultifileClass
package mypack
expect fun intermediateFunctionWithActualization(
commonActualization: MyCommonClassWithActualization,
intermediateActualization: IntermediateClassWithActualization,
common: MyCommonClass,
intermediate: MyIntermediateClass,
)
|
expect var intermediateVariableWithActualization: IntermediateClassWithActualization
fun intermediateFunction1(
commonActualization: MyCommonClassWithActualization,
intermediateActualization: IntermediateClassWithActualization,
common: MyCommonClass,
intermediate: MyIntermediateClass,
) {
}
expect class IntermediateClassWithActualization
class MyIntermediateClass<|endoftext|>
|
// fun <ADAPTER_FUN>(function: <FUN_TYPE>): <FUN_INTERFACE_TYPE> =
// <FUN_INTERFACE_TYPE>(function!!)
// ::<ADAPTER_FUN>
// }
val startOffset = ktCallableReference.startOffsetSkippingComments
val endOffset = ktCallableReference.endOffset
|
val irReferenceType = callableReferenceType.toIrType()
val irAdapterFun = createFunInterfaceConstructorAdapter(startOffset, endOffset, descriptor)
val irAdapterRef = IrFunctionReferenceImpl(
startOffset, endOffset,
type = irReferenceType,
symbol = irAdapterFun.symbol,
typeArgumentsCount = irAdapterFun.typeParameters.size,<|endoftext|>
|
if (this.d != null) <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String? & kotlin.String")!>d<!>.propAny
if (this.d != null) <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String? & kotlin.String")!>d<!>.propNullableT
|
if (this.d != null) <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String? & kotlin.String")!>d<!>.propNullableAny
if (this.d != null) <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String? & kotlin.String")!>d<!>.funT()<|endoftext|>
|
@kotlinx.cinterop.ObjCMethod("ofpn:s:", "", false)
fun overloadedFunctionByParameterNames(i: Int, s: String) {
}
@kotlinx.cinterop.ObjCMethod("ofpn:xs:", "", false)
fun overloadedFunctionByParameterNames(xi: Int, xs: String) {
}
|
fun functionMismatchedParameterCount1(i: Int, s: String, l: List<Double>) {}
fun functionMismatchedParameterCount2(i: Int, s: String) {}
fun functionMismatchedParameterTypes1(i: Short, s: String) {}
fun functionMismatchedParameterTypes2(i: Int, s: CharSequence) {}<|endoftext|>
|
log += "6"
} catch (e: Throwable) {
log += "7"
"OK2"
} finally {
log += "8"
"FINALLY2"
}
}
var throw1 = false
var throw2 = false
fun mightThrow() {
if (throw1) throw Exception()
}
fun mightThrow2() {
|
if (throw2) throw Exception()
}
fun box(): String {
log += "a"
foo()
throw2 = true
log += " b"
foo()
throw1 = true
log += " c"
foo()
if (log != "a124568 b124578 c134578")
return "Failed: $log"
return "OK"<|endoftext|>
|
import kotlin.script.experimental.host.FileScriptSource
import kotlin.script.experimental.host.ScriptingHostConfiguration
import kotlin.script.experimental.impl.internalScriptingRunSuspend
import kotlin.script.experimental.jvm.*
import kotlin.script.experimental.jvm.compat.mapLegacyDiagnosticSeverity
|
import kotlin.script.experimental.jvm.compat.mapLegacyScriptPosition
import kotlin.script.experimental.jvmhost.CompiledScriptJarsCache
import kotlin.script.experimental.jvmhost.jsr223.configureProvidedPropertiesFromJsr223Context
import kotlin.script.experimental.jvmhost.jsr223.importAllBindings<|endoftext|>
|
// Groups are Lower, Upper, ASCII, Alpha, Digit, XDigit, Alnum, Punct,
// Graph, Print, Blank, Space, Cntrl
// Test \p{Lower}
/*
* FIXME: Requires complex range processing p = Regex("<\\p{Lower}\\d\\P{Lower}:[\\p{Lower}Z]\\s[^\\P{Lower}]>");
|
* m = p.matcher("<a4P:g x>"); assertTrue(m.matches()); m = p.matcher("<p4%:Z\tq>");
* assertTrue(m.matches()); m = p.matcher("<A6#:e e>");
* assertFalse(m.matches());
*/
regex = Regex("\\p{Lower}+")<|endoftext|>
|
// EXPECTED_REACHABLE_NODES: 1291
package foo
open class A {
private val a = 1
private val b = 2
get() {
return field + 10 + 100 * a
}
fun getBInA(): Int {
return b
}
}
class B : A() {
val a = 13
val b = 42
}
|
fun box(): String {
val b = B()
if (b.getBInA() != 112) return "b.getBInA() != 112, it: ${b.getBInA()}"
if (b.a != 13) return "b.a != 13, it: ${b.a}"<|endoftext|>
|
val major: Int = numbers.getOrNull(0) ?: UNKNOWN
val minor: Int = numbers.getOrNull(1) ?: UNKNOWN
val patch: Int = numbers.getOrNull(2) ?: UNKNOWN
val rest: List<Int> = if (numbers.size > 3) {
if (numbers.size > MAX_LENGTH)
|
throw IllegalArgumentException("BinaryVersion with length more than $MAX_LENGTH are not supported. Provided length ${numbers.size}.")
else
numbers.asList().subList(3, numbers.size).toList()
} else emptyList()
@Deprecated("Please use isCompatibleWithCurrentCompilerVersion()", ReplaceWith("isCompatibleWithCurrentCompilerVersion()"))<|endoftext|>
|
// test.kt:7 id: obj:java.lang.Object=java.lang.Integer
|
// test.kt:35 box: $completion:kotlin.coroutines.Continuation=Generated_Box_MainKt$main$1, $continuation:kotlin.coroutines.Continuation=TestKt$box$1, $result:java.lang.Object=null, $i$f$baz:int=0:int, $i$f$bar:int=0:int,<|endoftext|>
|
X().foo(y, <!ARGUMENT_TYPE_MISMATCH!>t<!>)
}
fun testOut(y: X.Y<out Any>, t: Any) {
X().foo(y, <!ARGUMENT_TYPE_MISMATCH!>t<!>)
}
fun testIn(y: X.Y<in Any>, t: Any) {
|
X().foo(y, t)
}
fun <T : Any> testWithParameter(y: X.Y<T>, t: Any) {
X().foo(y, <!ARGUMENT_TYPE_MISMATCH!>t<!>)
}
fun <T : Any> testWithCapturedParameter(y: X.Y<out T>, t: Any) {<|endoftext|>
|
object JavaAnnotationMapper {
internal val DEPRECATED_ANNOTATION_MESSAGE = Name.identifier("message")
internal val TARGET_ANNOTATION_ALLOWED_TARGETS = Name.identifier("allowedTargets")
internal val RETENTION_ANNOTATION_VALUE = Name.identifier("value")
fun mapOrResolveJavaAnnotation(
|
annotation: JavaAnnotation,
c: LazyJavaResolverContext,
isFreshlySupportedAnnotation: Boolean = false
): AnnotationDescriptor? =
when (annotation.classId) {
ClassId.topLevel(TARGET_ANNOTATION) -> JavaTargetAnnotationDescriptor(annotation, c)<|endoftext|>
|
internal val descImplType = Type.getObjectType("kotlinx/serialization/internal/$SERIAL_DESCRIPTOR_CLASS_IMPL")
internal val descriptorForEnumsType = Type.getObjectType("kotlinx/serialization/internal/$SERIAL_DESCRIPTOR_FOR_ENUM")
|
internal val generatedSerializerType = Type.getObjectType("kotlinx/serialization/internal/${SerialEntityNames.GENERATED_SERIALIZER_CLASS}")
internal val kOutputType = Type.getObjectType("kotlinx/serialization/encoding/$STRUCTURE_ENCODER_CLASS")<|endoftext|>
|
val result = doCreateSerializerProperty(
thisDescriptor,
SerialEntityNames.SERIAL_DESC_FIELD_NAME,
propertyFromSerializer.type,
propertyFromSerializer.typeParameters,
DescriptorVisibilities.PUBLIC,
Modality.OPEN // TODO: it was historically OPEN, but I do not see the reasons not to change to FINAL
)
|
result.overriddenDescriptors = listOf(propertyFromSerializer)
return result
}
private fun doCreateSerializerProperty(
thisDescriptor: ClassDescriptor,
name: Name,
type: KotlinType,
typeParameters: List<TypeParameterDescriptor> = emptyList(),
visibility: DescriptorVisibility = DescriptorVisibilities.PRIVATE,<|endoftext|>
|
public inline fun DOMPointInit(x: Double? = 0.0, y: Double? = 0.0, z: Double? = 0.0, w: Double? = 1.0): DOMPointInit {
val o = js("({})")
o["x"] = x
o["y"] = y
o["z"] = z
o["w"] = w
return o
}
/**
|
* Exposes the JavaScript [DOMRect](https://developer.mozilla.org/en/docs/Web/API/DOMRect) to Kotlin
*/
public external open class DOMRect(x: Double = definedExternally, y: Double = definedExternally, width: Double = definedExternally, height: Double = definedExternally) : DOMRectReadOnly {
override var x: Double
override var y: Double<|endoftext|>
|
fun interface IFooIntArray {
fun foo(x: IntArray): IntArray
}
fun interface IFooMix0 : IFooT<IntArray>, IFooIntArray
fun interface IFooMix1 : IFooT<IntArray>, IFooIntArray {
override fun foo(x: IntArray): IntArray
}
fun box(): String {
var t0 = "Failed 0"
|
val f0 = IFooMix0 {
t0 = "O" + it[0].toChar()
it
}
f0.foo(intArrayOf('K'.toInt()))
if (t0 != "OK")
return "Failed: t0=$t0"
var t1 = "Failed 1"
val f1 = IFooMix1 {<|endoftext|>
|
expectFailure(linkage("Class initialization error: Constructor 'Local.<init>' should call a constructor of direct super class 'InterfaceToAbstractClass' but calls 'Any.<init>' instead")) { getInterfaceToAbstractClassAsAny2() }
|
expectFailure(linkage("Anonymous object initialization error: Constructor '<init>' should call a constructor of direct super class 'InterfaceToOpenClass' but calls 'Any.<init>' instead")) { getInterfaceToOpenClass() }<|endoftext|>
|
parcel.setDataPosition(0)
val first2 = readFromParcel<Test>(parcel)
assert(first == first2)
assert((first.c as HashMap<*, *>).size == 1)
assert((first2.e as TreeMap<*, *>).size == 1)
assert(first2.f is SortedMap<*, *>)
|
assert(first2.g is NavigableMap<*, *>)
}<|endoftext|>
|
fun test1(int: Int, any: Any) {
val a0 : MyList<Any> = getMyList(int)
val a1 : MyList<Int> = <!TYPE_MISMATCH, TYPE_MISMATCH!>getMyList(any)<!>
val a2 : MyList<out Any> = getMyList(int)
|
val a3 : MyList<out Any> = getMyListToReadFrom(int)
val a4 : MyList<in Int> = getMyList(any)
val a5 : MyList<in Int> = getMyListToWriteTo(any)<|endoftext|>
|
backingContainer: DomainObjectSet<NativeBinary>
) : AbstractKotlinNativeBinaryContainer(),
DomainObjectSet<NativeBinary> by backingContainer
{
final override val project: Project
get() = target.project
private val defaultCompilation: KotlinNativeCompilation
|
get() = target.compilations.getByName(KotlinCompilation.MAIN_COMPILATION_NAME)
private val defaultTestCompilation: KotlinNativeCompilation
get() = target.compilations.getByName(KotlinCompilation.TEST_COMPILATION_NAME)
private val nameToBinary = mutableMapOf<String, NativeBinary>()<|endoftext|>
|
ExpectedData(0x43c6252411ee3beUL, 0x2247a4b2058d1c50UL, 0x1b3fa184b1d7bcc0UL, 0xdeb85613995c06edUL, 0xcbe1d957485a3ccdUL),
|
ExpectedData(0xce38a9a54fad6599UL, 0xe8b9ee96efa2d0eUL, 0x90122905c4ab5358UL, 0x84f80c832d71979cUL, 0x229310f3ffbbf4c6UL),<|endoftext|>
|
val DELEGATE_SPECIAL_FUNCTION_RETURN_TYPE_MISMATCH: KtDiagnosticFactory3<String, ConeKotlinType, ConeKotlinType> by error3<KtExpression, String, ConeKotlinType, ConeKotlinType>()
|
val UNDERSCORE_IS_RESERVED: KtDiagnosticFactory0 by error0<PsiElement>(SourceElementPositioningStrategies.NAME_IDENTIFIER)
val UNDERSCORE_USAGE_WITHOUT_BACKTICKS: KtDiagnosticFactory0 by error0<PsiElement>(SourceElementPositioningStrategies.NAME_IDENTIFIER)<|endoftext|>
|
// !LANGUAGE: +ExpectedTypeFromCast
fun foo() = 1
fun <T> foo() = foo() <!UNCHECKED_CAST!>as T<!>
fun <T> foo2(): T = TODO()
|
val test = <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>foo2<!>().<!DEBUG_INFO_MISSING_UNRESOLVED!>plus<!>("") as String
fun <T> T.bar() = this
val barTest = "".bar() <!CAST_NEVER_SUCCEEDS!>as<!> Number<|endoftext|>
|
require(setterVisibility == null) { "isVar = false but setterVisibility is specified. Did you forget to set isVar = true?" }
}
if (hasBackingField) {
backingField = FirDefaultPropertyBackingField(
session.moduleData,
key.origin,
source = null,
mutableListOf(),
returnTypeRef,
isVar,
|
symbol,
status,
resolvePhase = FirResolvePhase.BODY_RESOLVE,
)
}
isLocal = false
bodyResolveState = FirPropertyBodyResolveState.ALL_BODIES_RESOLVED
}
}
}
// ---------------------------------------------------------------------------------------------------------------------
/**
* Creates a member property for [owner] class with [returnType] return type<|endoftext|>
|
fun <V : Value> Frame<V>.peekWords(size1: Int, size2: Int): List<V>? {
val result = ArrayList<V>(size1 + size2)
val offset = peekWordsTo(result, size1)
if (offset < 0) return null
if (peekWordsTo(result, size2, offset) < 0) return null
return result
}
|
class SavedStackDescriptor(
val savedValues: List<FixStackValue>,
val firstLocalVarIndex: Int
) {
private val savedValuesSize = savedValues.fold(0) { size, value -> size + value.size }
val firstUnusedLocalVarIndex = firstLocalVarIndex + savedValuesSize
override fun toString(): String =<|endoftext|>
|
private fun removeUselessDeclarationsFromCapturedConstructors(irClass: IrClass, data: Data) {
irClass.parents.first { it !is IrFunction || it.origin != JvmLoweredDeclarationOrigin.INLINE_LAMBDA }
.accept(this, data.copy(classDeclaredOnCallSiteOrIsDefaultLambda = false, modifyTree = false))
}
|
override fun visitCall(expression: IrCall, data: Data): IrElement {
if (expression.symbol == context.ir.symbols.singleArgumentInlineFunction) return expression
return super.visitCall(expression, data)
}
override fun visitBlock(expression: IrBlock, data: Data): IrExpression {
if (expression is IrInlinedFunctionBlock) {<|endoftext|>
|
is SirInit -> initKind.print()
is SirFunction -> kind.print()
is SirGetter -> print("get")
is SirSetter -> print("set")
}
private fun SirCallable.printName() = print(
when (this) {
is SirInit -> "init"
is SirFunction -> "func $name"
is SirGetter,
|
is SirSetter
-> ""
}
)
private fun SirCallable.printPostNameKeywords() = when (this) {
is SirInit -> "?".takeIf { isFailable }?.let { print(it) }
is SirFunction,
is SirGetter,
is SirSetter
-> print("")
}<|endoftext|>
|
// test.kt:20 baz: param:int=6:int, b:int=2:int, $i$f$inlineCall:int=0:int, e$iv:int=5:int, $i$a$-inlineCall-TestKt$bar$1$baz$1:int=0:int, g:int=7:int
|
// test.kt:27 baz: param:int=6:int, b:int=2:int, $i$f$inlineCall:int=0:int, e$iv:int=5:int
// test.kt:28 baz: param:int=6:int, b:int=2:int, $i$f$inlineCall:int=0:int, e$iv:int=5:int<|endoftext|>
|
package org.jetbrains.kotlin.analysis.api.annotations
import org.jetbrains.kotlin.descriptors.annotations.AnnotationUseSiteTarget
import org.jetbrains.kotlin.name.ClassId
import org.jetbrains.kotlin.psi.KtCallElement
/**
* A lightweight implementation of [KtAnnotationApplication].
|
* Should be used instead of [KtAnnotationApplicationWithArgumentsInfo] where possible to avoid redundant resolve.
*
* Example:
* ```
* @Anno1(1) @Anno2
* class Foo
* ```
* In this case if you don't want to process [KtAnnotationApplicationWithArgumentsInfo.arguments]<|endoftext|>
|
package org.jetbrains.kotlin.sir.providers.impl
import org.jetbrains.kotlin.analysis.project.structure.KtModule
import org.jetbrains.kotlin.sir.SirModule
import org.jetbrains.kotlin.sir.builder.buildImport
import org.jetbrains.kotlin.sir.builder.buildModule
|
import org.jetbrains.kotlin.sir.providers.SirModuleProvider
import org.jetbrains.kotlin.sir.util.addChild
/**
* An implementation of [SirModuleProvider] that stores all declarations under a single module
*/
public class SirSingleModuleProvider(
private val swiftModuleName: String,
private val bridgeModuleName: String,
) : SirModuleProvider {<|endoftext|>
|
out.println(" * whereas the ${msb(type.bitSize - otherType.bitSize)} are filled with the sign bit of this value.")
}
otherType == type -> {
out.println(" * If this value is positive, the resulting `$className` value represents the same numerical value as this `$otherSigned`.")
out.println(" *")
|
out.println(" * The resulting `$className` value has the same binary representation as this `$otherSigned` value.")
}
else -> {
out.println(" * If this value is positive and less than or equals to [$className.MAX_VALUE], the resulting `$className` value represents")
out.println(" * the same numerical value as this `$otherSigned`.")<|endoftext|>
|
insertBefore(capturedVar.newInsn, VarInsnNode(storeOpcode, capturedVar.localVarIndex))
}
for (insn in localVar.findCleanInstructions()) {
// after visiting block codegen tries to delete all allocated references:
// see ExpressionCodegen.addLeaveTaskToRemoveLocalVariableFromFrameMap
if (storeOpcode == Opcodes.ASTORE) {
|
set(insn.previous, InsnNode(AsmUtil.defaultValueOpcode(capturedVar.valueType)))
} else {
remove(insn.previous)
remove(insn)
}
}
localVar.index = capturedVar.localVarIndex
localVar.desc = capturedVar.valueType.descriptor
localVar.signature = null<|endoftext|>
|
return if (expressions.size == 1)
expressions.single()
else
expressions.reduce { lhs, rhs -> irOrOr(lhs, rhs) }
}
override fun irCopyToTemporary(
nameHint: String?,
isVar: Boolean,
exactName: Boolean
): IrChangedBitMaskVariable {
used = true
|
val temps = params.mapIndexed { index, param ->
IrVariableImpl(
UNDEFINED_OFFSET,
UNDEFINED_OFFSET,
// We label "dirty" as a defined variable instead of a temporary, so that it
// is properly stored in the locals table and discoverable by debuggers. The
// dirty variable encodes information that could be useful for tooling to<|endoftext|>
|
assertFalse(eqByteQByte(undefined, 1.toByte()))
assertTrue(eqByteQByteQ(0.toByte(), 0.toByte()))
assertFalse(eqByteQByteQ(0.toByte(), 1.toByte()))
assertFalse(eqByteQByteQ(0.toByte(), null))
assertFalse(eqByteQByteQ(0.toByte(), undefined))
|
assertFalse(eqByteQByteQ(1.toByte(), 0.toByte()))
assertTrue(eqByteQByteQ(1.toByte(), 1.toByte()))
assertFalse(eqByteQByteQ(1.toByte(), null))
assertFalse(eqByteQByteQ(1.toByte(), undefined))
assertFalse(eqByteQByteQ(null, 0.toByte()))<|endoftext|>
|
for (x in 0..1) {
f(x)
}
}
// EXPECTATIONS JVM_IR
// test.kt:10 box: $completion:kotlin.coroutines.Continuation=Generated_Box_MainKt$main$1
|
// test.kt:12 box: $completion:kotlin.coroutines.Continuation=Generated_Box_MainKt$main$1, $continuation:kotlin.coroutines.Continuation=TestKt$box$1, $result:java.lang.Object=null<|endoftext|>
|
fun I.canBeApply(): Boolean = true
fun I.getDescriptor(): CallableDescriptor
fun I.getArgs(): List<JsExpression>
fun intrinsic(callInfo: I, context: TranslationContext): JsExpression? = if (callInfo.canBeApply()) callInfo.getIntrinsic(context) else null
|
private fun I.getIntrinsic(context: TranslationContext): JsExpression? {
val descriptor = getDescriptor()
// Now intrinsic support only FunctionDescriptor. See DelegatePropertyAccessIntrinsic.getDescriptor()
if (descriptor is FunctionDescriptor) {
val intrinsic = context.intrinsics().getFunctionIntrinsic(descriptor, context)<|endoftext|>
|
val errorAnonymousObjectExn = <!INNER_CLASS_OF_GENERIC_THROWABLE_SUBCLASS_WARNING!>object<!> : Exception() {}
fun foo() {
<!INNER_CLASS_OF_GENERIC_THROWABLE_SUBCLASS_WARNING!>class OkLocalExn<!> : Exception()
|
val errorAnonymousObjectExn = <!INNER_CLASS_OF_GENERIC_THROWABLE_SUBCLASS_WARNING!>object<!> : Exception() {}
}
fun <X> genericFoo() {
<!INNER_CLASS_OF_GENERIC_THROWABLE_SUBCLASS_WARNING!>class OkLocalExn<!> : Exception()<|endoftext|>
|
trace.report(REDUNDANT_LABEL_WARNING.on(labelNameExpression))
}
}
}
override fun visitBinaryExpression(expression: KtBinaryExpression) {
val operationReference = expression.operationReference
val operationType = operationReference.getReferencedNameElementType()
val left = expression.left
val right = expression.right
|
if (operationType === ANDAND || operationType === OROR) {
generateBooleanOperation(expression)
} else if (operationType === EQ) {
visitAssignment(left, getDeferredValue(right), expression)
} else if (OperatorConventions.ASSIGNMENT_OPERATIONS.containsKey(operationType)) {<|endoftext|>
|
@kotlin.internal.IntrinsicConstEvaluation
public operator fun plus(other: Short): Int
/** Adds the other value to this value. */
@kotlin.internal.IntrinsicConstEvaluation
public operator fun plus(other: Int): Int
/** Adds the other value to this value. */
|
@kotlin.internal.IntrinsicConstEvaluation
public operator fun plus(other: Long): Long
/** Adds the other value to this value. */
@kotlin.internal.IntrinsicConstEvaluation
public operator fun plus(other: Float): Float
/** Adds the other value to this value. */<|endoftext|>
|
@GradleTest
fun testHostSpecificBuildWithPublishedDependency(
gradleVersion: GradleVersion,
@TempDir localRepo: Path
) {
testBuildWithDependency(gradleVersion, localRepo) {
publishProjectDepAndAddDependency(validateHostSpecificPublication = true)
}
}
|
@DisplayName("Works with Kotlin native transitive dependencies")
@GradleTest
fun testKotlinNativeImplPublishedDeps(
gradleVersion: GradleVersion,
@TempDir localRepo: Path
) {
testKotlinNativeImplementationDependencies(gradleVersion, localRepo) {<|endoftext|>
|
val classPath = classPathUrls.mapNotNullTo(mutableListOf(this)) { cpEntry ->
File(URI(cpEntry)).takeIf { it.exists() } ?: File(cpEntry).takeIf { it.exists() }
}
if (!checkMissingDependencies || classPathUrls.size + 1 == classPath.size) {
|
return KJvmCompiledScriptLazilyLoadedFromClasspath(className, classPath)
} else {
// Assuming that some script dependencies are not accessible anymore so the script is not valid and should be recompiled to reresolve dependencies
return null
}
}
open class BasicJvmScriptJarGenerator(val outputJar: File) : ScriptEvaluator {<|endoftext|>
|
override fun testBad(x: Any) =
reifiedSafeAsReturnsNull<Function4<*, *, *, *, *>>(
x, "x as? Function4<*, *, *, *, *>")
}
object TestFn5 : TestFnBase {
override fun testGood(x: Any) =
|
reifiedSafeAsReturnsNonNull<Function5<*, *, *, *, *, *>>(
x, "x as? Function5<*, *, *, *, *, *>")
override fun testBad(x: Any) =
reifiedSafeAsReturnsNull<Function5<*, *, *, *, *, *>>(<|endoftext|>
|
if (y !is Int) throw Exception()
|
var z = select(select(select(select(<!DEBUG_INFO_SMARTCAST!>y<!>), select(<!DEBUG_INFO_SMARTCAST!>y<!>)), select(select(<!DEBUG_INFO_SMARTCAST!>y<!>), select(<!DEBUG_INFO_SMARTCAST!>y<!>))),<|endoftext|>
|
// WITH_STDLIB
class OutPair<out T, out E>
class Out<out F>
class In<in H>
class X
fun simpleOut(x: Out<@JvmWildcard X>) {}
// method: OnTypesKt::simpleOut
// generic signature: (LOut<+LX;>;)V
|
fun simpleIn(x: In<@JvmWildcard Any?>) {}
// method: OnTypesKt::simpleIn
// generic signature: (LIn<-Ljava/lang/Object;>;)V<|endoftext|>
|
const val toString3 = <!CONST_VAL_WITH_NON_CONST_INITIALIZER!>intVal.toString()<!>
const val toString4 = <!CONST_VAL_WITH_NON_CONST_INITIALIZER!>longVal.toString()<!>
|
const val equals1 = <!CONST_VAL_WITH_NON_CONST_INITIALIZER!>byteVal.equals(byteVal)<!>
const val equals2 = <!CONST_VAL_WITH_NON_CONST_INITIALIZER!>byteVal.equals(shortVal)<!><|endoftext|>
|
buildMetrics[metric]?.let { printSizeMetric(metric, it) }
}
}
}
private fun Printer.printSizeMetric(sizeMetric: BuildPerformanceMetric, value: Long) {
fun BuildPerformanceMetric.numberOfAncestors(): Int {
var count = 0
var parent: BuildPerformanceMetric? = getParent()
|
while (parent != null) {
count++
parent = parent.getParent()
}
return count
}
val indentLevel = sizeMetric.numberOfAncestors()
repeat(indentLevel) { pushIndent() }
when (sizeMetric.getType()) {<|endoftext|>
|
* If the [index] is out of bounds of this string, throws an [IndexOutOfBoundsException] except in Kotlin/JS
* where the behavior is unspecified.
*/
@kotlin.internal.IntrinsicConstEvaluation
public override fun get(index: Int): Char {
rangeCheck(index, this.length)
return chars.get(index)
}
|
internal fun foldChars() {
val stringLength = this.length
val newArray = WasmCharArray(stringLength)
var currentStartIndex = stringLength
var currentLeftString: String? = this
while (currentLeftString != null) {
val currentLeftStringChars = currentLeftString._chars
val currentLeftStringLen = currentLeftStringChars.len()<|endoftext|>
|
// FILE: usage.kt
package first
import third.<!DEPRECATION!>JavaClass<!>.<!DEPRECATION!>NestedJavaClass<!>
// FILE: KotlinAnnotation.kt
package second
class KotlinClass {
fun foo(i: Int) {}
annotation class KotlinAnnotation
}
// FILE: third/JavaClass.java
package third;
|
import second.KotlinClass.*;
import static second.KotlinClass.*;
/**
* @deprecated deprecated message
*/
@KotlinAnnotation
public class JavaClass {
/**
* @deprecated deprecated message
*/
@KotlinAnnotation
public static class NestedJavaClass {
}
}<|endoftext|>
|
val PROCESSING_INSTRUCTION_NODE: Short
val COMMENT_NODE: Short
val DOCUMENT_NODE: Short
val DOCUMENT_TYPE_NODE: Short
val DOCUMENT_FRAGMENT_NODE: Short
val NOTATION_NODE: Short
val DOCUMENT_POSITION_DISCONNECTED: Short
|
val DOCUMENT_POSITION_PRECEDING: Short
val DOCUMENT_POSITION_FOLLOWING: Short
val DOCUMENT_POSITION_CONTAINS: Short
val DOCUMENT_POSITION_CONTAINED_BY: Short
val DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: Short
}
}<|endoftext|>
|
open fun visitBinaryOrExitLeftOperandNode(node: BinaryOrExitLeftOperandNode, data: D): R {
return visitNode(node, data)
}
open fun visitBinaryOrEnterRightOperandNode(node: BinaryOrEnterRightOperandNode, data: D): R {
return visitNode(node, data)
}
|
open fun visitBinaryOrExitNode(node: BinaryOrExitNode, data: D): R {
return visitNode(node, data)
}
// ----------------------------------- Operator call -----------------------------------
open fun visitTypeOperatorCallNode(node: TypeOperatorCallNode, data: D): R {
return visitNode(node, data)
}<|endoftext|>
|
override val transformer: FirTransformer<Nothing?> = FirExpectActualMatcherTransformer(session, scopeSession)
override fun processFile(file: FirFile) {
if (!enabled) return
super.processFile(file)
}
}
/**
* This transformer populates [expectForActual] mapping for actual declarations.
|
* Also, populates it [memberExpectForActual] mapping
*
* Should run before any kind of body resolution, since [expectForActual] is used there.
*
* See `/docs/fir/k2_kmp.md`
*/
open class FirExpectActualMatcherTransformer(
final override val session: FirSession,
private val actualScopeSession: ScopeSession,<|endoftext|>
|
package org.jetbrains.kotlin.jps.incremental
import org.jetbrains.kotlin.load.kotlin.JvmBytecodeBinaryVersion
import org.jetbrains.kotlin.metadata.jvm.deserialization.JvmMetadataVersion
import org.junit.Assert.assertEquals
import org.junit.Test
class CacheVersionTest {
|
@Test
fun testConstruct() {
assertEquals(
3011001,
CacheVersion(
3,
JvmBytecodeBinaryVersion(1, 0, 3),
JvmMetadataVersion(1, 1, 13)
).intValue
)
}
@Test
fun testDeconstruct() {
assertEquals(<|endoftext|>
|
* either throwing exception or returning some kind of implementation-specific default value.
*/
internal fun FloatArray.copyOfUninitializedElements(newSize: Int): FloatArray {
return copyOfUninitializedElements(0, newSize)
}
/**
* Returns new array which is a copy of the original array with new elements filled with **lateinit** _uninitialized_ values.
|
* Attempts to read _uninitialized_ values from this array work in implementation-dependent manner,
* either throwing exception or returning some kind of implementation-specific default value.
*/
internal fun DoubleArray.copyOfUninitializedElements(newSize: Int): DoubleArray {
return copyOfUninitializedElements(0, newSize)
}
/**<|endoftext|>
|
).also {
it.files = files
it.codegenFactory = codegenFactory
}
}
abstract class GenerateClassFilter {
abstract fun shouldAnnotateClass(processingClassOrObject: KtClassOrObject): Boolean
abstract fun shouldGenerateClass(processingClassOrObject: KtClassOrObject): Boolean
|
abstract fun shouldGeneratePackagePart(ktFile: KtFile): Boolean
abstract fun shouldGenerateScript(script: KtScript): Boolean
abstract fun shouldGenerateCodeFragment(script: KtCodeFragment): Boolean
open fun shouldGenerateClassMembers(processingClassOrObject: KtClassOrObject) = shouldGenerateClass(processingClassOrObject)
companion object {<|endoftext|>
|
val updatedFilesWithStubbedSignatures = hashMapOf<KotlinSourceFile, Set<IdSignature>>()
val fileArtifacts = klibSrcFiles.map { srcFile ->
val signatureMapping = signatureToIndexMapping[srcFile] ?: emptyMap()
val artifact = commitSourceFileMetadata(srcFile, signatureMapping)
|
val fileStubbedSignatures = when (artifact) {
is SourceFileCacheArtifact.CommitMetadata -> signatureMapping.keys.filterTo(hashSetOf()) { it in stubbedSignatures }
else -> filesWithStubbedSignatures[srcFile] ?: emptySet()
}
if (fileStubbedSignatures.isNotEmpty()) {<|endoftext|>
|
class G<E : <!FINAL_UPPER_BOUND!>Double<!>>(val balue: E) : F<E>(balue) {
override fun rest(): E = balue
}
|
class H<E : <!FINAL_UPPER_BOUND!>String<!>>(val balue: E) : F<<!UPPER_BOUND_VIOLATED!>E<!>>(<!ARGUMENT_TYPE_MISMATCH!>balue<!>) {
override fun rest(): E = balue // no report because of INAPPLICABLE_CANDIDATE
}<|endoftext|>
|
irScript.constructor = with(IrFunctionBuilder().apply {
isPrimary = true
returnType = irScript.thisReceiver!!.type as IrSimpleType
}) {
irScript.factory.createConstructor(
startOffset = startOffset,
endOffset = endOffset,
origin = origin,
name = SpecialNames.INIT,
visibility = visibility,
|
isInline = isInline,
isExpect = isExpect,
returnType = returnType,
symbol = context.symbolTable.descriptorExtension.referenceConstructor(descriptor.unsubstitutedPrimaryConstructor),
isPrimary = isPrimary,
isExternal = isExternal,
containerSource = containerSource
)
}.also { irConstructor -><|endoftext|>
|
, ) = Pair(1, 2)
}
class A<
T1: Number,
T2: Iterable<Iterable<Iterable<Number>>>,
T3: Comparable<Comparable<Comparable<Number>>>,
> { }
fun <
T1: Comparable<Comparable<Number>>,
T2: Iterable<Iterable<Number>>
,
|
> foo() {}
fun main() {
foo<Comparable<Comparable<Number>>, Iterable<Iterable<Number>>,>()
}
fun main() {
val x: (
y: Comparable<Comparable<Number>>,
z: Iterable<Iterable<Number>>,
) -> Int = { 10 }
val y = foo(1,) {}<|endoftext|>
|
val sourceSetNamesByVariantName: Map<String, Set<String>>,
@Input
val sourceSetsDependsOnRelation: Map<String, Set<String>>,
@Nested
val sourceSetBinaryLayout: Map<String, SourceSetMetadataLayout>,
@Internal
val sourceSetModuleDependencies: Map<String, Set<ModuleDependencyIdentifier>>,
|
@Input
val sourceSetCInteropMetadataDirectory: Map<String, String>,
@Input
val hostSpecificSourceSets: Set<String>,
@get:Input
val isPublishedAsRoot: Boolean,
@get:Input
val sourceSetNames: Set<String>,
@Input
val formatVersion: String = FORMAT_VERSION_0_3_3,<|endoftext|>
|
fun f(a : Boolean) : Unit {
1
a
2.toLong()
foo(a, 3)
genfun<Any>()
flfun {1}
3.equals(4)
3 equals 4
1 + 2
a && true
a || false
}
fun foo(a : Boolean, b : Int) : Unit {}
|
fun <T> genfun() : Unit {}
fun flfun(f : () -> Any) : Unit {}<|endoftext|>
|
val c1Typed: MFVC = MFVC(3, 4)
val a1Untyped: I = a1Typed
val b1Untyped: I = b1Typed
val c1Untyped: I = c1Typed
require(a1Typed == a1Typed && a1Untyped == a1Untyped)
|
require(a1Typed == b1Typed && a1Untyped == b1Untyped)
require(a1Typed != c1Typed && a1Untyped != c1Untyped)
require(b1Typed == a1Typed && b1Untyped == a1Untyped)<|endoftext|>
|
@kotlin.contracts.ExperimentalContracts
fun varInitializationOrReassignment() {
var x: Int
callsInPlaceAtLeastOnceContract {
x = 10
}
assertEquals(10, x)
}
@Sample
@kotlin.contracts.ExperimentalContracts
fun valInitialization() {
val x: Int
|
callsInPlaceExactlyOnceContract {
x = 10
}
assertEquals(10, x)
}
@Sample
@kotlin.contracts.ExperimentalContracts
fun varPossibleInitialization() {
var x: Int
callsInPlaceUnknownContract {
x = 10
assertEquals(10, x)
}
}<|endoftext|>
|
// LANGUAGE: +ErrorAboutDataClassCopyVisibilityChange, -DataClassCopyRespectsConstructorVisibility
data class Data protected constructor(val x: Int) {
fun member() {
copy()
this.copy()
}
companion object {
fun of(): Data {
return Data(1).copy()
}
}
}
fun topLevel(data: Data) {
|
data.copy()
}
fun Data.topLevelExtension() {
copy()
}
fun local() {
data class Local private constructor(val x: Int)
fun Local.foo() {
copy()
}
}<|endoftext|>
|
override val languageVersion: org.gradle.api.provider.Property<org.jetbrains.kotlin.gradle.dsl.KotlinVersion> =
objectFactory.property(org.jetbrains.kotlin.gradle.dsl.KotlinVersion::class.java)
|
override val optIn: org.gradle.api.provider.ListProperty<kotlin.String> =
objectFactory.listProperty(kotlin.String::class.java).convention(emptyList<String>())
override val progressiveMode: org.gradle.api.provider.Property<kotlin.Boolean> =<|endoftext|>
|
import org.jetbrains.kotlin.fir.types.ConeCapturedType
import org.jetbrains.kotlin.fir.types.coneType
import org.jetbrains.kotlin.fir.types.contains
import org.jetbrains.kotlin.fir.types.toRegularClassSymbol
|
object FirConstructorCallChecker : FirFunctionCallChecker(MppCheckerKind.Common) {
override fun check(expression: FirFunctionCall, context: CheckerContext, reporter: DiagnosticReporter) {
val constructorSymbol = expression.calleeReference.toResolvedConstructorSymbol() ?: return
val coneType = constructorSymbol.resolvedReturnTypeRef.coneType<|endoftext|>
|
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER
import kotlin.reflect.KProperty
interface A {
val prop: Int
}
class AImpl: A {
override val prop by Delegate()
}
fun foo() {
AImpl().prop
}
class Delegate {
|
operator fun getValue(t: Any?, p: KProperty<*>): Int {
return 1
}
}<|endoftext|>
|
abstract override fun replaceExtensionReceiver(newExtensionReceiver: FirExpression?)
@FirImplementationDetail
abstract override fun replaceSource(newSource: KtSourceElement?)
abstract override fun replaceNonFatalDiagnostics(newNonFatalDiagnostics: List<ConeDiagnostic>)
|
abstract override fun replaceArgumentList(newArgumentList: FirArgumentList)
abstract override fun replaceCalleeReference(newCalleeReference: FirNamedReference)
abstract override fun replaceCalleeReference(newCalleeReference: FirReference)
abstract override fun replaceExplicitReceiver(newExplicitReceiver: FirExpression?)<|endoftext|>
|
}
checkWhen(emptyArray(), null, packageClasses("kotlinProject", "src/test1.kt", "Test1Kt"))
}
@WorkingDir("KotlinProject")
fun testModuleRebuildOnJvmTargetChange() {
initProject(JVM_MOCK_RUNTIME)
myProject.modules.forEach {
|
val facet = KotlinFacetSettings()
facet.useProjectSettings = false
facet.compilerArguments = K2JVMCompilerArguments()
(facet.compilerArguments as K2JVMCompilerArguments).jvmTarget = "1.8"
it.container.setChild(
JpsKotlinFacetModuleExtension.KIND,<|endoftext|>
|
override fun getSource(): SourceElement = SourceElement.NO_SOURCE
override fun getOriginal(): ClassDescriptor = this
}
private class FakeActualPropertyDescriptor(original: PropertyDescriptor) : PropertyDescriptor by original {
override fun isActual(): Boolean = true
override fun isExpect(): Boolean = false
|
override fun getSource(): SourceElement = SourceElement.NO_SOURCE
override fun getOriginal(): PropertyDescriptor = this
}
private class FakeActualClassConstructorDescriptor(original: ClassConstructorDescriptor) : ClassConstructorDescriptor by original {
override fun isActual(): Boolean = true
override fun isExpect(): Boolean = false<|endoftext|>
|
operator fun minus(x: Long): Unit = TODO() //(1.2)
operator fun minus(x: Short): Unit = TODO() //(1.3)
operator fun minus(x: Byte): Unit = TODO() //(1.4)
}
fun case4(case: Case4) {
case.apply {
//to (1.1)
|
<!DEBUG_INFO_CALL("fqName: Case4.minus; typeCall: operator function")!>minus(1)<!>
//(1.1) return type is String
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String")!>minus(1)<!>
//to (1.1)<|endoftext|>
|
// FIR_IDENTICAL
// !DIAGNOSTICS: +RUNTIME_ANNOTATION_NOT_SUPPORTED
@Retention(AnnotationRetention.BINARY)
annotation class X
@Retention(AnnotationRetention.RUNTIME)
annotation class Y
@X
external class A {
@X
fun f()
@X
val p: Int
|
@get:X
val r: Int
}
<!RUNTIME_ANNOTATION_ON_EXTERNAL_DECLARATION!>@Y<!>
external class B {
<!RUNTIME_ANNOTATION_ON_EXTERNAL_DECLARATION!>@Y<!>
fun f()<|endoftext|>
|
*/
@SinceKotlin("2.0")
@Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS")
public actual fun String.toCharArray(
destination: CharArray,
destinationOffset: Int = 0,
startIndex: Int = 0,
endIndex: Int = length
): CharArray {
|
AbstractList.checkBoundsIndexes(startIndex, endIndex, length)
val rangeSize = endIndex - startIndex
AbstractList.checkBoundsIndexes(destinationOffset, destinationOffset + rangeSize, destination.size)
return toCharArray(this, destination, destinationOffset, startIndex, rangeSize)
}
/**
* Decodes a string from the bytes in UTF-8 encoding in this array.
*<|endoftext|>
|
StateMachineChecker.suspendHere()
StateMachineChecker.suspendHere()
}
// FILE: box.kt
import helpers.*
import kotlin.coroutines.*
fun builder(c: suspend () -> Unit) {
c.startCoroutine(CheckStateMachineContinuation)
}
fun box(): String {
StateMachineChecker.reset()
|
val r = inlineMe2 {
StateMachineChecker.suspendHere()
StateMachineChecker.suspendHere()
}
builder {
r.run()
}
StateMachineChecker.check(numberOfSuspensions = 2)
StateMachineChecker.reset()
builder {
r.run2()
}<|endoftext|>
|
String[] stra() default {"bu", "zz"};
Class<?>[] ka() default {double.class, String.class, long[].class, Integer[][][].class, void.class};
// E[] ea() default {E.E2, E.E3};
// TODO: A[] aa() default {@A("2"), @A("3")};
}
|
// FILE: anno.kt
actual typealias Anno = Jnno
// MODULE: main(lib)
// FILE: main.kt
annotation class A(val value: String)
@Anno
fun test() {}
fun box(): String {
// We don't need to check the contents, just check that there are no anomalities in the bytecode by loading annotations<|endoftext|>
|
"OROR" -> when (typeA) {
"kotlin.Boolean" -> if (typeB == "kotlin.Boolean") return (a as Boolean) || (b as Boolean)
}
"mod" -> when (typeA) {
"kotlin.Byte" -> when (typeB) {
|
"kotlin.Byte" -> return (a as Byte).mod(b as Byte)
"kotlin.Short" -> return (a as Byte).mod(b as Short)
"kotlin.Int" -> return (a as Byte).mod(b as Int)
"kotlin.Long" -> return (a as Byte).mod(b as Long)
}<|endoftext|>
|
val moduleFile = File(tmpdir.absolutePath, "META-INF/main.kotlin_module").readBytes()
val versionNumber = ModuleMapping.readVersionNumber(DataInputStream(ByteArrayInputStream(moduleFile)))!!
val moduleVersion = JvmMetadataVersion(*versionNumber)
if (languageVersion == LanguageVersion.KOTLIN_2_0) {
|
assertEquals("Actual version: $moduleVersion", JvmMetadataVersion(1, 9, 9999), moduleVersion)
} else {
assertEquals("Actual version: $moduleVersion", expectedMajor, moduleVersion.major)
assertEquals("Actual version: $moduleVersion", expectedMinor, moduleVersion.minor)
}
}
}<|endoftext|>
|
// 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 <T : Collection<*>> test(c: T) {
var sum = 0
for (i in c.indices) {
sum += i
}
}
// 0 iterator
// 0 getStart
// 0 getEnd<|endoftext|>
|
// TARGET_BACKEND: JVM
// WITH_STDLIB
enum class E {
A;
companion object {
@JvmStatic
fun values(): Array<String> = arrayOf("OK")
@JvmStatic
fun E.values(): Array<E> = arrayOf(A)
@JvmStatic
|
fun values(x: Int): Array<E> = arrayOf(A)
}
}
fun f(e: E) = when (e) {
E.A -> "OK"
}
fun box(): String {
return f(E.A)
}<|endoftext|>
|
import org.jetbrains.kotlin.gradle.utils.named
import kotlin.test.*
class PublishJvmEnvironmentAttributeTest {
@Test
fun `test - default value`() = buildProjectWithMPP().runLifecycleAwareTest {
val kotlin = multiplatformExtension
kotlin.jvm()
configurationResult.await()
|
assertTrue(kotlinPropertiesProvider.publishJvmEnvironmentAttribute)
assertJvmEnvironmentAttributeEquals(kotlin.jvm(), STANDARD_JVM)
}
@Test
fun `test - publishJvmEnvironmentAttribute disabled`() = buildProjectWithMPP().runLifecycleAwareTest {
val kotlin = multiplatformExtension
kotlin.jvm()<|endoftext|>
|
public constructor IntArray(size: kotlin.Int, init: (kotlin.Int) -> kotlin.Int)
public final val size: kotlin.Int { get; }
public final operator fun get(index: kotlin.Int): kotlin.Int
public final operator fun iterator(): kotlin.collections.IntIterator
|
public final operator fun set(index: kotlin.Int, value: kotlin.Int): kotlin.Unit
}
@kotlin.SinceKotlin(version = "1.1")
public final class KotlinVersion : kotlin.Comparable<kotlin.KotlinVersion> {
public constructor KotlinVersion(major: kotlin.Int, minor: kotlin.Int)<|endoftext|>
|
// WITH_STDLIB
/*
* KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
*
* SPEC VERSION: 0.1-213
* MAIN LINK: expressions, built-in-types-and-their-semantics, kotlin.nothing-1 -> paragraph 1 -> sentence 1
* NUMBER: 10
* DESCRIPTION: ckeck a common type of String and Nothing is String
*/
|
fun box(): String {
var name: Any? = null
val men = arrayListOf(Man("Phill"), Man())
loop@ for (i in men) {
name = i.name ?: break@loop
}
if (name is String?) return "OK"
return "NOK"
}
private class Man(var name: String? = null) {}<|endoftext|>
|
import org.jetbrains.kotlin.analysis.api.standalone.base.project.structure.LLFirStandaloneLibrarySymbolProviderFactory
import org.jetbrains.kotlin.analysis.api.standalone.base.project.structure.StandaloneProjectFactory
|
import org.jetbrains.kotlin.analysis.api.standalone.base.services.LLStandaloneFirElementByPsiElementChooser
import org.jetbrains.kotlin.analysis.low.level.api.fir.api.services.LLFirElementByPsiElementChooser<|endoftext|>
|
println(C().<!INVISIBLE_REFERENCE!>propAI<!>.x())
println(C().<!INVISIBLE_REFERENCE!>propG<!>.x())
println(C().<!INVISIBLE_REFERENCE!>propOI<!>.df())
println(C().<!INVISIBLE_REFERENCE!>propL<!>.l())
|
println(C().<!INVISIBLE_REFERENCE!>propL2<!>.l2())
}<|endoftext|>
|
addAll(arrayMap)
add(attribute)
}
return ConeAttributes(newAttributes)
}
fun remove(attribute: ConeAttribute<*>): ConeAttributes {
if (isEmpty()) return this
val attributes = arrayMap.filter { it != attribute }
if (attributes.size == arrayMap.size) return this
return create(attributes)
}
|
fun filterNecessaryToKeep(): ConeAttributes {
return if (all { it.keepInInferredDeclarationType }) this
else create(filter { it.keepInInferredDeclarationType })
}
private inline fun perform(other: ConeAttributes, op: ConeAttribute<*>.(ConeAttribute<*>?) -> ConeAttribute<*>?): ConeAttributes {<|endoftext|>
|
for (element in list) {
if (element != implicitNullableNothingProperty && true && true && true) else { break }
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int? & kotlin.Int")!>element<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int? & kotlin.Int")!>element<!>.inv()
|
}
}
// TESTCASE NUMBER: 10
fun case_10(x: Float?) {
while (false) {
if (true && true && true && x !== null) else break
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Float?")!>x<!><|endoftext|>
|
val List<MutableSet<Array<CharSequence>>>.l: Any get() = this
fun box(): String {
check("kotlin.Boolean", Boolean::x)
check("kotlin.Char", Char::x)
check("kotlin.Byte", Byte::x)
check("kotlin.Short", Short::x)
check("kotlin.Int", Int::x)
|
check("kotlin.Float", Float::x)
check("kotlin.Long", Long::x)
check("kotlin.Double", Double::x)
check("kotlin.BooleanArray", BooleanArray::x)
check("kotlin.CharArray", CharArray::x)
check("kotlin.ByteArray", ByteArray::x)<|endoftext|>
|
val proxyFunBody = context.irFactory.createBlockBody(startOffset, endOffset).also { proxyFun.body = it }
when {
targetFun.returnType.isUnit() -> {
proxyFunBody.statements.add(targetCall)
}
else -> {
proxyFunBody.statements.add(
IrReturnImpl(
startOffset, endOffset,
|
context.irBuiltIns.nothingType,
proxyFun.symbol,
targetCall
)
)
}
}
}
val proxyFunRef = IrFunctionReferenceImpl(
startOffset, endOffset,
reference.type,
proxyFun.symbol,
0, // TODO generic function reference?
proxyFun.valueParameters.size
)<|endoftext|>
|
@file:Suppress("UNUSED_VARIABLE", "UNUSED_PARAMETER")
package usage
import a.*
fun baz(param: A, nested: A.Nested) {
val constructor = A()
val nested2 = A.Nested()
val methodCall = param.method()
val supertype = object : A() {}
val x = foo()
|
val y = bar
bar = 239
val z: TA = ""
}<|endoftext|>
|
// WITH_STDLIB
// WORKS_WHEN_VALUE_CLASS
// LANGUAGE: +ValueClasses, +GenericInlineClassParameter
class Foo {
companion object {
var a: Int = 42
private var d by Delegate(0)
fun d() = d
fun d(newValue: Int) { d = newValue }
}
}
|
var setterInvoked = 0
OPTIONAL_JVM_INLINE_ANNOTATION
value class Delegate<T: Int>(val ignored: T) {
operator fun getValue(thisRef: Any?, prop: Any?) = Foo.a
operator fun setValue(thisRef: Any?, prop: Any?, newValue: Int) {
setterInvoked++
Foo.a = newValue<|endoftext|>
|
// FIXME: There is a `functionN` factory in `IrBuiltIns`, but it currently produces unbound symbols.
// We can switch to this and remove this function once KT-54230 is fixed.
fun IrPluginContext.function(arity: Int): IrClassSymbol =
referenceClass(ClassId(FqName("kotlin"), Name.identifier("Function$arity")))!!
|
@OptIn(ObsoleteDescriptorBasedAPI::class)
fun IrAnnotationContainer.hasAnnotationSafe(fqName: FqName): Boolean =
annotations.any {
// compiler helper getAnnotation fails during remapping in [ComposableTypeRemapper], so we
// use this impl
fqName == it.annotationClass?.descriptor?.fqNameSafe
}<|endoftext|>
|
val test3 = Outer<Int>.<!EXPLICIT_TYPE_ARGUMENTS_IN_PROPERTY_ACCESS("Object"), NESTED_CLASS_ACCESSED_VIA_INSTANCE_REFERENCE!>Inner<!><Double>
val test4 = Outer<Int>.<!NESTED_CLASS_ACCESSED_VIA_INSTANCE_REFERENCE!>Obj<!>
|
val test5 = Outer
val test6 = Outer.Nested
val test7 = Outer.Inner
val test8 = Outer.Obj<|endoftext|>
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.