prompt
stringlengths 1
924
| completion
stringlengths 14
937
|
|---|---|
import org.jetbrains.kotlin.serialization.deserialization.builtins.BuiltInSerializerProtocol
import org.jetbrains.kotlin.serialization.deserialization.getClassId
class OptionalAnnotationClassesProvider(
session: FirSession,
moduleDataProvider: ModuleDataProvider,
kotlinScopeProvider: FirKotlinScopeProvider,
|
val packagePartProvider: PackagePartProvider,
defaultDeserializationOrigin: FirDeclarationOrigin = FirDeclarationOrigin.Library
) : AbstractFirDeserializedSymbolProvider(
session, moduleDataProvider, kotlinScopeProvider, defaultDeserializationOrigin, BuiltInSerializerProtocol
) {
private val annotationDeserializer = MetadataBasedAnnotationDeserializer(session)<|endoftext|>
|
return JsBinaryOperation(JsBinaryOperator.GT, arg1, arg2)
}
fun greaterThanEq(arg1: JsExpression, arg2: JsExpression): JsBinaryOperation {
return JsBinaryOperation(JsBinaryOperator.GTE, arg1, arg2)
}
|
fun assignment(left: JsExpression, right: JsExpression): JsBinaryOperation {
return JsBinaryOperation(JsBinaryOperator.ASG, left, right)
}
fun assignmentToThisField(fieldName: String, right: JsExpression): JsStatement {<|endoftext|>
|
if (w != null) <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Number? & kotlin.Int")!>w<!>.funNullableT()
if (w != null) <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Number? & kotlin.Int")!>w<!>.funNullableAny()
|
if (w != null) <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Number? & kotlin.Int")!>w<!>
if (this.w != null) <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Number? & kotlin.Int")!>w<!>.equals(null)<|endoftext|>
|
// TARGET_BACKEND: JVM
// WITH_STDLIB
// FILE: JavaCall.java
public class JavaCall {
public static void test() {
new Example();
new Example("1");
}
}
// FILE: Example.kt
data class Example @JvmOverloads constructor(
var one: String = "",
var two: String = "",
|
var three: String = "",
var four: String = "",
var five: String = "",
var six: String = "",
var seven: String = "",
var eight: String = "",
var nine: String = "",
var ten: String = "",
var eleven: String = "",
var twelve: String = "",
var thirteen: String = "",<|endoftext|>
|
// test.kt:15 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\1\33:int=0:int,
|
$i$f$bar\2\165:int=0:int, $i$f$foo\3\168:int=0:int, $i$a$-suspendCoroutineUninterceptedOrReturn-TestKt$foo$2\4\171\3:int=0:int, b\4:int=2:int<|endoftext|>
|
accessorAnnotationsFromProperty = propertyAnnotations.filterUseSiteTarget(PROPERTY_GETTER),
parameterAnnotationsFromProperty = emptyList()
)
setter = [email protected](
this@toFirProperty,
propertyType,
propertySymbol = symbol,
isGetter = false,
|
accessorAnnotationsFromProperty = propertyAnnotations.filterUseSiteTarget(PROPERTY_SETTER),
parameterAnnotationsFromProperty = propertyAnnotations.filterUseSiteTarget(SETTER_PARAMETER)
)
status = FirDeclarationStatusImpl(getVisibility(), modality).apply {<|endoftext|>
|
if (t is ClassLevel2? && t is Interface1?) {
if (t !is Interface3?) {} else if (false) {
if (t != <!DEBUG_INFO_CONSTANT!>`null`<!>) {
<!DEBUG_INFO_EXPRESSION_TYPE("Interface2 & kotlin.Any?"), DEBUG_INFO_SMARTCAST!>t<!>.itest2()
|
<!DEBUG_INFO_EXPRESSION_TYPE("Interface1 & kotlin.Any?"), DEBUG_INFO_SMARTCAST!>t<!>.itest1()
<!DEBUG_INFO_EXPRESSION_TYPE("Interface2 & kotlin.Any?"), DEBUG_INFO_SMARTCAST!>t<!>.itest()<|endoftext|>
|
// FULL_JDK
// MODULE: lib
// !JVM_DEFAULT_MODE: disable
// FILE: 1.kt
interface Check {
fun test(): String {
return "fail";
}
}
interface SubCheck : Check {
override fun test(): String {
return "OK"
}
}
open class CheckClass : Check
// MODULE: main(lib)
|
// !JVM_DEFAULT_MODE: all
// JVM_TARGET: 1.8
// FILE: main.kt
class SubCheckClass : CheckClass(), SubCheck
fun box(): String {
return SubCheckClass().test()
}<|endoftext|>
|
package org.jetbrains.kotlin.resolve.calls.inference.constraintPosition
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPositionKind.*
import org.jetbrains.kotlin.types.KotlinType
|
enum class ConstraintPositionKind {
RECEIVER_POSITION,
EXPECTED_TYPE_POSITION,
VALUE_PARAMETER_POSITION,
TYPE_BOUND_POSITION,
COMPOUND_CONSTRAINT_POSITION,
FROM_COMPLETER,
SPECIAL;
fun position(): ConstraintPosition {<|endoftext|>
|
"\"../../../../../../../lib/src/main/kotlin/foo.kt\"",
"\"sourcesContent\":[null",
)
// The default should be generating simple names.
assertFileDoesNotContain(libSourceMap, "\"names\":[]")
val libSourceMap2 = projectPath
|
.resolve("build/js/packages/$projectName-app/kotlin/$projectName-lib.js.map")
assertFileContains(
libSourceMap2,
"\"../../../../../lib/src/main/kotlin/foo.kt\"",
"\"sourcesContent\":[null",
)
// The default should be generating simple names.<|endoftext|>
|
// library.kt:57 box: $i$f$foo\56\65:int=0:int, array\56:java.lang.Integer[]=java.lang.Integer[], myClass\56:MyClass=MyClass, this_\58:MyClass=MyClass, $i$f$f1\58\500:int=0:int,
|
$i$a$-f1-LibraryKt$foo$1\60\504\56:int=0:int, $i$f$test\61\500:int=0:int<|endoftext|>
|
val answers = arrayOf(
0x7ff8000000000000UL, 0x7ff0000000000000UL, 0x7ff8000000000000UL, 0x408633ce8fb9f87dUL,
|
0x7ff8000000000000UL, 0x407d8ef0e521dbc8UL, 0x7ff8000000000000UL, 0x7ff8000000000000UL,
0x7ff8000000000000UL, 0x7ff8000000000000UL, 0x7ff8000000000000UL, 0x7ff8000000000000UL,<|endoftext|>
|
get() = S("${global.x}$x")
set(value) {
global = S("${value.x}$x")
}
var nullableTest: S?
get() = S("${global.x}$x")
set(value) {
global = S("${value!!.x}$x")
}
}
fun box(): String {
|
global = S("")
assertEquals(S("42"), S::nonNullTest.call(S("42")))
assertEquals(S("42"), S("42")::nonNullTest.call())
assertEquals(S("42"), S::nonNullTest.getter.call(S("42")))<|endoftext|>
|
for (baseInterface in stubInterface.interfaces) {
if (baseInterface in BASE_STUB_INTERFACES) {
result.addAll(collectProperties(baseInterface))
}
}
return result
}
private fun renderProperty(property: Method): String? {
return try {
val value = property.invoke(this)
|
val name = getPropertyName(property)
"$name=$value"
} catch (e: Exception) {
LOGGER.error(e)
null
}
}
private fun getPropertyName(method: Method): String {
val methodName = method.name!!
if (methodName.startsWith("get")) {<|endoftext|>
|
val protectedIsAllowed =
languageVersionSettings.supportsFeature(LanguageFeature.AllowSealedInheritorsInDifferentFilesOfSamePackage)
if (!(visibilityKeyword == KtTokens.PRIVATE_KEYWORD || (protectedIsAllowed && visibilityKeyword == KtTokens.PROTECTED_KEYWORD))) {
val factory =
|
if (protectedIsAllowed) NON_PRIVATE_OR_PROTECTED_CONSTRUCTOR_IN_SEALED else NON_PRIVATE_CONSTRUCTOR_IN_SEALED
trace.report(factory.on(visibilityModifier))
}
}
}
}
private fun checkModifiersAndAnnotationsInPackageDirective(file: KtFile) {<|endoftext|>
|
task.includes.clear() // we need to include non '.kt' or '.kts' files
task.disallowSourceChanges()
}
NativeLinkTaskMetrics.collectMetrics(this)
if (binary !is TestExecutable) {
tasks.named(binary.compilation.target.artifactsTaskName).dependsOn(linkTask)
|
locateOrRegisterTask<Task>(LifecycleBasePlugin.ASSEMBLE_TASK_NAME).dependsOn(linkTask)
}
if (binary is Framework) {
createFrameworkArtifact(binary, linkTask)
}
}
private fun Project.createRunTask(binary: Executable) {
val taskName = binary.runTaskName ?: return<|endoftext|>
|
moduleDescriptor.builtIns,
ObjCExportMapper(local = true, unitSuspendFunctionExport = UnitSuspendFunctionObjCExport.DEFAULT),
ObjCExportProblemCollector.SILENT,
topLevelNamePrefix,
local = true
)
// Note: this class duplicates some of ObjCExportNamerImpl logic,
// but operates on different representation.
|
internal open class ObjCExportNameTranslatorImpl(
private val configuration: ObjCExportNamer.Configuration,
) : ObjCExportNameTranslator {
private val helper = ObjCExportNamingHelper(configuration.topLevelNamePrefix, configuration.objcGenerics)
override fun getFileClassName(file: KtFile): ObjCExportNamer.ClassOrProtocolName =<|endoftext|>
|
import org.jetbrains.kotlin.resolve.calls.tower.psiExpression
object SuspendConversionCallChecker : CallChecker {
override fun check(resolvedCall: ResolvedCall<*>, reportOn: PsiElement, context: CallCheckerContext) {
if (resolvedCall !is NewResolvedCallImpl<*>) return
|
if (context.languageVersionSettings.supportsFeature(LanguageFeature.SuspendConversion)) return
val argumentsWithSuspendConversion = resolvedCall.resolvedCallAtom.argumentsWithSuspendConversion
for (argumentWithSuspendConversion in argumentsWithSuspendConversion.keys) {
context.trace.report(
Errors.UNSUPPORTED_FEATURE.on(<|endoftext|>
|
// TARGET_BACKEND: JVM
// ASSERTIONS_MODE: jvm
// WITH_STDLIB
// If assertions are disabled, neither argument to assert should be evaluated.
// If assertions are enabled, both arguments should be evaluate to values before
// checking the assertion.
package assertions
interface Checker {
fun check(): Boolean
}
class Checker1 : Checker {
override fun check(): Boolean {
|
var result = true
val lam = {
result = false
{ "Assertion failure" }
}
assert(true, lam())
return result
}
}
class Checker2 : Checker {
override fun check(): Boolean {
var result = true
val lam = {
result = false
{ "Assertion failure" }
}<|endoftext|>
|
override fun newCopyBuilder(): FunctionDescriptor.CopyBuilder<out SimpleFunctionDescriptor> {
TODO("not implemented")
}
override fun <R, D> accept(visitor: DeclarationDescriptorVisitor<R, D>?, data: D) =
visitor!!.visitFunctionDescriptor(this, data)
|
override fun acceptVoid(visitor: DeclarationDescriptorVisitor<Void, Void>?) {
visitor!!.visitFunctionDescriptor(this, null)
}
}
fun IrSimpleFunction.toIrBasedDescriptor() =
when {
isGetter -> IrBasedPropertyGetterDescriptor(this)<|endoftext|>
|
val x14: String? = select(idFromClassTypeArg(), null)
}
val boolean: Boolean? = true
val x15: String? = when (boolean) {
true -> select(<!IMPLICIT_NOTHING_TYPE_ARGUMENT_AGAINST_NOT_NOTHING_EXPECTED_TYPE!>materialize<!>(), null)
|
false -> select(<!IMPLICIT_NOTHING_TYPE_ARGUMENT_AGAINST_NOT_NOTHING_EXPECTED_TYPE!>materialize<!>(), null)
null -> null
}
val x16: String? = when (boolean) {
true -> null
false -> materialize()
null -> null
}<|endoftext|>
|
return withChildClassName(
classOrObject.nameAsSafeName,
isExpect = classIsExpect,
forceLocalContext = isLocalWithinParent,
) {
val classSymbol = FirRegularClassSymbol(context.currentClassId)
withContainerSymbol(classSymbol) {
val isLocal = context.inLocalContext
val classKind = when (classOrObject) {
|
is KtObjectDeclaration -> ClassKind.OBJECT
is KtClass -> when {
classOrObject.isInterface() -> ClassKind.INTERFACE
classOrObject.isEnum() -> ClassKind.ENUM_CLASS
classOrObject.isAnnotation() -> ClassKind.ANNOTATION_CLASS
else -> ClassKind.CLASS
}<|endoftext|>
|
println("@", it.render())
}
if (visibility != Visibility.PUBLIC) {
print(visibility.name.toLowerCaseAsciiOnly(), " ")
}
when (modality) {
null -> {}
Modality.FINAL -> print("final ")
Modality.OPEN -> print("open ")
|
Modality.ABSTRACT -> print("abstract ")
Modality.SEALED -> error("Function cannot be sealed")
}
if (override) {
print("override ")
}
if (isInline) {
print("inline ")
}
print("fun ")
print(typeParameters.typeParameters(end = " "))<|endoftext|>
|
return checkInfiniteSumDefined(value, duration, durationInUnit)
}
if (durationInUnit.isSaturated()) { // duration doesn't fit in Long units
return saturatingAddInHalves(value, unit, duration)
}
val result = value + durationInUnit
if (((value xor result) and (durationInUnit xor result)) < 0) {
|
return if (value < 0) Long.MIN_VALUE else Long.MAX_VALUE
}
return result
}
private fun checkInfiniteSumDefined(value: Long, duration: Duration, durationInUnit: Long): Long {
if (duration.isInfinite() && (value xor durationInUnit < 0)) throw IllegalArgumentException("Summing infinities of different signs")
return value
}<|endoftext|>
|
it.addressOf(Int.MIN_VALUE)
}
}
}
@Test
fun pinnedUByteArrayAddressOf() {
val arr = UByteArray(10) { 0U }
arr.usePinned {
assertEquals(0U, it.addressOf(0).pointed.value)
|
assertEquals(0U, it.addressOf(9).pointed.value)
assertFailsWith<IndexOutOfBoundsException> {
it.addressOf(10)
}
assertFailsWith<IndexOutOfBoundsException> {
it.addressOf(-1)
}
assertFailsWith<IndexOutOfBoundsException> {<|endoftext|>
|
* ISSUES: KT-22996
*/
fun case_5(value_1: Any?): String {
when (value_1) {
is Float, is Char?, is Int -> return ""
is Double, is EmptyObject, is String -> return ""
<!SENSELESS_NULL_IN_WHEN!>null<!> -> return "" // null-check redundant
else -> return ""
|
}
}
/*
* TESTCASE NUMBER: 6
* UNEXPECTED BEHAVIOUR
* ISSUES: KT-22996
*/
fun case_6(value_1: Any?): String {
when (value_1) {<|endoftext|>
|
override fun getType() = classDescriptor.defaultType
override val declarationDescriptor = classDescriptor
override fun equals(other: Any?) = classDescriptor == (other as? ImplicitClassReceiver)?.classDescriptor
override fun hashCode() = classDescriptor.hashCode()
override fun toString() = "Class{$type}"
|
override fun replaceType(newType: KotlinType) =
throw UnsupportedOperationException("Replace type should not be called for this receiver")
override fun getOriginal() = original
}<|endoftext|>
|
* expressions, jump-expressions, break-expression -> paragraph 1 -> sentence 2
* expressions, jump-expressions, break-expression -> paragraph 2 -> sentence 1
* NUMBER: 1
* DESCRIPTION: A simple break expression, specified using the break keyword, which break-jumps to the innermost loop statement in the current scope
*/
fun box(): String {
val inputList = listOf(1, 2, 3)
|
var list1 = mutableListOf<Any>()
for (it in listOf(1, 2, 3)){
for (it1 in listOf("1.", "2.", "3.")) {
if (true) break
}
list1.add(it)
}
if (list1.containsAll(inputList))
return "OK"
else return "NOK"<|endoftext|>
|
is SI1.C2 -> "OK"
SI1.O2 -> "OK"
is SI1.I2 -> "OK"
}
fun compute(sealedInterface: SI2): String = when (sealedInterface) {
is SI2.C1 -> "OK"
SI2.O1 -> "OK"
is SI2.I1 -> "OK"
|
is SI2.C2 -> "OK"
SI2.O2 -> "OK"
is SI2.I2 -> "OK"
}
fun compute(sealedInterface: SI3): String = when (sealedInterface) {
is SI3.C1 -> "OK"
SI3.O1 -> "OK"
is SI3.I1 -> "OK"<|endoftext|>
|
package org.jetbrains.kotlin.gradle.utils
import org.gradle.api.Project
import org.gradle.api.plugins.ExtraPropertiesExtension
internal inline fun <reified T : Any> ExtraPropertiesExtension.getOrPut(key: String, provideValue: () -> T): T {
return synchronized(this) {
if (!has(key)) {
|
set(key, provideValue())
}
val value = get(key) ?: throw NullPointerException("Null extra in for $key")
value.castIsolatedKotlinPluginClassLoaderAware()
}
}
internal inline fun <reified T : Any> Project.getOrPutRootProjectProperty(key: String, provideValue: () -> T) =<|endoftext|>
|
!is SealedChild1, <!USELESS_IS_CHECK!>is SealedChild1<!> -> ""
}
// TESTCASE NUMBER: 5
fun case_5(value_1: Any?): String = when (value_1) {
is SealedChild3, !is SealedChild3? -> ""
else -> ""
}
/*
|
* TESTCASE NUMBER: 6
* UNEXPECTED BEHAVIOUR
* ISSUES: KT-22996
*/
fun case_6(value_1: Any?): String = when (value_1) {
is Boolean?, !is SealedChild3 -> "" // double nullable type check in the one branch
<!USELESS_IS_CHECK!>is SealedChild3<!> -> ""<|endoftext|>
|
atomicGetField(invokePropertyGetter(irGet(refGetter)), valueType),
"atomicfu\$cur", false
)
val upd = createTmpVariable(
irCall(atomicSymbols.invoke1Symbol).apply {
dispatchReceiver = irGet(action)
putValueArgument(0, irGet(cur))
}, "atomicfu\$upd", false
|
)
+irIfThen(
type = atomicSymbols.irBuiltIns.unitType,
condition = irCallAtomicNativeIntrinsic(
functionName = "compareAndSet",
propertyRef = invokePropertyGetter(irGet(refGetter)),
valueType = valueType,
returnType = atomicSymbols.irBuiltIns.booleanType,<|endoftext|>
|
return if (expression.symbol.owner.parentClassOrNull?.isInlined() == true && !expression.symbol.owner.isStatic) {
// Happens in one of the cases:
// 1. In primary constructor of the inlined class. Makes no sense, "has no effect", can be removed.
// The constructor will be lowered and used.
|
// 2. In setter of NativePointed.rawPtr. It is generally a hack and isn't actually used.
// TODO: it is better to get rid of it.
//
// So drop the entire IrSetField:
return builder.irComposite(expression) {}
} else {
expression
}
}<|endoftext|>
|
* TESTCASE NUMBER: 2
* UNEXPECTED BEHAVIOUR
* ISSUES: KT-28489
*/
fun case_2(x: Boolean?) {
l1@ while (true) {
l2@ do {
break@l1
} while (<!UNREACHABLE_CODE!>true || x!!<!>)
}
|
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Boolean & kotlin.Boolean?")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Boolean & kotlin.Boolean?"), DEBUG_INFO_SMARTCAST!>x<!>.not()
}
/*
* TESTCASE NUMBER: 3<|endoftext|>
|
val taskConfig = KaptGenerateStubsConfig(kotlinCompilation)
taskConfig.configureTask {
it.stubsDir.set(getKaptStubsDir())
it.destinationDirectory.set(getKaptIncrementalDataDir())
it.kaptClasspath.from(kaptClasspathConfigurations)
}
taskConfig.execute(kaptTaskProvider)
|
project.whenEvaluated {
addCompilationSourcesToExternalCompileTask(kotlinCompilation, kaptTaskProvider)
}
return kaptTaskProvider
}
private fun Kapt3SubpluginContext.disableAnnotationProcessingInJavaTask() {
javaCompile?.configure { javaCompileInstance ->
if (javaCompileInstance !is JavaCompile)<|endoftext|>
|
fun adoptNode(node: Node): Node
fun createAttribute(localName: String): Attr
fun createAttributeNS(namespace: String?, qualifiedName: String): Attr
fun createEvent(param_interface: String): Event
fun createRange(): Range
fun createNodeIterator(root: Node, whatToShow: Int = definedExternally, filter: NodeFilter? = definedExternally): NodeIterator
|
fun createNodeIterator(root: Node, whatToShow: Int = definedExternally, filter: ((Node) -> Short)? = definedExternally): NodeIterator
fun createTreeWalker(root: Node, whatToShow: Int = definedExternally, filter: NodeFilter? = definedExternally): TreeWalker<|endoftext|>
|
return owner.enhance(
overriddenMembers,
owner,
isCovariant = true,
defaultQualifiers,
containerApplicabilityType,
typeInSignature = TypeInSignature.ReturnPossiblyDeferred(calc),
predefinedEnhancementInfo?.returnTypeInfo,
forAnnotationMember = forAnnotationMember
).type
}
|
override fun toString(): String = "Deferred for Enhancement (Overriddens with Implicit Types)"
}
return null to deferredReturnTypeCalculation
}
return owner.enhance(
overriddenMembers,
owner,
isCovariant = true,
defaultQualifiers,
containerApplicabilityType,
TypeInSignature.Return,<|endoftext|>
|
override fun visitValueParameter(declaration: IrValueParameter, data: Visibles) {
data.visitTypeAccess(declaration, declaration.type)
declaration.varargElementType?.let { data.visitTypeAccess(declaration, it) }
super.visitValueParameter(declaration, data)
}
|
override fun visitValueAccess(expression: IrValueAccessExpression, data: Visibles) {
data.visitValueAccess(expression, expression.symbol.owner)
super.visitValueAccess(expression, data)
}
override fun visitMemberAccess(expression: IrMemberAccessExpression<*>, data: Visibles) {
for (i in 0 until expression.typeArgumentsCount) {<|endoftext|>
|
value = "-Xadd-modules",
valueDescription = "<module[,]>",
description = """Root modules to resolve in addition to the initial modules, or all modules on the module path if <module> is ALL-MODULE-PATH."""
)
var additionalJavaModules: Array<String>? = null
set(value) {
checkFrozen()
field = value
}
|
@Argument(value = "-Xno-call-assertions", description = "Don't generate not-null assertions for arguments of platform types.")
var noCallAssertions = false
set(value) {
checkFrozen()
field = value
}
@Argument(
value = "-Xno-receiver-assertions",<|endoftext|>
|
object MACOS_ARM64 : KonanTarget("macos_arm64", Family.OSX, Architecture.ARM64)
object LINUX_ARM64 : KonanTarget("linux_arm64", Family.LINUX, Architecture.ARM64)
object LINUX_ARM32_HFP : KonanTarget("linux_arm32_hfp", Family.LINUX, Architecture.ARM32)
/**
|
* Removed targets. References are left just to provide a readable diagnostic message (as opposed to
* plain "unresolved reference error").
*
* Note that removed targets do not extend [KonanTarget] in order to make it possible to drop them references
* to them from the codebase without breaking exhaustive `when`s.
*/<|endoftext|>
|
import org.jetbrains.kotlin.fir.MutableOrEmptyList
import org.jetbrains.kotlin.fir.builder.toMutableOrEmpty
import org.jetbrains.kotlin.fir.expressions.FirAnnotation
import org.jetbrains.kotlin.fir.expressions.FirAugmentedAssignment
|
import org.jetbrains.kotlin.fir.expressions.FirExpression
import org.jetbrains.kotlin.fir.expressions.FirOperation
import org.jetbrains.kotlin.fir.visitors.FirTransformer
import org.jetbrains.kotlin.fir.visitors.FirVisitor<|endoftext|>
|
.setConstant(true)
staticData.placeGlobal(rangeEndName, createConstant(llvmType, end), true)
.setConstant(true)
val values = (start..end).map { staticData.createConstKotlinObjectBody(kotlinType, createConstant(llvmType, it)) }
|
staticData.placeGlobalArray(cacheName, llvmBoxType, values, true).also {
it.setConstant(true)
}
}
}
internal fun IrConstantPrimitive.toBoxCacheValue(generationState: NativeGenerationState): ConstValue? {
val irBuiltIns = generationState.context.irBuiltIns
val cacheType = when (value.type) {<|endoftext|>
|
override fun <D> transformTypeArguments(transformer: FirTransformer<D>, data: D): FirCallableReferenceAccessImpl {
typeArguments.transformInplace(transformer, data)
return this
}
override fun <D> transformExplicitReceiver(transformer: FirTransformer<D>, data: D): FirCallableReferenceAccessImpl {
|
explicitReceiver = explicitReceiver?.transform(transformer, data)
return this
}
override fun <D> transformCalleeReference(transformer: FirTransformer<D>, data: D): FirCallableReferenceAccessImpl {
calleeReference = calleeReference.transform(transformer, data)
return this
}<|endoftext|>
|
import org.jetbrains.kotlin.codegen.inline.coroutines.FOR_INLINE_SUFFIX
import org.jetbrains.kotlin.ir.IrElement
import org.jetbrains.kotlin.ir.builders.createTmpVariable
import org.jetbrains.kotlin.ir.builders.irBlockBody
|
import org.jetbrains.kotlin.ir.builders.irInt
import org.jetbrains.kotlin.ir.builders.irReturn
import org.jetbrains.kotlin.ir.declarations.*
import org.jetbrains.kotlin.ir.expressions.IrBlockBody
import org.jetbrains.kotlin.ir.expressions.IrExpressionBody<|endoftext|>
|
"-scheme", swiftApiModuleName.get(),
"-destination", destination(),
) + (inheritedBuildSettings + intermediatesDestination).map { (k, v) -> "$k=$v" },
processConfiguration = {
directory(workingDir.get())
}
)
return syntheticObjectFilesDirectory
}
|
private fun packObjectFilesIntoLibrary(syntheticObjectFilesDirectory: File) {
val objectFilePaths = syntheticObjectFilesDirectory.listFilesOrEmpty().filter {
it.extension == "o"
}.map { it.canonicalPath }
if (objectFilePaths.isEmpty()) {
error("Synthetic project build didn't produce any object files")
}
runCommand(<|endoftext|>
|
"-Pkotlin.daemon.jvmargs=-agentlib:jdwp=transport=dt_socket,server=n,suspend=y,address=$it"
}
)
}
private fun TestProject.withBuildSummary(
buildArguments: List<String>,
run: () -> Unit,
) {
try {
run()
|
} catch (t: Throwable) {
println("<=== Test build: $projectName ===>")
println("<=== Using Gradle version: ${gradleVersion.version} ===>")
println("<=== Run arguments: ${buildArguments.joinToString()} ===>")
println("<=== Project path: ${projectPath.toAbsolutePath()} ===>")
throw t
}<|endoftext|>
|
<!CONFLICTING_OVERLOADS!>@Deprecated(message = "", level = DeprecationLevel.HIDDEN) inline fun testIdenticalPresenceOfInlineModifier()<!> {}
<!CONFLICTING_OVERLOADS!>inline fun testIdenticalPresenceOfInlineModifier()<!> {}
|
<!CONFLICTING_OVERLOADS!>@Deprecated(message = "", level = DeprecationLevel.HIDDEN) inline fun testDifferencesInInlineModifierPresence()<!> {}
<!CONFLICTING_OVERLOADS!>fun testDifferencesInInlineModifierPresence()<!> {}<|endoftext|>
|
@kotlin.internal.IntrinsicConstEvaluation
public override inline fun toShort(): Short =
this.toInt().toShort()
/**
* Converts this [Double] value to [Int].
*
* The fractional part, if any, is rounded down towards zero.
|
* Returns zero if this `Double` value is `NaN`, [Int.MIN_VALUE] if it's less than `Int.MIN_VALUE`,
* [Int.MAX_VALUE] if it's bigger than `Int.MAX_VALUE`.
*/
@kotlin.internal.IntrinsicConstEvaluation
public override fun toInt(): Int =<|endoftext|>
|
val ctx3 = CtxC(3) + CtxA(1) + CtxB(2) // same
val ctx4 = CtxA(1) + CtxB(2) + CtxC(4) // different
assertEquals(ctx1, ctx2)
assertEquals(ctx1, ctx3)
assertEquals(ctx2, ctx3)
|
assertNotEquals(ctx1, ctx4)
assertNotEquals(ctx2, ctx4)
assertNotEquals(ctx3, ctx4)
}
private fun assertContents(ctx: CoroutineContext, vararg elements: CoroutineContext.Element) {
val set = ctx.fold(setOf<CoroutineContext>()) { a, b -> a + b }<|endoftext|>
|
}
}
// FILE: test.kt
fun <T, S: Any> test(x1: T, x2: T?, y1: S, y2: S?) {
<!USELESS_IS_CHECK!>x1 is T?<!>
<!USELESS_IS_CHECK!>x2 is T?<!>
|
<!USELESS_IS_CHECK!>y1 is S?<!>
<!USELESS_IS_CHECK!>y2 is S?<!>
val f1 = JavaClass.foo()
<!USELESS_IS_CHECK!>f1 is Int?<!>
val f2 = JavaClass.fooN()<|endoftext|>
|
if (this.x != null) this.x.funNullableAny()
if (this.x != null) this.x
if (x != null) this.x.equals(null)
if (x != null) this.x.propT
if (x != null) this.x.propAny
if (x != null) this.x.propNullableT
|
if (x != null) this.x.propNullableAny
if (x != null) this.x.funT()
if (x != null) this.x.funAny()
if (x != null) this.x.funNullableT()
if (x != null) this.x.funNullableAny()
if (x != null) this.x<|endoftext|>
|
* It's allowed to pass the same array in the [destination] and even specify the subrange so that it overlaps with the destination range.
*
* @param destination the array to copy to.
* @param destinationOffset the position in the [destination] array to copy to, 0 by default.
* @param startIndex the beginning (inclusive) of the subrange to copy, 0 by default.
|
* @param endIndex the end (exclusive) of the subrange to copy, size of this array by default.
*
* @throws IndexOutOfBoundsException or [IllegalArgumentException] when [startIndex] or [endIndex] is out of range of this array indices or when `startIndex > endIndex`.<|endoftext|>
|
if (subProjectName != null) {
subProject(subProjectName).sourcesDir().resolve(it)
} else {
sourcesDir().resolve(it)
}
}
.map {
it.relativeTo(projectPath)
}
}
/**
|
* Returns a single file located in the [relativePath] subdirectory. If no file or more than one file is found an assertion error will be thrown.
*/
fun Path.getSingleFileInDir(relativePath: String): Path {
val path = resolve(relativePath)
return Files.list(path).use {
val files = it.asSequence().toList()<|endoftext|>
|
return copyOfUninitializedElements(fromIndex, toIndex)
}
/**
* Returns a new array which is a copy of the specified range of the original array.
*
* @param fromIndex the start of the range (inclusive) to copy.
* @param toIndex the end of the range (exclusive) to copy.
*
|
* @throws IndexOutOfBoundsException if [fromIndex] is less than zero or [toIndex] is greater than the size of this array.
* @throws IllegalArgumentException if [fromIndex] is greater than [toIndex].
*/
public actual fun ShortArray.copyOfRange(fromIndex: Int, toIndex: Int): ShortArray {
checkCopyOfRangeArguments(fromIndex, toIndex, size)<|endoftext|>
|
// TESTCASE NUMBER: 1
fun <T: Any, K: Any> case_1(x: T?, y: K?) {
x as T
y as K
|
val z = <!DEBUG_INFO_EXPRESSION_TYPE("T & T & Any & T?")!>x<!> <!USELESS_ELVIS!>?: <!DEBUG_INFO_EXPRESSION_TYPE("K & K & Any & K?"), DEBUG_INFO_SMARTCAST!>y<!><!><|endoftext|>
|
.atMostOne { it.name == CONTINUATION_CONTEXT_PROPERTY_NAME }?.getter!!
return contextGetter.symbol
}
val coroutineContextProperty: PropertyDescriptor
get() {
val vars = coroutinePackage.memberScope.getContributedVariables(
COROUTINE_CONTEXT_NAME,
|
NoLookupLocation.FROM_BACKEND
)
return vars.single()
}
companion object {
private val INTRINSICS_PACKAGE_NAME = Name.identifier("intrinsics")
private val COROUTINE_SUSPENDED_NAME = Name.identifier("COROUTINE_SUSPENDED")<|endoftext|>
|
var accumulator = this[0]
for (index in 1..lastIndex) {
accumulator = operation(accumulator, this[index])
}
return accumulator
}
/**
* Accumulates value starting with the first element and applying [operation] from left to right
* to current accumulator value and each element.
*
|
* Throws an exception if this array is empty. If the array can be empty in an expected way,
* please use [reduceOrNull] instead. It returns `null` when its receiver is empty.
*
* @param [operation] function that takes current accumulator value and an element,
* and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.reduce
*/<|endoftext|>
|
fun <A: Boolean, B: Long?> eqBooleanLongQ(a: A, b: B) = a == b
fun <A: Boolean?, B: Long> eqBooleanQLong(a: A, b: B) = a == b
fun <A: Boolean?, B: Long?> eqBooleanQLongQ(a: A, b: B) = a == b
|
fun <A: Short, B: Byte> eqShortByte(a: A, b: B) = a == b
fun <A: Short, B: Byte?> eqShortByteQ(a: A, b: B) = a == b
fun <A: Short?, B: Byte> eqShortQByte(a: A, b: B) = a == b<|endoftext|>
|
// WITH_STDLIB
// WITH_COROUTINES
import helpers.*
import kotlin.coroutines.*
import kotlin.coroutines.intrinsics.*
var stopped = false
var log = ""
var postponed: () -> Unit = { }
suspend fun delay(): Unit = suspendCoroutine { c ->
log += "1"
postponed = {
log += "3"
|
c.resume(Unit)
}
COROUTINE_SUSPENDED
}
suspend inline fun foo(x: String): String {
delay()
return x
}
suspend inline fun bar(x: String) = foo(x)
suspend fun baz(x: String) = bar(x)
fun act(c: suspend () -> Unit) {<|endoftext|>
|
): CirAnnotation = interner.intern(
CirAnnotationInternedImpl(
type = type,
constantValueArguments = constantValueArguments,
annotationValueArguments = annotationValueArguments
)
)
private val interner = Interner<CirAnnotationInternedImpl>()
}
}
private data class CirAnnotationInternedImpl(
|
override val type: CirClassType,
override val constantValueArguments: Map<CirName, CirConstantValue>,
override val annotationValueArguments: Map<CirName, CirAnnotation>
) : CirAnnotation {
private var hashCode = hashCode(type)
.appendHashCode(constantValueArguments)
.appendHashCode(annotationValueArguments)<|endoftext|>
|
val buildReportPath = outputFile.toPath().toUri().toString()
printBuildReport(data, outputFile)
log.lifecycle("Kotlin build report is written to $buildReportPath")
}
} catch (e: Exception) {
log.error("Could not create Kotlin build report in $buildReportDir", e)
}
}
|
private fun createReportFile(log: KotlinLogger): File? {
for (index in 0..MAX_ATTEMPTS) {
val outputFile = buildReportDir.resolve("$projectName-build-$ts-$index.$fileSuffix")
if (outputFile.createNewFile()) {
return outputFile
}
}<|endoftext|>
|
internal fun checkContextReceiverTypeRefIsResolved(declaration: FirScript, acceptImplicitTypeRef: Boolean = false) {
checkContextReceiverTypeRefIsResolved(declaration.contextReceivers, declaration, acceptImplicitTypeRef)
}
private fun checkContextReceiverTypeRefIsResolved(
contextReceivers: List<FirContextReceiver>,
owner: FirDeclaration,
|
acceptImplicitTypeRef: Boolean,
) {
for (contextReceiver in contextReceivers) {
val receiverTypeRef = contextReceiver.typeRef
checkTypeRefIsResolved(receiverTypeRef, typeRefName = "context receiver type", owner, acceptImplicitTypeRef)
}
}
internal fun checkContractDescriptionIsResolved(declaration: FirContractDescriptionOwner) {<|endoftext|>
|
} else {
reportVisibilityModifierDiagnostics(tokens.values, PRIVATE_SETTER_FOR_OPEN_PROPERTY)
}
} else {
val compare = DescriptorVisibilities.compare(accessorDescriptor.visibility, propertyDescriptor.visibility)
if (compare == null || compare > 0) {
|
reportVisibilityModifierDiagnostics(tokens.values, SETTER_VISIBILITY_INCONSISTENT_WITH_PROPERTY_VISIBILITY)
}
}
}
if (propertyDescriptor.isExpect) {
checkExpectDeclarationHasNoExternalModifier(accessor)
}
}<|endoftext|>
|
// val prop5: true
<!DEBUG_INFO_CONSTANT_VALUE("true")!>val prop5 = y && true<!>
// val prop6: false
<!DEBUG_INFO_CONSTANT_VALUE("false")!>val prop6 = true && false || 2 > 1<!>
// val prop7: true
|
<!DEBUG_INFO_CONSTANT_VALUE("true")!>val prop7 = x == 1<!>
// val prop8: true
<!DEBUG_INFO_CONSTANT_VALUE("true")!>val prop8 = 1 / x<!><|endoftext|>
|
import org.jetbrains.kotlin.fir.visitors.transformSingle
import org.jetbrains.kotlin.fir.withFileAnalysisExceptionWrapping
@OptIn(AdapterForResolveProcessor::class)
class FirContractResolveProcessor(session: FirSession, scopeSession: ScopeSession) : FirTransformerBasedResolveProcessor(
|
session, scopeSession, FirResolvePhase.CONTRACTS
) {
override val transformer = FirContractResolveTransformerAdapter(session, scopeSession)
}
@AdapterForResolveProcessor
class FirContractResolveTransformerAdapter(session: FirSession, scopeSession: ScopeSession) : FirTransformer<Any?>() {
private val transformer = FirContractResolveTransformer(session, scopeSession)<|endoftext|>
|
import org.jetbrains.kotlin.analysis.api.impl.base.test.cases.symbols.*
import org.jetbrains.kotlin.analysis.api.impl.base.test.cases.types.AbstractAnalysisApiSubstitutorsTest
import org.jetbrains.kotlin.analysis.api.impl.base.test.cases.types.AbstractBuiltInTypeTest
|
import org.jetbrains.kotlin.analysis.api.impl.base.test.cases.types.AbstractTypeByDeclarationReturnTypeTest
import org.jetbrains.kotlin.analysis.api.standalone.fir.test.cases.components.psiDeclarationProvider.AbstractPsiDeclarationProviderTest<|endoftext|>
|
if (test2 != "OK_FINALLY" || h.value != "OK_LOCAL, OK_EXCEPTION, OK_FINALLY") return "test2: ${test2}, holder: ${h.value}"
h = Holder()
val test3 = test3(h)
|
if (test3 != "CATCHED_EXCEPTION" || h.value != "OK_LOCAL, OK_EXCEPTION, OK_FINALLY") return "test3: ${test3}, holder: ${h.value}"
h = Holder()
val test4 = test4(h)<|endoftext|>
|
delegationSpecifiers?.let { superTypeRefs += it.superTypesRef }
when {
calculatedModifiers.isEnum() && (classKind == ClassKind.ENUM_CLASS) && delegatedConstructorSource == null -> {
delegatedSuperTypeRef = buildResolvedTypeRef {
type = ConeClassLikeTypeImpl(
implicitEnumType.type.lookupTag,
|
arrayOf(selfType.type),
isNullable = false
)
}
superTypeRefs += delegatedSuperTypeRef
}
calculatedModifiers.isAnnotation() && (classKind == ClassKind.ANNOTATION_CLASS) -> {
superTypeRefs += implicitAnnotationType
delegatedSuperTypeRef = implicitAnyType
}
}<|endoftext|>
|
import org.jetbrains.kotlin.resolve.scopes.receivers.Receiver
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
import org.jetbrains.kotlin.resolve.source.getPsi
import org.jetbrains.kotlin.types.KotlinType
|
import org.jetbrains.kotlin.types.TypeUtils
import org.jetbrains.kotlin.utils.DFS
fun generateDelegateCall(
classDescriptor: ClassDescriptor,
fromDescriptor: FunctionDescriptor,
toDescriptor: FunctionDescriptor,
thisObject: JsExpression,
context: TranslationContext,<|endoftext|>
|
import a.D.<!CONFLICTING_IMPORT!>B<!>
fun test(b: <!OVERLOAD_RESOLUTION_AMBIGUITY!>B<!>) {
<!UNRESOLVED_REFERENCE!>B<!>()
}
// FILE: d.kt
import a.A.*
import a.D.*
// todo ambiguvity here
|
fun test2(b: <!OVERLOAD_RESOLUTION_AMBIGUITY!>B<!>) {
<!UNRESOLVED_REFERENCE!>B<!>()
}<|endoftext|>
|
// test.kt:48 box: m:int=2:int, m1:int=2:int, xg$iv:int=0:int, $i$f$g:int=0:int, yLambdaG:int=2:int, xLambdaG:int=1:int, $i$a$-g-TestKt$box$2:int=0:int
|
// library.kt:12 box: m:int=2:int, m1:int=2:int, xg$iv:int=0:int, $i$f$g:int=0:int, yLambdaG:int=2:int, xLambdaG:int=1:int, $i$a$-g-TestKt$box$2:int=0:int,<|endoftext|>
|
implicitInvokeExplicitRecieverArgumentCast().let { if (it != "OK") result += "FAIL: implicitInvokeExplicitRecieverArgumentCast(): $it\n" }
explicitInvokeImplicitRecieverArgumentCast().let { if (it != "OK") result += "FAIL: explicitInvokeImplicitRecieverArgumentCast(): $it\n" }
|
explicitInvokeExplicitRecieverArgumentCast().let { if (it != "OK") result += "FAIL: explicitInvokeExplicitRecieverArgumentCast(): $it\n" }
return if (result.length == 0) "OK" else result
}
fun implicitArgumentCast(): String {
val a: Any = ""
return when (val result = a(a as String)) {<|endoftext|>
|
* No characters of that string will have special meaning when it is used as a replacement string in [Regex.replace] function.
*/
public actual fun escapeReplacement(literal: String): String = literal.nativeReplace(replacementEscape, "\\$&")
private val patternEscape = RegExp("""[\\^$*+?.()|[\]{}]""", "g")
|
private val replacementEscape = RegExp("""[\\$]""", "g")
internal fun nativeEscapeReplacement(literal: String): String = literal.nativeReplace(nativeReplacementEscape, "$$$$")
private val nativeReplacementEscape = RegExp("""\$""", "g")
}
}<|endoftext|>
|
abstract class My {
abstract var x: Int
<!REDUNDANT_MODIFIER_IN_GETTER!>public<!> get
<!PRIVATE_SETTER_FOR_ABSTRACT_PROPERTY!>private<!> set
abstract val y: Int
|
<!GETTER_VISIBILITY_DIFFERS_FROM_PROPERTY_VISIBILITY!>protected<!> get
abstract protected var z: Int
<!GETTER_VISIBILITY_DIFFERS_FROM_PROPERTY_VISIBILITY!>internal<!> get<|endoftext|>
|
override fun registerReferenceProviders(registrar: KotlinPsiReferenceRegistrar) {
with(registrar) {
registerProvider(factory = ::KtFirForLoopInReference)
registerProvider(factory = ::KtFirInvokeFunctionReference)
registerProvider(factory = ::KtFirPropertyDelegationMethodsReference)
|
registerProvider(factory = ::KtFirDestructuringDeclarationReference)
registerProvider(factory = ::KtFirArrayAccessReference)
registerProvider(factory = ::KtFirConstructorDelegationReference)
registerProvider(factory = ::KtFirCollectionLiteralReference)
registerProvider(factory = ::KtFirKDocReference)<|endoftext|>
|
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER -ABSTRACT_SUPER_CALL
abstract class A {
open fun foo(a: String = "default") {
}
final fun foo2(a: String = "default") {
}
abstract fun foo3(a: String = "default")
}
|
open class B : A() {
fun test() {
super.foo("123")
super.<!SUPER_CALL_WITH_DEFAULT_PARAMETERS!>foo<!>()
super.foo2("123")
super.<!SUPER_CALL_WITH_DEFAULT_PARAMETERS!>foo2<!>()
super.foo3("123")<|endoftext|>
|
import org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid
open class ScopeWithIr(val scope: Scope, val irElement: IrElement)
abstract class IrElementTransformerVoidWithContext : IrElementTransformerVoid() {
private val scopeStack = mutableListOf<ScopeWithIr>()
|
protected open fun createScope(declaration: IrSymbolOwner): ScopeWithIr =
ScopeWithIr(Scope(declaration.symbol), declaration)
protected fun unsafeEnterScope(declaration: IrSymbolOwner) {
scopeStack.push(createScope(declaration))
}
protected fun unsafeLeaveScope() {
scopeStack.pop()
}<|endoftext|>
|
import org.jetbrains.kotlin.ir.linkage.partial.setupPartialLinkageConfig
import org.jetbrains.kotlin.ir.util.IrMessageLogger
import org.jetbrains.kotlin.library.metadata.KlibMetadataVersion
import org.jetbrains.kotlin.metadata.deserialization.BinaryVersion
|
import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.util.profile
import org.jetbrains.kotlin.utils.KotlinPaths
private class K2NativeCompilerPerformanceManager: CommonCompilerPerformanceManager("Kotlin to Native Compiler")<|endoftext|>
|
import org.jetbrains.kotlin.fir.declarations.FirValueParameter
import org.jetbrains.kotlin.fir.declarations.impl.FirPrimaryConstructor
import org.jetbrains.kotlin.fir.declarations.utils.isCompanion
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
|
import org.jetbrains.kotlin.fir.expressions.FirArrayLiteral
import org.jetbrains.kotlin.fir.expressions.FirFunctionCall
import org.jetbrains.kotlin.fir.types.resolvedType
import org.jetbrains.kotlin.fir.types.toRegularClassSymbol<|endoftext|>
|
) : PackageFragmentProviderOptimized {
private val c = LazyJavaResolverContext(components, TypeParameterResolver.EMPTY, lazyOf(null))
private val packageFragments: CacheWithNotNullValues<FqName, LazyJavaPackageFragment> =
c.storageManager.createCacheWithNotNullValues()
|
private fun getPackageFragment(fqName: FqName): LazyJavaPackageFragment? {
val jPackage = c.components.finder.findPackage(fqName) ?: return null
return packageFragments.computeIfAbsent(fqName) {
LazyJavaPackageFragment(c, jPackage)
}
}<|endoftext|>
|
// Bulk Modification Operations
/**
* Adds all of the elements of the specified collection to the end of this list.
*
* The elements are appended in the order they appear in the [elements] collection.
*
* @return `true` if the list was changed as the result of the operation.
*/
override fun addAll(elements: Collection<E>): Boolean
/**
|
* Inserts all of the elements of the specified collection [elements] into this list at the specified [index].
*
* @return `true` if the list was changed as the result of the operation.
*/
public fun addAll(index: Int, elements: Collection<E>): Boolean
override fun removeAll(elements: Collection<E>): Boolean<|endoftext|>
|
I(<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.reflect.KProperty0<kotlin.String>")!>::x<!>)
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Unit")!>I(::x)<!>
|
<!DEBUG_INFO_CALL("fqName: I.Companion.invoke; typeCall: variable&invoke")!>I(::x)<!>
I(<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.reflect.KFunction0<kotlin.String>")!>::y<!>)<|endoftext|>
|
b <!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>+=<!> { C() }
b <!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>+=<!> {1}
}
class B {
private operator fun plusAssign(c: () -> C) {}
|
// private operator fun plus(c: () -> C): C = c()
}
class C
// FILE: LibCase1b.kt
package LibPackCase1.b
import LibPackCase1.a.*
import testPackCase1.B
import testPackCase1.C
operator fun B?.plusAssign( c: ()->C) {} //(2)<|endoftext|>
|
@OptIn(Marker::class)
class A : I
@OptIn(Marker::class)
class B : I
@OptIn(Marker::class)
typealias MyList = ArrayList<I>
@Marker
typealias AList = ArrayList<I>
@Marker
typealias YourList = ArrayList<String>
|
fun my2(my: <!OPT_IN_USAGE_ERROR!>MyList<!>) {}
fun my3(my: <!OPT_IN_USAGE_ERROR!>YourList<!>) {}
fun main() {
val x = <!OPT_IN_USAGE_ERROR!>listOf<!>(A(), B())<|endoftext|>
|
package org.jetbrains.kotlin.fir.analysis.checkers.extended
import org.jetbrains.kotlin.diagnostics.DiagnosticReporter
import org.jetbrains.kotlin.diagnostics.reportOn
import org.jetbrains.kotlin.fir.FirSession
|
import org.jetbrains.kotlin.fir.analysis.checkers.MppCheckerKind
import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext
import org.jetbrains.kotlin.fir.analysis.checkers.expression.FirQualifiedAccessExpressionChecker<|endoftext|>
|
reporter.reportOn(classSymbol.source, FirJsPlainObjectsErrors.ONLY_INTERFACES_ARE_SUPPORTED, classKind, context)
return
}
}
private fun checkJsPlainObjectMembers(
classSymbol: FirClassSymbol<FirClass>,
context: CheckerContext,
reporter: DiagnosticReporter,
) {
|
if (!classSymbol.isEffectivelyExternal(context.session) || !classSymbol.isInterface) return
classSymbol
.declaredMemberScope(context.session, null)
.processAllFunctions {
if (!it.isMethodOfAny && !it.isInline) {<|endoftext|>
|
fun foo1(x : String) : String {
when (x) {
"abc", "cde" -> return "abc_cde"
"efg", "ghi" -> return "efg_ghi"
}
return "other"
}
fun foo2(x : String) : String {
when (x) {
|
"abc", "cde" -> return "abc_cde"
"efg", "ghi" -> return "efg_ghi"
else -> return "other"
}
}
fun box() : String {
//foo1
assertEquals("abc_cde", foo1("abc"))
assertEquals("abc_cde", foo1("cde"))<|endoftext|>
|
logFile.assertLogContainsSequence("Idle timeout exceeded 1s",
"Shutdown started")
}
}
}
fun testDaemonGracefulShutdown() {
withFlagFile(getTestName(true), ".alive") { flagFile ->
|
val daemonOptions = DaemonOptions(autoshutdownIdleSeconds = 1, shutdownDelayMilliseconds = 1, forceShutdownTimeoutMilliseconds = 60000, runFilesPath = File(testTempDir, getTestName(true)).absolutePath)
withLogFile("kotlin-daemon-test") { logFile ->
val daemonJVMOptions = makeTestDaemonJvmOptions(logFile)<|endoftext|>
|
@kotlin.internal.IntrinsicConstEvaluation
public final operator fun plus(other: kotlin.Byte): kotlin.Double
@kotlin.internal.IntrinsicConstEvaluation
public final operator fun plus(other: kotlin.Double): kotlin.Double
@kotlin.internal.IntrinsicConstEvaluation
|
public final operator fun plus(other: kotlin.Float): kotlin.Double
@kotlin.internal.IntrinsicConstEvaluation
public final operator fun plus(other: kotlin.Int): kotlin.Double
@kotlin.internal.IntrinsicConstEvaluation
public final operator fun plus(other: kotlin.Long): kotlin.Double<|endoftext|>
|
p.println("package org.jetbrains.kotlin.ir.interpreter.builtins")
p.println()
p.println("import org.jetbrains.kotlin.ir.interpreter.exceptions.InterpreterMethodNotFoundError")
p.println("import org.jetbrains.kotlin.ir.interpreter.proxy.Proxy")
p.println()
|
p.println("/** This file is generated by `./gradlew generateInterpreterMap`. DO NOT MODIFY MANUALLY */")
p.println()
}
private fun generateInterpretUnaryFunction(p: Printer, unaryOperations: List<Operation>) {
p.println("internal fun interpretUnaryFunction(name: String, type: String, a: Any?): Any? {")<|endoftext|>
|
s = ""
try {
}
catch (e: Exception) {
s = null
return
}
s.length
}
fun test4() {
var s: String? = null
s = ""
try {
}
catch (e: ExcA) {
s = null
return
}
catch (e: ExcB) {
|
}
s.length
}
fun test5(s: String?) {
try {
requireNotNull(s)
}
catch (e: ExcA) {
return
}
catch (e: ExcB) {
}
s<!UNSAFE_CALL!>.<!>length
}
fun test6(s: String?) {<|endoftext|>
|
fun <K> FlowCollector<K>.bar(): K = null as K
fun <K> FlowCollector<K>.foo(): K = null as K
fun <K> K.bar3(): K = null as K
fun <K> K.foo3(): K = null as K
fun bar2(): Int = 1
fun foo2(): Float = 1f
val bar4: Int
get() = 1
|
var foo4: Float
get() = 1f
set(value) {}
val <K> FlowCollector<K>.bar5: K get() = null as K
val <K> FlowCollector<K>.foo5: K get() = null as K
class Foo6
class Foo7<T>
fun foo7() = null as Foo7<Int>
interface FlowCollector<in T> {}<|endoftext|>
|
}
}
override fun visitNamedFunction(function: KtNamedFunction) {
visitFunction(function)
}
override fun visitLambdaExpression(lambdaExpression: KtLambdaExpression) {
mark(lambdaExpression)
val functionLiteral = lambdaExpression.functionLiteral
|
// NB. Behaviour here is implicitly controlled by the LanguageFeature 'UseCallsInPlaceEffect'
// If this feature is turned off, then slice LAMBDA_INVOCATIONS is never written and invocationKind
// in all subsequent calls always 'null', resulting in falling back to old behaviour
visitFunction(functionLiteral, trace[BindingContext.LAMBDA_INVOCATIONS, lambdaExpression])<|endoftext|>
|
compareAnnotationLists(propertyContext, propertyA.getterAnnotations, propertyB.getterAnnotations, AnnotationKind.GETTER)
compareAnnotationLists(propertyContext, propertyA.setterAnnotations, propertyB.setterAnnotations, AnnotationKind.SETTER)
compareTypeParameterLists(propertyContext, propertyA.typeParameters, propertyB.typeParameters)
|
compareNullableEntities(
containerContext = propertyContext,
entityA = propertyA.receiverParameterType,
entityB = propertyB.receiverParameterType,
entityKind = TypeKind.RECEIVER,
entitiesComparator = ::compareTypes
)
compareOrderSensitiveTypeLists(
containerContext = propertyContext,<|endoftext|>
|
}
/** Check if this fqName already used or not. */
private fun checkTopLevelSuiteName(irFile: IrFile, topLevelSuiteName: String): Boolean {
if (topLevelSuiteNames.contains(topLevelSuiteName)) {
context.reportCompilationError("Package '${irFile.packageFqName}' has top-level test " +
|
"functions in several files with the same name: '${irFile.fileName}'")
}
topLevelSuiteNames.add(topLevelSuiteName)
return true
}
private val topLevelSuite = symbols.topLevelSuite.owner
private val topLevelSuiteConstructor = topLevelSuite.constructors.single {
it.valueParameters.size == 1<|endoftext|>
|
classLoader.urLs.asSequence().mapNotNull { url -> url.toValidClasspathFileOrNull() }
}
else -> {
classLoader.classPathFromGetUrlsMethodOrNull()
?: classLoader.classPathFromTypicalResourceUrls()
}
}
classPath
}.filter { processedJars.add(it) }
|
.toList().takeIf { it.isNotEmpty() }
}
internal fun URL.toValidClasspathFileOrNull(): File? =
(toContainingJarOrNull() ?: toFileOrNull())?.takeIf { it.isValidClasspathFile() }
internal fun File.isValidClasspathFile(): Boolean =
isDirectory || (isFile && extension in validClasspathFilesExtensions)<|endoftext|>
|
private fun RegularClassSymbolMarker.asDescriptor(): ClassDescriptor = this as ClassDescriptor
private fun TypeAliasSymbolMarker.asDescriptor(): TypeAliasDescriptor = this as TypeAliasDescriptor
private inline fun <reified T : DeclarationDescriptor> DeclarationSymbolMarker.safeAsDescriptor(): T? = this as? T
|
override val RegularClassSymbolMarker.classId: ClassId
get() = (this as ClassifierDescriptor).classId!!
override val TypeAliasSymbolMarker.classId: ClassId
get() = (this as ClassifierDescriptor).classId!!
override val CallableSymbolMarker.callableId: CallableId
get() {<|endoftext|>
|
import org.jetbrains.kotlin.gradle.tasks.dependsOn
import org.jetbrains.kotlin.gradle.tasks.locateTask
import org.jetbrains.kotlin.gradle.tasks.withType
import javax.inject.Inject
abstract class KotlinD8Ir @Inject constructor(target: KotlinJsIrTarget) :
|
KotlinJsIrSubTargetBase(target, "d8"),
KotlinWasmD8Dsl {
private val d8 = D8RootPlugin.apply(project.rootProject)
override val testTaskDescription: String
get() = "Run all ${target.name} tests inside d8 using the builtin test framework"<|endoftext|>
|
import kotlin.test.*
import kotlin.native.concurrent.*
enum class A {
A, B
}
data class Foo(val kind: A)
// Enums are shared between threads so identity should be kept.
fun box(): String = withWorker {
val result = execute(TransferMode.SAFE, { Foo(A.B) }) { input ->
input.kind === A.B
|
}.result
return if (result) "OK" else "FAIL"
}<|endoftext|>
|
append(right)
return this.toString()
}
fun formatBoth(indent: Int, left: String, right: String) = formatLeft(indent, left).formatRight(right)
println("Usage: ${::printUsageAndExit.javaClass.`package`.name}.CommonizerCLI <task> <options> [<task> <options>...]")
println()
|
println("Tasks:")
for (taskType in TaskType.values()) {
println(formatBoth(1, taskType.alias, taskType.description))
println(formatLeft(1, if (taskType.optionTypes.isNotEmpty()) "Options:" else "No options."))
for (optionType in taskType.optionTypes) {
val lines = optionType.description.split('\n')<|endoftext|>
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.