prompt
stringlengths 1
924
| completion
stringlengths 14
937
|
---|---|
* ```kotlin
* try {
* RESULT_EXPRESSION
* } catch (e: ExceptionType) {
* CATCH_EXPRESSION
* }
* ```
*
* Is translated into:
*
* ```wat
* block $catch_block (BLOCK_TYPE) | * block $try_block (EXCEPTION_TYPE)
* try_table (EXCEPTION_TYPE) catch IDX $try_block
* TRANSLATED_RESULT_EXPRESSION
* br $catch_block
* end
* end
* TRANSLATED_CATCH_EXPRESSION
* end
* ```
*<|endoftext|> |
@JsName("internal_baz")
internal fun internal_baz(a: String) {
}
private fun private_baz(i: Int) {
}
@JsName("private_baz")
private fun private_baz(a: String) {
}
val call_private_baz = { private_baz(0) } | val call_private_native_baz = { private_baz("native") }
}
internal open class OpenInternalClass {
public fun public_baz(i: Int) {
}
@JsName("public_baz")
public fun public_baz(a: String) {
}
internal fun internal_baz(i: Int) {
}<|endoftext|> |
val changes = computeClasspathChanges(currentClasspathSnapshot, previousClasspathSnapshot)
Changes(
lookupSymbols = setOf(
LookupSymbol(name = "CoarseGrainedFirstBuild_CoarseGrainedSecondBuild_Class", scope = "com.example"), | LookupSymbol(name = "CoarseGrainedFirstBuild_FineGrainedSecondBuild_Class", scope = "com.example"),
LookupSymbol(name = "FineGrainedFirstBuild_CoarseGrainedSecondBuild_Class", scope = "com.example"),
LookupSymbol(name = "modifiedProperty", scope = "com.example.FineGrainedFirstBuild_FineGrainedSecondBuild_Class"),<|endoftext|> |
is ExpectActualAnnotationsIncompatibilityType.MissingOnActual -> {
sb.append("is missing on actual declaration")
}
is ExpectActualAnnotationsIncompatibilityType.DifferentOnActual -> {
sb.append("has different arguments on actual declaration: `")
.append(renderAnnotation(incompatibilityType.actualAnnotation))
.append("`")
}
} | sb.toString()
}
private fun renderAnnotation(ann: FirAnnotation): String {
return FirRenderer(
typeRenderer = ConeTypeRenderer(),
idRenderer = ConeIdShortRenderer(),
referencedSymbolRenderer = FirIdRendererBasedSymbolRenderer(),<|endoftext|> |
attributes.setAttribute(Usage.USAGE_ATTRIBUTE, objects.named(KotlinUsages.KOTLIN_CINTEROP))
attributes.setAttribute(Category.CATEGORY_ATTRIBUTE, project.categoryByName(Category.LIBRARY))
attributes.setAttribute(artifactTypeAttribute, NativeArtifactFormat.KLIB)
/* Expose api dependencies */ | target.compilations.findByName(MAIN_COMPILATION_NAME)?.let { compilation ->
extendsFrom(compilation.internal.configurations.apiConfiguration)
}
}
}
}
private fun cInteropApiElementsConfigurationName(target: KotlinTarget): String {
return target.name + "CInteropApiElements"
}<|endoftext|> |
is IrCall -> expression.symbol
is IrConstructorCall -> expression.symbol
else -> return expression
}
val actualCallee = inlineFunctionResolver.getFunctionDeclaration(calleeSymbol)
if (actualCallee?.body == null) {
return expression
}
withinScope(actualCallee) { | actualCallee.body?.transformChildrenVoid()
}
val parent = allScopes.map { it.irElement }.filterIsInstance<IrDeclarationParent>().lastOrNull()
?: allScopes.map { it.irElement }.filterIsInstance<IrDeclaration>().lastOrNull()?.parent
?: containerScope?.irElement as? IrDeclarationParent<|endoftext|> |
// test 1: PTV is in consuming position (yield-case)
fun testYield() {
fun testBasicCase() {
val arg: UserKlass.Inner<T> = UserKlass().Inner()
val buildee = build {
yield(arg)
}
checkExactType<Buildee<UserKlass.Inner<T>>>(buildee)
} | fun testThisExpression() {
val buildee = build {
yield(this@Inner)
}
checkExactType<Buildee<UserKlass.Inner<T>>>(buildee)
}
testBasicCase()
testThisExpression()
}
// test 2: PTV is in producing position (materialize-case)<|endoftext|> |
compilationName = kotlinCompilation.compilationName
)
}
fun store(kotlinCompilation: KotlinCompilation<*>, task: TaskProvider<out AbstractArchiveTask>) {
require(kotlinCompilation.project in currentBuild) { "Compilation $kotlinCompilation is not from current project" }
tasksMap[Key(kotlinCompilation)] = task | }
override fun getArchiveTaskOrNull(kotlinCompilation: KotlinCompilation<*>): TaskProvider<out AbstractArchiveTask>? {
if (kotlinCompilation.project !in currentBuild) return null
return tasksMap[Key(kotlinCompilation)]
}
}
internal val KotlinCreateCompilationArchivesTask = KotlinCompilationSideEffect { compilation -><|endoftext|> |
}
// Binary operators
private fun FirLiteralExpression<*>.evaluate(
function: FirSimpleFunction,
other: FirLiteralExpression<*>
): FirLiteralExpression<*>? {
if (value == null || other.value == null) return null | // NB: some utils accept very general types, and due to the way operation map works, we should up-cast rhs type.
val rightType = when {
function.symbol.callableId.isStringEquals -> CompileTimeType.ANY
function.symbol.callableId.isStringPlus -> CompileTimeType.ANY
else -> other.kind.toCompileTimeType()
}<|endoftext|> |
@RequiresOptIn
@OptionalExpectation
expect annotation class MyOptIn
// MODULE: m1-jvm()()(m1-common)
// FILE: jvm.kt
@RequiresOptIn
<!EXPECT_ACTUAL_OPT_IN_ANNOTATION!>actual<!> annotation class ActualOnly
@RequiresOptIn | <!EXPECT_ACTUAL_OPT_IN_ANNOTATION!>actual<!> annotation class Both
@RequiresOptIn
actual annotation class MyOptIn<|endoftext|> |
testCopyMaybeFailsWith<IllegalFileNameException>(aDir, aDirTarget, setOf(aDirTarget))
// No file is copied outside the target
testWalkSucceeds(root, root.resolve("", "Archive.zip", "UnzipArchive-aDir"))
}
}
@Test
fun deleteZipRootDirectory() { | withZip("Archive.zip", emptyList()) { _, zipRoot ->
// Deleting the root directory of a zip archive throws NullPointerException.
assertFailsWith<NullPointerException> {
zipRoot.deleteIfExists()
}
}
}
// KT-63103
@Test
fun zipDoubleDotsFileName() {<|endoftext|> |
<!DEBUG_INFO_EXPRESSION_TYPE("T & Any & T?"), DEBUG_INFO_SMARTCAST!>x<!>.equals(null)
<!DEBUG_INFO_EXPRESSION_TYPE("T & Any & T?"), DEBUG_INFO_SMARTCAST!>x<!>.propT | <!DEBUG_INFO_EXPRESSION_TYPE("T & Any & T?"), DEBUG_INFO_SMARTCAST!>x<!>.propAny
<!DEBUG_INFO_EXPRESSION_TYPE("T & Any & T?")!>x<!>.propNullableT
<!DEBUG_INFO_EXPRESSION_TYPE("T & Any & T?")!>x<!>.propNullableAny<|endoftext|> |
context.log { "Removed ${numberOfRemovedGlobalInitializerCalls * 100.0 / numberOfFunctionsWithGlobalInitializerCall}% global initializers" }
context.log { "Removed ${numberOfRemovedThreadLocalInitializerCalls * 100.0 / numberOfFunctionsWithThreadLocalInitializerCall}% thread local initializers" } | context.log { "Removed ${(numberOfCallSitesWithExtractedGlobalInitializerCall) * 100.0 / numberOfCallSitesToFunctionsWithGlobalInitializerCall}% global initializer calls" }<|endoftext|> |
internal object LLFirAnnotationArgumentsLazyResolver : LLFirLazyResolver(FirResolvePhase.ANNOTATION_ARGUMENTS) {
override fun createTargetResolver(target: LLFirResolveTarget): LLFirTargetResolver = LLFirAnnotationArgumentsTargetResolver(target) | override fun phaseSpecificCheckIsResolved(target: FirElementWithResolveState) {
if (target !is FirAnnotationContainer) return
checkAnnotationsAreResolved(target)
when (target) {
is FirCallableDeclaration -> {
checkAnnotationsAreResolved(target, target.returnTypeRef)
val receiverParameter = target.receiverParameter<|endoftext|> |
ktElement = null,
FirErrorTypeRef::class,
FirResolvedTypeRef::class
)
}
}
private fun getSymbolsForResolvedQualifier(
fir: FirResolvedQualifier,
expression: KtSimpleNameExpression,
session: FirSession,
symbolBuilder: KtSymbolByFirBuilder | ): Collection<KtSymbol> {
val referencedSymbol = if (fir.resolvedToCompanionObject) {
(fir.symbol?.fir as? FirRegularClass)?.companionObjectSymbol
} else {
fir.symbol
}
if (referencedSymbol == null) {<|endoftext|> |
parameterValuePassings.map { it.cType },
variadic = false
))
override fun IrBuilderWithScope.kotlinToBridged(expression: IrExpression): IrExpression =
irCall(symbols.interopCreateKotlinObjectHolder.owner).apply {
putValueArgument(0, expression)
} | override fun IrBuilderWithScope.bridgedToKotlin(expression: IrExpression, symbols: KonanSymbols): IrExpression =
irLetS(expression) { blockPointerVarSymbol ->
val blockPointerVar = blockPointerVarSymbol.owner
irIfThenElse(
functionType.makeNullable(),<|endoftext|> |
val value_3 = <!ILLEGAL_UNDERSCORE!>0B000000000_<!>
// TESTCASE NUMBER: 4
val value_4 = <!ILLEGAL_UNDERSCORE, INT_LITERAL_OUT_OF_RANGE!>0b_<!>
// TESTCASE NUMBER: 5 | val value_5 = <!ILLEGAL_UNDERSCORE, INT_LITERAL_OUT_OF_RANGE!>0B______________<!>
// TESTCASE NUMBER: 6
val value_6 = <!ILLEGAL_UNDERSCORE!>0B0_<!>
// TESTCASE NUMBER: 7<|endoftext|> |
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Number? & kotlin.Comparable<kotlin.Nothing>? & kotlin.Number & kotlin.Comparable<kotlin.Nothing>")!>it<!>.funNullableAny()
}
}
}
/*
* TESTCASE NUMBER: 4
* ISSUES: KT-28670
*/ | fun case_4(a: Interface1?, b: Interface2?, c: Boolean) {
a as Interface2?
b as Interface1?
val x = when (c) {
true -> a
false -> b
}
x.apply {
<!DEBUG_INFO_EXPRESSION_TYPE("Interface2? & Interface1?")!>this<!><|endoftext|> |
ProtoBuf.MemberKind.FAKE_OVERRIDE -> CallableMemberDescriptor.Kind.FAKE_OVERRIDE
ProtoBuf.MemberKind.DELEGATION -> CallableMemberDescriptor.Kind.DELEGATION
ProtoBuf.MemberKind.SYNTHESIZED -> CallableMemberDescriptor.Kind.SYNTHESIZED | else -> CallableMemberDescriptor.Kind.DECLARATION
}
@Suppress("unused")
fun ProtoEnumFlags.memberKind(kind: CallableMemberDescriptor.Kind): ProtoBuf.MemberKind = when (kind) {
CallableMemberDescriptor.Kind.DECLARATION -> ProtoBuf.MemberKind.DECLARATION<|endoftext|> |
* 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: Byte): 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<|endoftext|> |
package org.jetbrains.kotlin.analysis.api.fir.symbols.pointers
import org.jetbrains.kotlin.analysis.api.KtAnalysisSession
import org.jetbrains.kotlin.analysis.api.fir.KtFirAnalysisSession
import org.jetbrains.kotlin.analysis.api.fir.utils.firSymbol | import org.jetbrains.kotlin.analysis.api.symbols.KtKotlinPropertySymbol
import org.jetbrains.kotlin.analysis.api.symbols.KtScriptSymbol
import org.jetbrains.kotlin.analysis.api.symbols.KtSymbol<|endoftext|> |
import org.jetbrains.kotlin.scripting.ide_common.idea.util.CallTypeAndReceiver
import org.jetbrains.kotlin.scripting.ide_common.idea.util.IdeDescriptorRenderersScripting
import org.jetbrains.kotlin.scripting.ide_common.idea.util.getResolutionScope | import org.jetbrains.kotlin.scripting.ide_services.compiler.completion
import org.jetbrains.kotlin.scripting.ide_services.compiler.filterOutShadowedDescriptors
import org.jetbrains.kotlin.scripting.ide_services.compiler.impl.KJvmReplCompleter.ResultGetter<|endoftext|> |
accept<String>(<!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>NullMarkedType.TargetType.TYPE_ARGUMENT().produce()<!>)
// jspecify_nullness_mismatch | accept<Any>(<!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>NullMarkedType.TargetType.UNBOUNDED_WILDCARD().produce()<!>)
// jspecify_nullness_mismatch<|endoftext|> |
package org.jetbrains.kotlin.commonizer.mergedtree
import org.jetbrains.kotlin.commonizer.core.*
import org.jetbrains.kotlin.commonizer.CommonizerSettings
import org.jetbrains.kotlin.commonizer.cir.*
import org.jetbrains.kotlin.commonizer.utils.CommonizedGroup | import org.jetbrains.kotlin.storage.NullableLazyValue
import org.jetbrains.kotlin.storage.StorageManager
internal fun buildRootNode(
storageManager: StorageManager,
commonDependencies: CirProvidedClassifiers,
size: Int
): CirRootNode = buildNode(
storageManager = storageManager,
size = size,
nodeRelationship = null,<|endoftext|> |
map.put(OVERLOAD_RESOLUTION_AMBIGUITY, "Overload resolution ambiguity between candidates:{0}", SYMBOLS_ON_NEXT_LINES)
map.put(ASSIGN_OPERATOR_AMBIGUITY, "Ambiguity between assign operator candidates:{0}", SYMBOLS_ON_NEXT_LINES) | map.put(HAS_NEXT_MISSING, "'hasNext()' cannot be called on 'iterator()'.")
map.put(HAS_NEXT_FUNCTION_AMBIGUITY, "Method ''hasNext()'' is ambiguous for this expression. Applicable candidates:{0}", SYMBOLS_ON_NEXT_LINES)<|endoftext|> |
import org.jetbrains.kotlin.test.directives.ConfigurationDirectives.WITH_STDLIB
import org.jetbrains.kotlin.test.directives.JvmEnvironmentConfigurationDirectives.FULL_JDK
import org.jetbrains.kotlin.test.directives.model.DirectivesContainer
import org.jetbrains.kotlin.test.directives.model.RegisteredDirectives | import org.jetbrains.kotlin.test.model.TestFile
import org.jetbrains.kotlin.test.model.TestModule
import org.jetbrains.kotlin.test.runners.codegen.AbstractFirLightTreeBlackBoxCodegenTest
import org.jetbrains.kotlin.test.runners.codegen.AbstractIrBlackBoxCodegenTest<|endoftext|> |
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER
// FILE: foo/A.java
package foo;
public class A {
private static void foo(int s) {}
static void bar(double s) {}
}
// FILE: K.kt
import foo.A
open class K : A() {
fun foo(i: Int) {} | fun bar(d: Double) {}
fun baz(i: Int) {}
companion object {
fun foo(i: Int) {}
fun bar(d: Double) {}
}
}<|endoftext|> |
+irReturn(irCall(irFunction).also {
for (i in irFunction.typeParameters.indices) {
it.putTypeArgument(i, typeParameters[i].defaultType)
}
val capturedThisValue = capturedThisField?.let { irField ->
irGetField(irGet(function.dispatchReceiverParameter!!), irField)
} | if (irFunction.dispatchReceiverParameter != null) {
it.dispatchReceiver = capturedThisValue
}
irFunction.extensionReceiverParameter?.let { extensionReceiverParameter ->
it.extensionReceiver = extensionReceiverParameter.type.defaultValue(
UNDEFINED_OFFSET, UNDEFINED_OFFSET, backendContext
)
}<|endoftext|> |
import org.jetbrains.kotlin.ir.symbols.IrPropertySymbol
import org.jetbrains.kotlin.ir.visitors.IrElementTransformer
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
/**
* Generated from: [org.jetbrains.kotlin.ir.generator.IrTree.property]
*/ | abstract class IrProperty : IrDeclarationBase(), IrPossiblyExternalDeclaration, IrOverridableDeclaration<IrPropertySymbol>, IrMetadataSourceOwner, IrAttributeContainer, IrMemberWithContainerSource {
@ObsoleteDescriptorBasedAPI
abstract override val descriptor: PropertyDescriptor
abstract override val symbol: IrPropertySymbol<|endoftext|> |
expect(1) { data.indexOfLast { it.length == 3 } }
expect(-1) { empty.indexOfLast { it.startsWith('f') } }
}
@Test
fun mutableList() {
val items = listOf("beverage", "location", "name")
var list = listOf<String>()
for (item in items) { | list += item
}
assertEquals(3, list.size)
assertEquals("beverage,location,name", list.joinToString(","))
}
@Test
fun testNullToString() {
assertEquals("[null]", listOf<String?>(null).toString())
}
}<|endoftext|> |
assertEquals(one, c.nonNullBoundRef().call())
assertEquals(one, c.nonNullBoundRef().getter.call())
assertEquals(Unit, c.nullableUnboundRef().setter.call(c, zero))
assertEquals(zero, c.nullableUnboundRef().call(c)) | assertEquals(zero, c.nullableUnboundRef().getter.call(c))
assertEquals(Unit, c.nullableBoundRef().setter.call(one))
assertEquals(one, c.nullableBoundRef().call())
assertEquals(one, c.nullableBoundRef().getter.call())<|endoftext|> |
get() = lowerCamelCaseName(disambiguateName(INTRANSITIVE), METADATA_CONFIGURATION_NAME_SUFFIX)
override val kotlin: SourceDirectorySet = createDefaultSourceDirectorySet(project, "$name Kotlin source")
override val languageSettings: LanguageSettingsBuilder = DefaultLanguageSettingsBuilder(project) | internal var actualResources: SourceDirectorySet = createDefaultSourceDirectorySet(project, "$name resources")
override val resources: SourceDirectorySet get() = actualResources
override fun kotlin(configure: SourceDirectorySet.() -> Unit): SourceDirectorySet = kotlin.apply {
configure(this)
}<|endoftext|> |
public operator fun kotlin.ranges.ClosedRange<kotlin.Float>.contains(value: kotlin.Short): kotlin.Boolean
@kotlin.jvm.JvmName(name = "intRangeContains")
public operator fun kotlin.ranges.ClosedRange<kotlin.Int>.contains(value: kotlin.Byte): kotlin.Boolean | @kotlin.Deprecated(message = "This `contains` operation mixing integer and floating point arguments has ambiguous semantics and is going to be removed.")
@kotlin.DeprecatedSinceKotlin(errorSince = "1.4", hiddenSince = "1.5", warningSince = "1.3")
@kotlin.jvm.JvmName(name = "intRangeContains")<|endoftext|> |
// TARGET_BACKEND: JVM
// FILE: Box.java
public class Box<T> {
private final T value;
public Box(T value) {
this.value = value;
}
public static <T> Box<T> create(T defaultValue) {
return new Box(defaultValue);
}
public T getValue() {
return value; | }
}
// FILE: test.kt
// See KT-10313: ClassCastException with Generics
fun box(): String {
val sub = Box<Long>(-1)
return if (sub.value == -1L) "OK" else "fail"
}<|endoftext|> |
fun consumeInt(arg: Int) {}
fun main() {
outerLambda {
lambda = {
consume(this@outerLambda)
}
}
outerLambda {
lambda = innerLambda@{
consumeInt(this@innerLambda)
}
}
lateinit var c: Int.() -> Unit | val a = "hello".apply {
val b: Int.() -> Unit = {
this@apply.hello()
}
c = {
this@apply.hello()
}
}
}
fun String.hello() = this<|endoftext|> |
const val V16 = 16
const val V17 = 17
const val V18 = 18
const val V19 = 19
const val V20 = 20
}
var VV1 = 1
var VV2 = 2
var VV3 = 3
var VV4 = 4
var VV5 = 5
var VV6 = 6
var VV7 = 7
var VV8 = 8 | var VV9 = 9
var VV10 = 10
var VV11 = 11
var VV12 = 12
var VV13 = 13
var VV14 = 14
var VV15 = 15
var VV16 = 16
var VV17 = 17
var VV18 = 18
var VV19 = 19
var VV20 = 20
open class SwitchBenchmark {<|endoftext|> |
val componentResolvedCall = getOrFail(BindingContext.COMPONENT_RESOLVED_CALL, ktEntry)
val componentSubstitutedCall = pregenerateCall(componentResolvedCall)
componentSubstitutedCall.setExplicitReceiverValue(containerValue)
containerValue = restContainerValue
val (componentCallStartOffset, componentCallEndOffset) = | if (context.extensions.debugInfoOnlyOnVariablesInDestructuringDeclarations) {
SYNTHETIC_OFFSET to SYNTHETIC_OFFSET
} else {
ktEntry.startOffsetSkippingComments to ktEntry.endOffset
}
val irComponentCall = callGenerator.generateCall(
componentCallStartOffset, componentCallEndOffset,<|endoftext|> |
// TODO: Cover all cases with frontend and disable error declarations
class ErrorDeclaration(val message: String) : ExportedDeclaration()
sealed class ExportedClass : ExportedDeclaration() {
abstract val name: String
abstract val ir: IrClass
abstract val members: List<ExportedDeclaration>
abstract val superClasses: List<ExportedType> | abstract val superInterfaces: List<ExportedType>
abstract val nestedClasses: List<ExportedClass>
}
data class ExportedRegularClass(
override val name: String,
val isInterface: Boolean = false,
val isAbstract: Boolean = false,
override val superClasses: List<ExportedType> = emptyList(),<|endoftext|> |
private fun IrClass.requiredToHaveBoxParameter(): Boolean {
return needsOfBoxParameter == true
}
}
class ES6CollectConstructorsWhichNeedBoxParameters(private val context: JsIrBackendContext) : DeclarationTransformer {
private var IrClass.needsOfBoxParameter by context.mapping.esClassWhichNeedBoxParameters | override fun transformFlat(declaration: IrDeclaration): List<IrDeclaration>? {
if (!context.es6mode || declaration !is IrClass) return null
val hasSuperClass = declaration.superClass != null
if (hasSuperClass && declaration.isInner) {
declaration.addToClassListWhichNeedBoxParameter()
}<|endoftext|> |
interface Ann {
fun foo()
}
interface KC<T> {
val x: T
}
fun <T> id(x: KC<T>): KC<T> = x
fun <T> KC<T>.idR(): KC<T> = this
val <T> KC<T>.idP: KC<T> get() = this | private fun getSetterInfos(kc: KC<out Ann>) {
id(kc).x.foo()
kc.idR().x.foo()
kc.idP.x.foo()
val x1 = id(kc)
val x2 = kc.idR()
val x3 = kc.idP
}<|endoftext|> |
public abstract val variance: Variance
public abstract val isReified: Boolean
}
public sealed class KtClassLikeSymbol : KtClassifierSymbol(), KtSymbolWithKind, KtPossibleMemberSymbol, KtPossibleMultiplatformSymbol {
public abstract val classIdIfNonLocal: ClassId? | abstract override fun createPointer(): KtSymbolPointer<KtClassLikeSymbol>
}
public abstract class KtTypeAliasSymbol : KtClassLikeSymbol(),
KtSymbolWithVisibility,
KtNamedSymbol {
/**
* Returns type from right-hand site of type alias<|endoftext|> |
// NO_CHECK_LAMBDA_INLINING
// IGNORE_INLINER_K2: IR
// FILE: 1.kt
package test
inline fun <R> doWork(crossinline job: ()-> R) : R {
return notInline({job()})
}
fun <R> notInline(job: ()-> R) : R {
return job()
} | // FILE: 2.kt
import test.*
val s = doWork({11})
fun box(): String {
if (s != 11) return "test1: ${s}"
return "OK"
}<|endoftext|> |
// SKIP_KT_DUMP
// TARGET_BACKEND: JVM
// WITH_STDLIB
// FILE: Java1.java
public class Java1 {
public <T> void foo(T a) { }
public <T> T bar() {
return null;
}
}
// FILE: Java2.java
public interface Java2 extends KotlinInterface { } | // FILE: Java3.java
public class Java3 extends Java1 {
@Override
public <T> void foo(T a) { }
@Override
public <T> T bar() {
return null;
}
}
// FILE: Java4.java
public class Java4 extends KotlinClass { }
// FILE: 1.kt<|endoftext|> |
var x: Class? = <!CONSTANT_EXPECTED_TYPE_MISMATCH!>10<!>
x!! | <!DEBUG_INFO_EXPRESSION_TYPE("Class & Class?"), DEBUG_INFO_SMARTCAST!>x<!>(if (true) {x=null;0} else 0, <!DEBUG_INFO_EXPRESSION_TYPE("Class & Class?"), DEBUG_INFO_SMARTCAST!>x<!>)<|endoftext|> |
val xx = A[logged("1;"), logged("2;"), logged("3;")]++
if (xx != "start;") return "Failed xx: $xx"
if (A.x != "start;inc;") return "Failed A.x: ${A.x}"
if (A.gets != "1;2;3;") return "Failed A.gets: ${A.gets}" | if (A.sets != "1;2;3;") return "Failed A.sets: ${A.sets}"
if (log != "1;2;3;get;inc;set;") return "Failed log: $log"
return "OK"
}<|endoftext|> |
val ALLOW_DANGEROUS_LANGUAGE_VERSION_TESTING by directive(
description = """
Allows the use of the LANGUAGE_VERSION directive. However, before you use it, please
make sure that you actually do need to pin language versions.
The LANGUAGE_VERSION directive is prone to limiting test to a specific language version, | which will become obsolete at some point and the test won't check things like feature
intersection with newer releases.
For language feature testing, use `// !LANGUAGE: [+-]FeatureName` directive instead,
where FeatureName is an entry of the enum `LanguageFeature`
""".trimIndent()
)
// --------------------- Analysis Flags ---------------------<|endoftext|> |
package org.jetbrains.kotlin.resolve
import org.jetbrains.kotlin.builtins.PlatformSpecificCastChecker
import org.jetbrains.kotlin.builtins.PlatformToKotlinClassMapper
import org.jetbrains.kotlin.container.*
import org.jetbrains.kotlin.resolve.calls.checkers.* | import org.jetbrains.kotlin.resolve.calls.results.TypeSpecificityComparator
import org.jetbrains.kotlin.resolve.checkers.*
import org.jetbrains.kotlin.resolve.lazy.AbsentDescriptorHandler
import org.jetbrains.kotlin.resolve.lazy.DelegationFilter<|endoftext|> |
package org.jetbrains.kotlin.fir.analysis.checkers.syntax
import com.intellij.lang.LighterASTNode
import com.intellij.psi.PsiElement
import com.intellij.psi.tree.TokenSet
import com.intellij.util.diff.FlyweightCapableTreeStructure | import org.jetbrains.kotlin.ElementTypeUtils.getOperationSymbol
import org.jetbrains.kotlin.ElementTypeUtils.isExpression
import org.jetbrains.kotlin.KtLightSourceElement
import org.jetbrains.kotlin.KtNodeTypes.*
import org.jetbrains.kotlin.KtPsiSourceElement<|endoftext|> |
// Issues: KT-33542, KT-33544
// WITH_STDLIB
import kotlin.experimental.ExperimentalTypeInference
interface In<in E> {
suspend fun send(element: E)
}
class InImpl<E>(val block: suspend In<E>.() -> Unit) : In<E> {
override suspend fun send(element: E) {}
} | @OptIn(ExperimentalTypeInference::class)
public fun <T> builder(block: suspend In<T>.() -> Unit) {
InImpl(block)
}
fun test33542() {
builder {
send(run {
15
})
}
}
fun test33544(){
builder {
send(run {
let { 0 } ?: 1
0<|endoftext|> |
import org.jetbrains.kotlin.fir.declarations.FirRegularClass
import org.jetbrains.kotlin.fir.declarations.FirResolvePhase
import org.jetbrains.kotlin.fir.declarations.utils.classId
import org.jetbrains.kotlin.fir.resolve.ScopeSession | import org.jetbrains.kotlin.fir.resolve.providers.symbolProvider
import org.jetbrains.kotlin.fir.scopes.FirContainingNamesAwareScope
import org.jetbrains.kotlin.fir.scopes.jvm.JvmMappedScope
import org.jetbrains.kotlin.fir.scopes.unsubstitutedScope<|endoftext|> |
package org.jetbrains.kotlin.ir.expressions.impl
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
import org.jetbrains.kotlin.ir.declarations.IrAttributeContainer
import org.jetbrains.kotlin.ir.expressions.IrCall
import org.jetbrains.kotlin.ir.expressions.IrExpression | import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin
import org.jetbrains.kotlin.ir.expressions.typeParametersCount
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
import org.jetbrains.kotlin.ir.symbols.IrConstructorSymbol<|endoftext|> |
filterHeadersByPredefined(filter, index, translationUnit, ownTranslationUnits, ownHeaders, allHeaders, unitsHolder)
}
ownHeaders.removeAll { library.headerExclusionPolicy.excludeAll(getHeaderId(library, it)) }
return NativeLibraryHeadersAndUnits(NativeLibraryHeaders(ownHeaders, allHeaders - ownHeaders), ownTranslationUnits) | }
class UnitsHolder(val index: CXIndex) : Disposable {
private val unitByBinaryFile = mutableMapOf<String, CXTranslationUnit>()
internal fun load(info: CXIdxImportedASTFileInfo): CXTranslationUnit {
val canonicalPath: String = info.file!!.canonicalPath<|endoftext|> |
private const val DEFAULT_BUILD_METHOD_NAME = "build"
private const val DEFAULT_BUILDER_METHOD_NAME = "builder"
private const val DEFAULT_REQUIRES_TO_BUILDER = false
override fun extract(annotation: AnnotationDescriptor?, config: LombokConfig): Builder {
return Builder( | builderClassName = annotation?.getStringArgument("builderClassName")
?: config.getString("lombok.builder.className")
?: DEFAULT_BUILDER_CLASS_NAME,
buildMethodName = annotation?.getStringArgument("buildMethodName") ?: DEFAULT_BUILD_METHOD_NAME,<|endoftext|> |
org.gradle.jvmargs = -Xmx758m -Xms128m
kotlin.daemon.jvmargs = -Xmx486m -Xms256m
""".trimIndent()
)
//language=Groovy
buildGradle.append(
""" | import org.jetbrains.kotlin.gradle.tasks.CompileUsingKotlinDaemon
tasks
.matching {
it.name == "compileTestKotlin" && it instanceof CompileUsingKotlinDaemon
}
.configureEach {<|endoftext|> |
endOffset: Int,
tree: FlyweightCapableTreeStructure<LighterASTNode>
): List<TextRange> {
val newNodes = tree.valueParameters(node).filter { tree.defaultValue(it) != null }.takeIf(List<*>::isNotEmpty)
?: tree.valueParameterList(node)?.let(::listOf) | ?: tree.nameIdentifier(node)?.let(::listOf)
?: listOf(node)
return newNodes.flatMap { markElement(it, startOffset, endOffset, tree, node) }
}
}
val PARAMETER_VARARG_MODIFIER: LightTreePositioningStrategy = object : LightTreePositioningStrategy() {
override fun mark(<|endoftext|> |
reporter: DiagnosticReporter,
supportsJvmStaticInInterface: Boolean,
targetSource: KtSourceElement?,
) {
val properDiagnostic = if (supportsJvmStaticInInterface) {
FirJvmErrors.JVM_STATIC_NOT_IN_OBJECT_OR_COMPANION
} else { | FirJvmErrors.JVM_STATIC_NOT_IN_OBJECT_OR_CLASS_COMPANION
}
reporter.reportOn(targetSource, properDiagnostic, context)
}
private fun checkForInterface(
declaration: FirDeclaration,
context: CheckerContext,
reporter: DiagnosticReporter,<|endoftext|> |
public void noBoundsNullable(A<? extends @Nullable Object, ? extends @Nullable Object, ? extends @Nullable Object> a) {}
}
// FILE: A.java
import org.jspecify.annotations.*;
public class A <T extends Object, E extends @Nullable Object, F extends @NullnessUnspecified Object> {}
// FILE: main.kt
fun main( | aNotNullNotNullNotNull: A<Any, Any, Any>,
aNotNullNotNullNull: A<Any, Any, Any?>,
aNotNullNullNotNull: A<Any, Any?, Any>,
aNotNullNullNull: A<Any, Any?, Any?>,
b: WildcardsWithDefault
): Unit {
b.noBoundsNotNull(aNotNullNotNullNotNull)<|endoftext|> |
// NO_CHECK_LAMBDA_INLINING
// FILE: 1.kt
package test
inline fun linearLayout2(init: X.() -> Unit) {
return X().init()
}
var result = "fail"
class X {
fun calc() {
result = "OK"
}
}
// FILE: 2.kt
import test.*
class A { | fun test() {
linearLayout2 {
{
apply2 {
this@linearLayout2::calc
}()
}.let { it() }
}
}
public fun <T, Z> T.apply2(block: T.() -> Z): Z {
return block()
}
}
fun box(): String {
A().test()<|endoftext|> |
fun plusK(s: String) = s + "K"
fun box(): String {
val sam1 = roundtrip(Sam1(::plusK))
if (sam1 !is Sam1) return "Failed: $sam1 !is Sam1"
val t1 = sam1.get("O")
if (t1 != "OK") return "Failed: $t1='$t1'" | val sam2 = roundtrip(Sam2(::plusK))
if (sam2 !is Sam2) return "Failed: $sam2 !is Sam2"
val t2 = sam2.get("O")
if (t2 != "OK") return "Failed: $t2='$t2'"
return "OK"
}
fun <T> roundtrip(x: T): T {<|endoftext|> |
import org.jetbrains.kotlin.fir.caches.FirCache
import org.jetbrains.kotlin.fir.caches.createCache
import org.jetbrains.kotlin.fir.caches.firCachesFactory
import org.jetbrains.kotlin.fir.caches.getValue | import org.jetbrains.kotlin.fir.declarations.FirCallableDeclaration
import org.jetbrains.kotlin.fir.declarations.FirClassLikeDeclaration
import org.jetbrains.kotlin.fir.declarations.FirDeclaration
import org.jetbrains.kotlin.fir.declarations.FirFile<|endoftext|> |
""".trimMargin()
)
build("assemble")
}
}
@DisplayName("Cross modules work correctly with compose dependency ('KT60852')")
@GradleTest
fun crossModulesWorkCorrectlyWithComposeDependencyKT60852(gradleVersion: GradleVersion) { | project("kotlin-js-compose-dependency", gradleVersion) {
build("compileDevelopmentExecutableKotlinJs") {
assertTasksExecuted(":compileDevelopmentExecutableKotlinJs")
}
}
}
@DisplayName("test package.json skipped with main package.json was up-to-date")
@GradleTest<|endoftext|> |
/**
* Calculates the set of package names which contain callables and can be provided by this declaration provider.
*
* The set may contain false positives. `null` may be returned if the package set is too expensive or impossible to compute.
*/
public open fun computePackageNamesWithTopLevelCallables(): Set<String>? = computePackageNames()
}
public abstract class KotlinDeclarationProviderFactory { | public abstract fun createDeclarationProvider(scope: GlobalSearchScope, contextualModule: KtModule?): KotlinDeclarationProvider
public companion object {
public fun getInstance(project: Project): KotlinDeclarationProviderFactory =
project.getService(KotlinDeclarationProviderFactory::class.java)
}
}
/**<|endoftext|> |
checkSubtype<Any>({})
val z: Any = { x: Any -> println(x) }
funWithAnyArg {}
}
// TESTCASE NUMBER: 7
fun case_7() {
checkSubtype<Any>(object {})
val z: Any = { x: Any -> object { val y = x } }(10) | funWithAnyArg(object : Comparable<Any> {
override fun compareTo(other: Any) = TODO()
})
}
// TESTCASE NUMBER: 8
fun case_8() {
checkSubtype<Any>(object {}::class)
val z: Any = {}::class
funWithAnyArg(0E0::class)
}<|endoftext|> |
public external abstract class HTMLImageElement : HTMLElement, HTMLOrSVGImageElement, TexImageSource, JsAny {
open var alt: String
open var src: String
open var srcset: String
open var sizes: String
open var crossOrigin: String?
open var useMap: String
open var isMap: Boolean
open var width: Int
open var height: Int | open val naturalWidth: Int
open val naturalHeight: Int
open val complete: Boolean
open val currentSrc: String
open var referrerPolicy: String
open var name: String
open var lowsrc: String
open var align: String
open var hspace: Int
open var vspace: Int
open var longDesc: String
open var border: String<|endoftext|> |
val lastLineNumber = codegen.lastLineNumber
val callSite = SourcePosition(lastLineNumber, sourceInfo.sourceFileName!!, sourceInfo.pathOrCleanFQN)
info.inlineScopesGenerator?.apply { currentCallSiteLineNumber = lastLineNumber }
val inliner = MethodInliner( | node, parameters, info, FieldRemapper(null, null, parameters), sourceCompiler.isCallInsideSameModuleAsCallee,
{ "Method inlining " + sourceCompiler.callElementText },
SourceMapCopier(sourceMapper, nodeAndSmap.classSMAP, callSite),
info.callSiteInfo,
isInlineOnlyMethod = isInlineOnly,<|endoftext|> |
KonanPrimitiveType.VECTOR128 -> emptyList()
}
},
ifReference = {
return emptyList()
},
)
}
}
}
sealed class ExtendOnCalleeSideTargetAbiInfo(private val shouldZeroExtBoolean: Boolean) : TargetAbiInfo { | private val typeAttributesCache = mutableMapOf<IrType, List<LlvmParameterAttribute>>()
override fun defaultParameterAttributesForIrType(irType: IrType): List<LlvmParameterAttribute> {
return typeAttributesCache.getOrPut(irType) {<|endoftext|> |
val list = a.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>filterNotNull<!>() | <!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>list<!> <!DEBUG_INFO_MISSING_UNRESOLVED!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><List<Int>>() }
}<|endoftext|> |
public inline fun <T, K, M : kotlin.collections.MutableMap<in K, in T>> kotlin.collections.Iterable<T>.associateByTo(destination: M, keySelector: (T) -> K): M | public inline fun <T, K, V, M : kotlin.collections.MutableMap<in K, in V>> kotlin.collections.Iterable<T>.associateByTo(destination: M, keySelector: (T) -> K, valueTransform: (T) -> V): M<|endoftext|> |
subProject("withconfig").buildGradle
).forEach { buildGradle ->
buildGradle.modify {
val freefairLombokVersion = if (gradleVersion < GradleVersion.version(TestVersions.Gradle.G_8_0)) {
"5.3.0"
} else {
"8.4"
} | it.replace("<freefair_lombok_version>", freefairLombokVersion)
}
}
build("build")
}
}
@OtherGradlePluginTests
@DisplayName("KT-51378: Using 'kotlin-dsl' with latest plugin version in buildSrc module")
@GradleTestVersions(<|endoftext|> |
/** Creates a range from this value to the specified [other] value. */
@kotlin.internal.InlineOnly
public inline operator fun rangeTo(other: ULong): ULongRange = ULongRange(this, other)
/**
* Creates a range from this value up to but excluding the specified [other] value.
* | * If the [other] value is less than or equal to `this` value, then the returned range is empty.
*/
@SinceKotlin("1.9")
@WasExperimental(ExperimentalStdlibApi::class)
@kotlin.internal.InlineOnly
public inline operator fun rangeUntil(other: ULong): ULongRange = this until other
/**<|endoftext|> |
// WITH_STDLIB
class Out<out T>
class Final
open class Open
@JvmField
val NO_WILDCARDS: Out<Open> = Out()
// field: FieldsKt::NO_WILDCARDS
// generic signature: LOut<LOpen;>;
@JvmField
var HAS_WILDCARDS: Out<Open> = Out() | // field: FieldsKt::HAS_WILDCARDS
// generic signature: LOut<+LOpen;>;
@JvmField
var NO_WILDCARDS_VAR: Out<Final> = Out()
// field: FieldsKt::NO_WILDCARDS_VAR
// generic signature: LOut<LFinal;>;
@JvmSuppressWildcards
@JvmField<|endoftext|> |
public inline fun <K, V> kotlin.ByteArray.associate(transform: (kotlin.Byte) -> kotlin.Pair<K, V>): kotlin.collections.Map<K, V> | public inline fun <K, V> kotlin.CharArray.associate(transform: (kotlin.Char) -> kotlin.Pair<K, V>): kotlin.collections.Map<K, V><|endoftext|> |
public inline fun IntArray.filter(predicate: (Int) -> Boolean): List<Int> {
return filterTo(ArrayList<Int>(), predicate)
}
/**
* Returns a list containing only elements matching the given [predicate].
*
* @sample samples.collections.Collections.Filtering.filter
*/ | public inline fun LongArray.filter(predicate: (Long) -> Boolean): List<Long> {
return filterTo(ArrayList<Long>(), predicate)
}
/**
* Returns a list containing only elements matching the given [predicate].
*
* @sample samples.collections.Collections.Filtering.filter
*/<|endoftext|> |
import org.jetbrains.kotlin.fir.expressions.UnresolvedExpressionTypeAccess
import org.jetbrains.kotlin.fir.types.ConeKotlinType
import org.jetbrains.kotlin.fir.types.constructClassType
import org.jetbrains.kotlin.fir.types.toLookupTag | import org.jetbrains.kotlin.fir.visitors.FirTransformer
import org.jetbrains.kotlin.fir.visitors.FirVisitor
import org.jetbrains.kotlin.fir.visitors.transformInplace
import org.jetbrains.kotlin.name.ClassId
import org.jetbrains.kotlin.name.Name<|endoftext|> |
class ClassAnnotationsChecker(annotationsProperty: KProperty1<ClassNode, List<Any?>?>) :
AnnotationsChecker<ClassNode>("class.${annotationsProperty.name}", annotationsProperty),
ClassChecker {
override fun check(class1: ClassNode, class2: ClassNode, report: ClassReport) {
val anns1 = getAnnotations(class1) | val anns2 = getAnnotations(class2)
report.addAnnotationDiffs(this, compareAnnotations(anns1, anns2) ?: return)
}
}<|endoftext|> |
testDecode(Base64.Mime, "Zm9vYg==\uD800\uDC00", "foob".encodeToByteArray())
// inserts line separator, but not to the end of the output
val expected = "Zm9vYmFy".repeat(76).chunked(76).joinToString(separator = "\r\n") | testEncode(Base64.Mime, "foobar".repeat(76).encodeToByteArray(), expected)
}
}<|endoftext|> |
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER
@DslMarker
annotation class Ann
@Ann
class A {
fun a() = 1
}
@Ann
class B {
fun b() = 2
}
fun bar(x: B.() -> Unit) {}
fun A.test() {
bar { | <!DSL_SCOPE_VIOLATION!>a<!>()
this@test.a()
b()
}
}<|endoftext|> |
import org.jetbrains.kotlin.fir.analysis.checkers.MppCheckerKind
import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext
import org.jetbrains.kotlin.fir.analysis.checkers.declaration.FirBasicDeclarationChecker | import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors
import org.jetbrains.kotlin.fir.analysis.js.checkers.FirJsStableName
import org.jetbrains.kotlin.fir.analysis.js.checkers.getJsName<|endoftext|> |
fun CallableMemberDescriptor.isDefinitelyNotDefaultImplsMethod() =
this is JavaCallableMemberDescriptor || this.annotations.hasAnnotation(PLATFORM_DEPENDENT_ANNOTATION_FQ_NAME)
fun ClassBuilder.generateMethod(
debugString: String,
access: Int,
method: Method,
element: PsiElement?, | origin: JvmDeclarationOrigin,
state: GenerationState,
generate: InstructionAdapter.() -> Unit
) {
val mv = this.newMethod(origin, access, method.name, method.descriptor, null, null)
if (state.classBuilderMode.generateBodies) {
val iv = InstructionAdapter(mv)
iv.visitCode()<|endoftext|> |
override val pathPartRegex = SpecTestLinkedType.NOT_LINKED.testDataPath + ps + sectionsInPathRegex
override val testPathPattern: Pattern =
Pattern.compile(testPathRegexTemplate.format(pathPartRegex, FILENAME_REGEX))
override val testInfoPattern: Pattern = | Pattern.compile(MULTILINE_COMMENT_REGEX.format(""" $ASTERISK_REGEX KOTLIN $testAreaRegex NOT LINKED SPEC TEST \($testTypeRegex\)\n(?<infoElements>[\s\S]*?\n)"""))
}
object LinkedSpecTestPatterns : BasePatterns {<|endoftext|> |
private inline fun <R> CallableSymbolMarker.processIr(
onFunction: (IrFunction) -> R,
onProperty: (IrProperty) -> R,
onField: (IrField) -> R,
onValueParameter: (IrValueParameter) -> R,
onEnumEntry: (IrEnumEntry) -> R,
): R {
return when (this) { | is IrFunctionSymbol -> onFunction(owner)
is IrPropertySymbol -> onProperty(owner)
is IrFieldSymbol -> onField(owner)
is IrValueParameterSymbol -> onValueParameter(owner)
is IrEnumEntrySymbol -> onEnumEntry(owner)
else -> error("Unsupported declaration: $this")
}
}<|endoftext|> |
}
fun writeUInt64(v: ULong) {
writeByte(v.toByte())
writeByte((v shr 8).toByte())
writeByte((v shr 16).toByte())
writeByte((v shr 24).toByte())
writeByte((v shr 32).toByte())
writeByte((v shr 40).toByte())
writeByte((v shr 48).toByte()) | writeByte((v shr 56).toByte())
}
fun writeVarInt7(v: Byte) {
writeSignedLeb128(v.toLong())
}
fun writeVarInt32(v: Int) {
writeSignedLeb128(v.toLong())
}
fun writeVarInt64(v: Long) {<|endoftext|> |
if (aLong[0] != bLong) return "Failed post-decrement Long: ${aLong[0]} != $bLong"
aFloat[0]++
bFloat++
if (aFloat[0] != bFloat) return "Failed post-increment Float: ${aFloat[0]} != $bFloat"
aFloat[0]--
bFloat-- | if (aFloat[0] != bFloat) return "Failed post-decrement Float: ${aFloat[0]} != $bFloat"
aDouble[0]++
bDouble++
if (aDouble[0] != bDouble) return "Failed post-increment Double: ${aDouble[0]} != $bDouble"
aDouble[0]--
bDouble--<|endoftext|> |
binaryOperation(STRING, STRING, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun)
)
//from library
class BigInteger(val value: String) {
fun add(o: BigInteger): BigInteger = o
fun divide(o: BigInteger): BigInteger = o
fun rem(o: BigInteger): BigInteger = o | fun multiply(o: BigInteger): BigInteger = o
fun subtract(o: BigInteger): BigInteger = o
fun or(o: BigInteger): BigInteger = o
fun and(o: BigInteger): BigInteger = o
fun xor(o: BigInteger): BigInteger = o
}<|endoftext|> |
}
assertEquals("Foo", foo.value)
}
@Test
fun testArranger() {
class Foo(var value: String)
val keeper: StateKeeper<Foo, Unit> = stateKeeper { _, _ ->
add(Foo::value::get, Foo::value::set) { "Baz" }
} | val foo = Foo("Foo")
keeper.withRestoration(foo) {
assertEquals("Baz", foo.value)
foo.value = "Bar"
assertEquals("Bar", foo.value)
}
assertEquals("Foo", foo.value)
}
@Test
fun testInclusion() {
open class Foo(var one: String)<|endoftext|> |
* ISSUES: KT-19446
*/
fun case_1() {
run {
var unit: Unit? = Unit
while (unit != null) {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Unit? & kotlin.Unit")!>unit<!>
<!UNRESOLVED_REFERENCE!>consume<!>(unit) | unit = null
}
}
run {
var unit: Unit? = Unit
while (unit != null) {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Unit? & kotlin.Unit")!>unit<!>
<!UNRESOLVED_REFERENCE!>consume<!>(unit)
unit = null
}
}<|endoftext|> |
if (targetExistsAndNotSymlink && this.isSameFileAs(target)) {
// TODO: KT-38678
// source and target files are the same entry, continue recursive copy operation
} else {
val isSubdirectory = when {
this.fileSystem != target.fileSystem ->
false
targetExistsAndNotSymlink -> | target.toRealPath().startsWith(this.toRealPath())
else ->
target.parent?.let { it.exists() && it.toRealPath().startsWith(this.toRealPath()) } ?: false
}
if (isSubdirectory)
throw FileSystemException(
this.toString(),
target.toString(),<|endoftext|> |
val fixedQualifiedAccessSegments = qualifiedAccessSegments.drop(1)
assert(referencedClassIdAndQualifiedAccessMatch(fixedQualifiedAccessSegments)) {
"Referenced classId $referencedClassId should end with qualifiedAccess expression ${qualifiedAccess.text} "
}
} | // In the code below, we always maintain the contract that `classId` and `qualifiedAccess` should stay "in-sync", i.e. they
// refer to the same class and classId should be null if `qualifiedAccess` references to a package.
var classId: ClassId? = referencedClassId
// Handle nested classes.
while (classId != null) {<|endoftext|> |
// !JVM_DEFAULT_MODE: all-compatibility
// TARGET_BACKEND: JVM
// JVM_TARGET: 1.8
// WITH_STDLIB
// MODULE: lib
// FILE: 1.kt
interface Test {
fun test(): String = "Fail"
}
class Delegate : Test {
override fun test(): String = "OK"
} | // MODULE: main(lib)
// FILE: 2.kt
class TestClass(val foo: Test) : Test by foo
fun box(): String {
val testClass = TestClass(Delegate())
return testClass.test()
}<|endoftext|> |
// org.jetbrains.kotlin.idea.caches.lightClasses.annotations.KOTLINX_SERIALIZABLE_FQ_NAME and
// org.jetbrains.kotlin.idea.caches.lightClasses.annotations.KOTLINX_SERIALIZER_FQ_NAME accordingly. | // Otherwise, there it might lead to exceptions from light classes when building them for serializer/serializable classes
val serializableAnnotationFqName = FqName("kotlinx.serialization.Serializable")
val serializerAnnotationFqName = FqName("kotlinx.serialization.Serializer")<|endoftext|> |
v.invokevirtual(PARCEL_TYPE.internalName, "readValue", "(Ljava/lang/ClassLoader;)Ljava/lang/Object;", false)
v.castIfNeeded(asmType)
}
}
internal class TypeParcelerParcelSerializer(
override val asmType: Type,
private val parcelerType: KotlinType, | private val typeMapper: KotlinTypeMapper
) : ParcelSerializer {
private val parcelerAsmType = typeMapper.mapType(parcelerType)
override fun writeValue(v: InstructionAdapter) {
// -> parcel, value(?)
boxTypeIfNeeded(v) // -> parcel, (boxed)value
v.swap() // -> value, parcel<|endoftext|> |
public inline fun kotlin.UIntArray.lastIndexOf(element: kotlin.UInt): kotlin.Int
@kotlin.SinceKotlin(version = "1.3")
@kotlin.ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly | public inline fun kotlin.ULongArray.lastIndexOf(element: kotlin.ULong): kotlin.Int
@kotlin.SinceKotlin(version = "1.3")
@kotlin.ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly<|endoftext|> |
fun fn21(x0: Any, x1: Any, x2: Any, x3: Any, x4: Any, x5: Any, x6: Any, x7: Any, x8: Any, x9: Any, x10: Any, x11: Any, x12: Any, x13: Any, x14: Any, x15: Any, x16: Any, x17: Any, x18: Any, | x19: Any, x20: Any) {<|endoftext|> |
if (!(element18 in 1L..3L) != !range0.contains(element18)) throw AssertionError()
if (!(element18 !in 1L..3L) != range0.contains(element18)) throw AssertionError()
}
fun testR0xE19() {
// with possible local optimizations | if (3L in 1L..3L != range0.contains(3L)) throw AssertionError()
if (3L !in 1L..3L != !range0.contains(3L)) throw AssertionError()
if (!(3L in 1L..3L) != !range0.contains(3L)) throw AssertionError()<|endoftext|> |
is ConeKotlinTypeProjectionOut -> ConeKotlinTypeProjectionOut(newType)
is ConeKotlinTypeConflictingProjection -> ConeKotlinTypeConflictingProjection(newType)
}
}
val ConeTypeProjection.variance: Variance
get() = when (this.kind) { | ProjectionKind.STAR -> Variance.OUT_VARIANCE
ProjectionKind.IN -> Variance.IN_VARIANCE
ProjectionKind.OUT -> Variance.OUT_VARIANCE
ProjectionKind.INVARIANT -> Variance.INVARIANT
}<|endoftext|> |
if (element1 !in '3' until '1' != !range1.contains(element1)) throw AssertionError()
if (!(element1 in '3' until '1') != !range1.contains(element1)) throw AssertionError()
if (!(element1 !in '3' until '1') != range1.contains(element1)) throw AssertionError()
} | fun testR1xE2() {
// with possible local optimizations
if ('2' in '3' until '1' != range1.contains('2')) throw AssertionError()
if ('2' !in '3' until '1' != !range1.contains('2')) throw AssertionError()<|endoftext|> |
if (u != null) <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String?"), DEBUG_INFO_SMARTCAST!>u<!>.propT
if (u != null) <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String?"), DEBUG_INFO_SMARTCAST!>u<!>.propAny | if (u != null) <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String?")!>u<!>.propNullableT
if (u != null) <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String?")!>u<!>.propNullableAny<|endoftext|> |
object DummyLogger : Logger {
override fun log(message: String) = println(message)
override fun warning(message: String) = println("w: $message")
override fun error(message: String) = println("e: $message") | @Deprecated(Logger.FATAL_DEPRECATION_MESSAGE, ReplaceWith(Logger.FATAL_REPLACEMENT))
override fun fatal(message: String): Nothing {
error(message)
exitProcess(1) // WARNING: This would stop the JVM process!
}
}<|endoftext|> |
assertTasksExecuted(":kaptGenerateStubsKotlin", ":kaptKotlin", ":compileKotlin", ":compileJava")
// generated sources
assertFileExists(projectPath.resolve("$generatedSrc/foo/bar/UseBar_MembersInjector.java")) | assertFileInProjectNotExists("$generatedSrc/bar/UseBar_MembersInjector.java")
// classes
assertFileExists(kotlinClassesDir().resolve("foo/bar/UseBar.class"))
assertFileNotExists(kotlinClassesDir().resolve("bar/UseBar.class"))<|endoftext|> |
// TARGET_BACKEND: JVM
// FILE: stringVsTXString.kt
fun <T> useTX(x: T, fn: () -> T) = fn()
fun checkNull(x: Any?) {
if (x != null) throw AssertionError("null expected")
}
fun box(): String {
checkNull(useTX("") { J.string() })
return "OK"
} | // FILE: J.java
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class J {
public static String string() {
return null;
}
public static @NotNull String notNullString() {
return null;
}
}<|endoftext|> |