rinapch/phi1.5-kotlin-finetune
Text Generation
•
Updated
•
2
prompt
stringlengths 1
924
| completion
stringlengths 14
937
|
---|---|
package test
class NestedClasses<TOuter> {
fun f() {
}
val c: Int = 0
private class Nested<TN> {
fun f(p1: TN) {
}
val c = 1
public class NN<TNN> {
fun f(p1: TNN) {
}
val c = 1 | }
inner class NI<TNI : TN> {
fun f(p1: TN, p2: TNI) {
}
}
}
public inner class Inner<TI : TOuter> {
fun f(p1: TI) {
}
private inner class II<TII> {<|endoftext|> |
addAll(declaredMemberScope.getCallableNames())
delegateFields.flatMapTo(this) {
buildScope(it)?.getCallableNames() ?: emptySet()
}
}
}
private val classifierNamesLazy: Set<Name> by lazy(LazyThreadSafetyMode.PUBLICATION) {
buildSet { | addAll(declaredMemberScope.getClassifierNames())
delegateFields.flatMapTo(this) {
buildScope(it)?.getClassifierNames() ?: emptySet()
}
}
}
override fun getCallableNames(): Set<Name> = callableNamesLazy
override fun getClassifierNames(): Set<Name> = classifierNamesLazy
}<|endoftext|> |
fun function(value: T): R = TODO()
}
}
class G4<T, R> {
val property1: T get() = TODO()
val property2: R get() = TODO()
fun function(value: T): R = TODO()
class Nested<T, R> {
val property1: T get() = TODO() | val property2: R get() = TODO()
fun function(value: T): R = TODO()
}
inner class Inner {
val property1: T get() = TODO()
val property2: R get() = TODO()
fun function(value: T): R = TODO()
}
}
class H1<T> {<|endoftext|> |
* NOTE: this test data is generated by FeatureInteractionTestDataGenerator. DO NOT MODIFY CODE MANUALLY!
* HELPERS: reflect
*/
fun f1(`true`: Boolean) = !!!`true`
fun f2(`false`: Boolean, `true`: Boolean) = `false` && `true` | fun f3(`false`: Boolean, `true`: Boolean = `false`) = `false` || !`true`
class A {
var x1: Boolean = false
set(`false`) {
field = !`false`
}
}
fun box(): String? {
val a = A()
a.x1 = false<|endoftext|> |
// FILE: b.kt
package MyPackage
//properties
<!MUST_BE_INITIALIZED!>val a: Int<!>
val a1: Int = 1
<!WRONG_MODIFIER_TARGET!>abstract<!> val a2: Int
<!WRONG_MODIFIER_TARGET!>abstract<!> val a3: Int = 1 | <!MUST_BE_INITIALIZED!>var b: Int<!> private set
var b1: Int = 0; private set
<!WRONG_MODIFIER_TARGET!>abstract<!> var b2: Int private set
<!WRONG_MODIFIER_TARGET!>abstract<!> var b3: Int = 0; private set<|endoftext|> |
call.dispatchReceiver = IrGetValueImpl(startOffset, endOffset, valueParameters[offset].symbol)
offset += 1
}
callTarget.extensionReceiverParameter?.let {
call.extensionReceiver = IrGetValueImpl(startOffset, endOffset, valueParameters[offset].symbol)
offset += 1
}
for (i in offset until valueParameters.size) { | call.putValueArgument(i - offset, IrGetValueImpl(startOffset, endOffset, valueParameters[i].symbol))
}
})
}
override fun visitReturn(expression: IrReturn): IrExpression {
val newFunction = removedFunctions[expression.returnTargetSymbol]?.owner
return super.visitReturn(
if (newFunction != null) {<|endoftext|> |
return createModifierListStubForDeclaration(parent, classProto.flags, relevantFlags, additionalModifiers)
}
private fun doCreateClassOrObjectStub(): StubElement<out PsiElement> {
val isCompanionObject = classKind == ProtoBuf.Class.Kind.COMPANION_OBJECT
val fqName = classId.asSingleFqName() | val shortName = fqName.shortName().ref()
val superTypeRefs = supertypeIds.filterNot {
//TODO: filtering function types should go away
isNumberedFunctionClassFqName(it.asSingleFqName().toUnsafe())
}.map { it.shortClassName.ref() }.toTypedArray()<|endoftext|> |
}
private fun tryMapPsiElementType(kClass: KClass<*>): HLParameterConversion? {
if (kClass.isSubclassOf(PsiElement::class)) {
return HLIdParameterConversion
}
return null
}
private val nullableTypeMapping: Map<KClass<*>, HLFunctionCallConversion> = mapOf( | FirExpression::class to HLFunctionCallConversion(
"{0}?.source?.psi as? KtExpression",
KtExpression::class.createType(nullable = true),
importsToAdd = listOf(
"org.jetbrains.kotlin.psi.KtExpression",
"org.jetbrains.kotlin.psi"<|endoftext|> |
reporter.reportOn(propertySource, FirErrors.PROPERTY_WITH_NO_TYPE_NO_INITIALIZER, context)
}
if (property.isLateInit) {
if (isExpect) {
reporter.reportOn(propertySource, FirErrors.EXPECTED_LATEINIT_PROPERTY, context)
} | // TODO, KT-59807: like [BindingContext.MUST_BE_LATEINIT], we should consider variable with uninitialized error.
if (backingFieldRequired && !inInterface && isCorrectlyInitialized) {
if (context.languageVersionSettings.supportsFeature(LanguageFeature.EnableDfaWarningsInK2)) {<|endoftext|> |
@Target(AnnotationTarget.FIELD, AnnotationTarget.VALUE_PARAMETER)
annotation class ParameterOrFieldAnnotation
@Target(AnnotationTarget.PROPERTY, AnnotationTarget.FIELD, AnnotationTarget.VALUE_PARAMETER)
annotation class UniversalAnnotation
annotation class AnotherUniversalAnnotation
class C( | @PropertyAnnotation @FieldAnnotation @ParameterAnnotation @UniversalAnnotation @AnotherUniversalAnnotation val x1: Int,
@PropertyOrFieldAnnotation val x2: Int,
@PropertyOrParameterAnnotation val x3: Int,
@ParameterOrFieldAnnotation val x4: Int,
@property:UniversalAnnotation @field:AnotherUniversalAnnotation val x5: Int,<|endoftext|> |
put(ErrorsWasm.NESTED_WASM_IMPORT, "Only top-level functions can be imported with @WasmImport")
put(ErrorsWasm.WASM_IMPORT_ON_NON_EXTERNAL_DECLARATION, "Functions annotated with @WasmImport must be external") | put(ErrorsWasm.WASM_IMPORT_EXPORT_PARAMETER_DEFAULT_VALUE, "Default parameter values are not supported with @WasmImport and @WasmExport")
put(ErrorsWasm.WASM_IMPORT_EXPORT_VARARG_PARAMETER, "Vararg parameters are not supported with @WasmImport and @WasmExport")<|endoftext|> |
// TARGET_BACKEND: JVM
// FULL_JDK
// WITH_STDLIB
// WITH_COROUTINES
// CHECK_TAIL_CALL_OPTIMIZATION
// JVM_ABI_K1_K2_DIFF: KT-63864
import helpers.*
import kotlin.coroutines.*
import kotlin.coroutines.intrinsics.* | sealed class X {
class A : X()
class B : X()
}
var log = ""
suspend fun process(a: X.A) {
log = "${log}from A;"
TailCallOptimizationChecker.saveStackTrace()
}
suspend fun process(b: X.B) {
log = "${log}from B;"<|endoftext|> |
val i: /*p:foo*/I = /*p:bar(C)*/c
/*p:foo(I)*/i./*p:foo.I*/ifunc() | /*p:baz p:foo p:java.lang p:kotlin p:kotlin.annotation p:kotlin.collections p:kotlin.comparisons p:kotlin.io p:kotlin.jvm p:kotlin.ranges p:kotlin.sequences p:kotlin.text*/I./*p:foo.I*/isfield<|endoftext|> |
@kotlin.SinceKotlin(version = "1.3")
@kotlin.ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <K> kotlin.UIntArray.groupBy(keySelector: (kotlin.UInt) -> K): kotlin.collections.Map<K, kotlin.collections.List<kotlin.UInt>> | @kotlin.SinceKotlin(version = "1.3")
@kotlin.ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly<|endoftext|> |
public expect inline fun <reified T> Array<out T>?.orEmpty(): Array<out T>
/**
* Returns a *typed* array containing all the elements of this collection.
*
* Allocates an array of runtime type `T` having its size equal to the size of this collection
* and populates the array with the elements of this collection. | * @sample samples.collections.Collections.Collections.collectionToTypedArray
*/
public expect inline fun <reified T> Collection<T>.toTypedArray(): Array<T>
/**
* Fills the list with the provided [value].
*
* Each element in the list gets replaced with the [value].
*/
@SinceKotlin("1.2")<|endoftext|> |
if (x.isEqualsCalled && !y.isEqualsCalled)
return "OK"
}
return "NOK"
}
fun checkEqualls(A: Any?, B: Any?): Boolean {
return (A as? Any)?.equals(B) ?: (B === null)
}
data class A(val a: Boolean) { | var isEqualsCalled = false
override operator fun equals(anObject: Any?): Boolean {
isEqualsCalled = true
if (this === anObject) {
return true
}
if (anObject is A) {
if (anObject.a == a)
return true
}
return false
}
}<|endoftext|> |
package org.jetbrains.kotlin.fir.analysis.js.checkers.expression
import org.jetbrains.kotlin.diagnostics.DiagnosticReporter
import org.jetbrains.kotlin.diagnostics.reportOn
import org.jetbrains.kotlin.fir.analysis.checkers.MppCheckerKind | import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext
import org.jetbrains.kotlin.fir.analysis.checkers.expression.FirCallChecker
import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors
import org.jetbrains.kotlin.fir.declarations.hasAnnotation<|endoftext|> |
assertEquals(
"TEXT: `Test1\n`\n" +
"TEXT: `\rTest2`\n",
clientCalls
)
assertEquals("[]", logString)
}
@Test
fun testLines3() {
handler.write("Test1\n\r\n".toByteArray()) | handler.write("Test2".toByteArray())
handler.close()
assertEquals(
"TEXT: `Test1\n`\n" +
"TEXT: `\r\n`\n" +
"TEXT: `Test2`\n",
clientCalls
)
assertEquals("[]", logString)
}
@Test<|endoftext|> |
* The referenced value.
* @throws IncorrectDereferenceException if referred object is not frozen and current worker is different from the one created [this].
*/
public val value: T
get() = valueOrNull ?: throw IncorrectDereferenceException("illegal attempt to access non-shared $valueDescription bound to `$ownerName` from `${Worker.current.name}`")
/** | * The referenced value or null if referred object is not frozen and current worker is different from the one created [this].
*/
public val valueOrNull: T?
get() = valueBeforeFreezing ?: @Suppress("UNCHECKED_CAST") (derefWorkerBoundReference(ptr) as T?)
/**
* Worker that [value] is bound to.
*/<|endoftext|> |
fun finalClassArgument(x: Out<Final>, y: In<Final>) {}
fun oneArgumentFinal(x: OutPair<Final, Open>) {}
fun arrayOfOutOpen(x: Array<Out<Open>>) {}
fun arrayOfOutFinal(x: Array<Out<Final>>) {}
fun outOfArrayOpen(x: Out<Array<Open>>) {} | fun outOfArrayOutOpen(x: Out<Array<out Open>>) {}
fun deepOpen(x: Out<Out<Out<Open>>>) {}
fun deepFinal(x: Out<Out<Out<Final>>>) {}
fun skipAllOutInvWildcards(): Inv<OutPair<Open, Out<Out<Open>>>> = null!!<|endoftext|> |
override fun visitElement(element: FirElement, data: Any?) {}
private fun prepareFileScopes(file: FirFile): ScopePersistentList {
return supertypeComputationSession.getOrPutFileScope(file) {
createImportingScopes(file, session, scopeSession).asReversed().toPersistentList()
}
} | private fun prepareScopeForNestedClasses(klass: FirClass, forStaticNestedClass: Boolean): ScopePersistentList {
return if (forStaticNestedClass) {
supertypeComputationSession.getOrPutScopeForStaticNestedClasses(klass) {
calculateScopes(klass, withCompanionScopes = true, forStaticNestedClass = true)
}<|endoftext|> |
// !LANGUAGE: -JvmStaticInInterface
// !DIAGNOSTICS: -UNUSED_VARIABLE
open class B {
public open val base1 : Int = 1
public open val base2 : Int = 1
}
class A {
companion object : B() {
var p1:Int = 1
@JvmStatic set(p: Int) { | p1 = 1
}
@JvmStatic val z = 1;
@JvmStatic override val base1: Int = 0
override val base2: Int = 0
@JvmStatic get
}
object A : B() {
var p:Int = 1
@JvmStatic set(p1: Int) {
p = 1
}<|endoftext|> |
// FIR_IDENTICAL
interface Visitor {
fun visit()
fun visitArray(): Visitor? = null
fun visitAnnotation(): Visitor? = null
}
class AnnotationLoader {
fun loadAnnotation(): Visitor? {
return object : Visitor {
override fun visit() {}
override fun visitArray(): Visitor? {
return object : Visitor { | override fun visit() {
foo()
}
}
}
override fun visitAnnotation(): Visitor? {
val visitor = loadAnnotation()!!
return object : Visitor by visitor {
override fun visit() {}
}
}
private fun foo() {}
}
}
}<|endoftext|> |
// TARGET_BACKEND: JVM
// WITH_REFLECT
class A {
fun foo(x: Int, y: Int) = x + y
}
fun box(): String {
val x = (A::foo).call(A(), 42, 239)
if (x != 281) return "Fail: $x"
try {
(A::foo).call() | return "Fail: no exception"
}
catch (e: Exception) {}
return "OK"
}<|endoftext|> |
val tosses2 = List(10) { charSeq.randomOrNull(random2) }
assertEquals(tosses1, tosses2)
}
data("x").let { singletonCharSeq ->
val tosses = List(10) { singletonCharSeq.randomOrNull() } | assertEquals(singletonCharSeq.toList(), tosses.distinct())
}
assertNull(data("").randomOrNull())
}
@Test fun partition() {
val data = "a1b2c3"
val pair = data.partition { it.isAsciiDigit() }
assertEquals("123", pair.first, "pair.first")<|endoftext|> |
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE -NOTHING_TO_INLINE
private val privateProperty = 11;
private fun privateFun() {}
internal val internalProperty = 11;
internal fun internalFun() {}
public inline fun test() { | <!NON_PUBLIC_CALL_FROM_PUBLIC_INLINE!>privateFun<!>()
<!NON_PUBLIC_CALL_FROM_PUBLIC_INLINE!>privateProperty<!>
}
public inline fun test2() {
<!NON_PUBLIC_CALL_FROM_PUBLIC_INLINE!>internalFun<!>()<|endoftext|> |
* Returns an element at the given [index] or `null` if the [index] is out of bounds of this array.
*
* @sample samples.collections.Collections.Elements.getOrNull
*/
public fun BooleanArray.getOrNull(index: Int): Boolean? {
return if (index in indices) get(index) else null
}
/** | * Returns an element at the given [index] or `null` if the [index] is out of bounds of this array.
*
* @sample samples.collections.Collections.Elements.getOrNull
*/
public fun CharArray.getOrNull(index: Int): Char? {
return if (index in indices) get(index) else null
}
/**<|endoftext|> |
$this$filterTo\29:java.lang.Iterable=java.util.ArrayList, destination\29:java.util.Collection=java.util.ArrayList, $i$f$filterTo\29\464:int=0:int, element\29:java.lang.Object=java.lang.Integer, it\30:int=4:int, | $i$a$-filter-LibraryKt$foo$7\30\465\1:int=0:int<|endoftext|> |
// such as test or benchmark sources; find all published compilations:
val publishedCompilations = getPublishedPlatformCompilations(project).values
return sourceSetsUsedInMultipleTargets
.filterValues { compilations -> compilations.any { it in publishedCompilations } }
.keys
} | internal suspend fun getPublishedPlatformCompilations(project: Project): Map<KotlinUsageContext, KotlinCompilation<*>> {
val result = mutableMapOf<KotlinUsageContext, KotlinCompilation<*>>()
project.multiplatformExtension.awaitTargets().withType(InternalKotlinTarget::class.java).forEach { target -><|endoftext|> |
is FunctionType -> this.copy(returnType = this.returnType.substituteInstancetype(container))
is PointerType -> this.copy(pointeeType = this.pointeeType.substituteInstancetype(container))
else -> this
}
data class ObjCProperty(val name: String, val getter: ObjCMethod, val setter: ObjCMethod?) { | fun getType(container: ObjCClassOrProtocol): Type = getter.getReturnType(container)
}
abstract class ObjCClass(name: String) : ObjCClassOrProtocol(name) {
abstract val binaryName: String?
abstract val baseClass: ObjCClass?
/**
* Categories whose methods and properties should be generated as members of Kotlin class.
*/<|endoftext|> |
on(Platform.JS) {
if (primitive == PrimitiveType.Char || primitive in PrimitiveType.unsignedPrimitives) {
body {
"""
return object : AbstractList<T>(), RandomAccess {
override val size: Int get() = this@asList.size
override fun isEmpty(): Boolean = this@asList.isEmpty() | override fun contains(element: T): Boolean = this@asList.contains(element)
override fun get(index: Int): T {
AbstractList.checkElementIndex(index, size)
return this@asList[index]
}
override fun indexOf(element: T): Int {
@Suppress("USELESS_CAST")<|endoftext|> |
package org.jetbrains.kotlin.gradle.plugin.ide
import org.jetbrains.kotlin.gradle.ExternalKotlinTargetApi
import org.jetbrains.kotlin.gradle.idea.tcs.IdeaKotlinDependency
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet
/** | * An [IdeDependencyTransformer] will be invoked after all [IdeDependencyResolver] finished.
* The transformation step is allowed to entirely modify the resolution result. Typical applications would be dependency filtering,
* or grouping. Adding additional dependencies might be harmful, since other transformers might not be able to see this additional
* dependency, running before the addition.
*<|endoftext|> |
@OptIn(UnresolvedExpressionTypeAccess::class)
override val coneTypeOrNull: ConeKotlinType?
get() = annotationTypeRef.coneTypeOrNull
override val annotations: List<FirAnnotation>
get() = emptyList()
override fun <R, D> acceptChildren(visitor: FirVisitor<R, D>, data: D) { | annotationTypeRef.accept(visitor, data)
typeArguments.forEach { it.accept(visitor, data) }
argumentList.accept(visitor, data)
calleeReference.accept(visitor, data)
}
override fun <D> transformChildren(transformer: FirTransformer<D>, data: D): FirAnnotationCallImpl {<|endoftext|> |
if (!(element9 in 1..3) != !range0.contains(element9)) throw AssertionError()
if (!(element9 !in 1..3) != range0.contains(element9)) throw AssertionError()
}
fun testR0xE10() {
// with possible local optimizations | if (1 in 1..3 != range0.contains(1)) throw AssertionError()
if (1 !in 1..3 != !range0.contains(1)) throw AssertionError()
if (!(1 in 1..3) != !range0.contains(1)) throw AssertionError()<|endoftext|> |
val property = annotationPsi.valueParameters.firstOrNull() ?: return emptyArray()
arrayOf(PsiElementResolveResult(property))
}
else -> emptyArray()
}
}
private fun KtDefaultAnnotationArgumentReference.resolveAnnotationCallee(): PsiElement? =
element.getStrictParentOfType<KtAnnotationEntry>() | ?.calleeExpression
?.constructorReferenceExpression
?.mainReference
?.resolve()
}
}<|endoftext|> |
val ClassDescriptor.useGeneratedEnumSerializer: Boolean
get() {
val functions = module.getPackage(SerializationPackages.internalPackageFqName).memberScope.getFunctionNames() | return !functions.contains(ENUM_SERIALIZER_FACTORY_FUNC_NAME) || !functions.contains(ANNOTATED_ENUM_SERIALIZER_FACTORY_FUNC_NAME)
}
fun ClassDescriptor.enumEntries(): List<ClassDescriptor> {
check(this.kind == ClassKind.ENUM_CLASS)<|endoftext|> |
fun box() : String {
val controller = Controller()
builder(controller) {
test {
res = calculate()
}
}
if (controller.res != "OK") return controller.res
controller.res = "FAIL 2"
builder(controller) {
test {
test {
test {
test {
test {
res = calculate()
} | }
}
}
}
}
return controller.res
}<|endoftext|> |
import org.jetbrains.kotlin.fir.visitors.FirVisitor
import org.jetbrains.kotlin.name.Name
open class FirNamedReferenceWithCandidate(
override val source: KtSourceElement?,
override val name: Name,
val candidate: Candidate
) : FirNamedReferenceWithCandidateBase() { | override val candidateSymbol: FirBasedSymbol<*>
get() = candidate.symbol
open val isError: Boolean get() = false
override fun <R, D> acceptChildren(visitor: FirVisitor<R, D>, data: D) {}
override fun <D> transformChildren(transformer: FirTransformer<D>, data: D): FirElement {
return this<|endoftext|> |
private fun test(node: Foo<*>) {
node.data.get(MyEnum.EnumEntry)
val map = node.data
map.get(MyEnum.EnumEntry)
}
open class FooEnumMap<P>(val data: EnumMap<P, Any?>) where P : Enum<P>, P : I | private fun test(node: FooEnumMap<*>) {
node.data.get(MyEnum.EnumEntry)
val map = node.data
map.get(MyEnum.EnumEntry)
}
open class Foo2<P : I>(val data: Map<P, Any?>)
private fun test(node: Foo2<*>) {<|endoftext|> |
// WITH_STDLIB
// SKIP_TXT
// !DIAGNOSTICS: -CAST_NEVER_SUCCEEDS -UNCHECKED_CAST -UNUSED_PARAMETER -UNUSED_VARIABLE -OPT_IN_USAGE_ERROR -UNUSED_EXPRESSION
import kotlin.experimental.ExperimentalTypeInference
fun bar2(): Int = 1 | fun foo2(): Float = 1f
val bar4: Int
get() = 1
var foo4: Float
get() = 1f
set(value) {}
interface FlowCollector<in T> {}
fun <L> flow(block: suspend FlowCollector<L>.() -> Unit) = Flow(block)<|endoftext|> |
import org.jetbrains.kotlin.incremental.components.LookupTracker
import org.jetbrains.kotlin.resolve.calls.components.*
import org.jetbrains.kotlin.resolve.calls.inference.components.ConstraintInjector
import org.jetbrains.kotlin.resolve.sam.SamConversionOracle | import org.jetbrains.kotlin.resolve.sam.SamConversionResolver
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValueWithSmartCastInfo
import org.jetbrains.kotlin.types.TypeSubstitutor
import org.jetbrains.kotlin.types.checker.KotlinTypeRefiner<|endoftext|> |
assertFailsWith<IllegalArgumentException> { Duration.INFINITE + (-Duration.INFINITE) }
}
@Test
fun subtraction() {
assertEquals(10.hours, 0.5.days - 120.minutes)
assertEquals(850.milliseconds, 1.seconds - 150.milliseconds) | assertEquals(1150.milliseconds, 1.seconds - (-150).milliseconds)
assertEquals(1.milliseconds, Long.MAX_VALUE.microseconds - (Long.MAX_VALUE - 1_000).microseconds)
assertEquals((-1).milliseconds, (Long.MAX_VALUE - 1_000).microseconds - Long.MAX_VALUE.microseconds)
run {<|endoftext|> |
import org.jetbrains.kotlin.fir.caches.FirCache
import org.jetbrains.kotlin.fir.caches.firCachesFactory
import org.jetbrains.kotlin.fir.caches.getValue
import org.jetbrains.kotlin.fir.declarations.FirDeclarationOrigin | import org.jetbrains.kotlin.fir.deserialization.SingleModuleDataProvider
import org.jetbrains.kotlin.fir.java.deserialization.KotlinBuiltins
import org.jetbrains.kotlin.fir.realPsi
import org.jetbrains.kotlin.fir.resolve.providers.FirSymbolNamesProvider<|endoftext|> |
map.put(MUST_BE_INITIALIZED_WARNING, "Property must be initialized. This warning will become an error in future releases.")
map.put(MUST_BE_INITIALIZED_OR_BE_FINAL, "Property must be initialized or be final.") | map.put(MUST_BE_INITIALIZED_OR_BE_FINAL_WARNING, "Property must be initialized or be final. This warning will become an error in future releases.")
map.put(MUST_BE_INITIALIZED_OR_BE_ABSTRACT, "Property must be initialized or be abstract.")<|endoftext|> |
package org.jetbrains.kotlin.fir.expressions.impl
import org.jetbrains.kotlin.KtSourceElement
import org.jetbrains.kotlin.fir.declarations.FirAnonymousFunction
import org.jetbrains.kotlin.fir.expressions.FirAnnotation | import org.jetbrains.kotlin.fir.expressions.FirAnonymousFunctionExpression
import org.jetbrains.kotlin.fir.expressions.RawFirApi
import org.jetbrains.kotlin.fir.expressions.UnresolvedExpressionTypeAccess
import org.jetbrains.kotlin.fir.types.ConeKotlinType<|endoftext|> |
// FILE: other_package.kt
package otherpackage
// TESTCASE NUMBER: 13
class EmptyClass13 {}
// TESTCASE NUMBER: 14
typealias TypealiasString14 = String
// FILE: main.kt
import otherpackage.*
// TESTCASE NUMBER: 1
fun case_1(x: Any) { | if (<!SENSELESS_COMPARISON!>x === null<!>) {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any & kotlin.Nothing")!>x<!>
}
}
// TESTCASE NUMBER: 2
fun case_2(x: Nothing) {<|endoftext|> |
val targetLabels: List<Label> = ArrayList(targetLabels)
private val resolvedTargets: Map<Label, Instruction>
get() = _resolvedTargets
fun setResolvedTarget(label: Label, resolvedTarget: Instruction) {
_resolvedTargets[label] = outgoingEdgeTo(resolvedTarget)!!
}
var next: Instruction | get() = _next!!
set(value) {
_next = outgoingEdgeTo(value)
}
override val nextInstructions: Collection<Instruction>
get() {
val targetInstructions = ArrayList(resolvedTargets.values)
targetInstructions.add(next)
return targetInstructions
}<|endoftext|> |
val bucketBranches = mutableListOf<IrBranch>()
bucket.value.mapTo(bucketBranches) { bucketCase ->
val matchedCase = stringConstantToMatchedCase.getValue(bucketCase)
irBranch(matchedCase.condition, matchedCase.branchIndex.toIrConst(intType))
} | bucketBranches.add(irElseBranch(elseBranchIndex.toIrConst(intType)))
irWhen(intType, bucketBranches)
}
BucketSelector(bucket.key, selector)
}
private fun IrBlockBuilder.createTransformedWhen(tempIntVariable: IrVariable, transformedWhen: IrWhen): IrWhen {<|endoftext|> |
import org.jetbrains.kotlin.descriptors.SourceElement
import org.jetbrains.kotlin.descriptors.annotations.Annotations
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.resolve.descriptorUtil.module
abstract class PackageFragmentDescriptorImpl(
module: ModuleDescriptor, | final override val fqName: FqName
) : DeclarationDescriptorNonRootImpl(module, Annotations.EMPTY, fqName.shortNameOrSpecial(), SourceElement.NO_SOURCE),
PackageFragmentDescriptor {
// Not inlined in order to not capture ref on 'module'
private val debugString: String = "package $fqName of $module"<|endoftext|> |
fun foo(x: java.util.SequencedCollection<String>, y: java.util.SequencedSet<String>, z: java.util.Deque<String>) {
x.addFirst("")
x.addLast("")
x.removeFirst()
x.removeLast()
x.getFirst()
x.getLast()
x.first
x.last | y.addFirst("")
y.addLast("")
y.removeFirst()
y.removeLast()
y.getFirst()
y.getLast()
y.first
y.last
z.addFirst("")
z.addLast("")
z.removeFirst()
z.removeLast()
z.getFirst()
z.getLast()<|endoftext|> |
builder {
test2 {
transform {
test2 {
res = "OK"
}
}
}
}
if (res != "OK") return res
res = "FAIL 6"
builder {
test3 {
transform {
test3 {
res = "OK"
}
}
}
}
return res | }<|endoftext|> |
if (symbol !is FirCallableSymbol || other.symbol !is FirCallableSymbol) return false
val otherOriginal = (other.symbol as FirCallableSymbol).unwrapSubstitutionOverrides()
if (symbol.unwrapSubstitutionOverrides<FirCallableSymbol<*>>() == otherOriginal) return true | val scope = originScope as? FirTypeScope ?: return false
@Suppress("UNCHECKED_CAST")
val overriddenProducer = when (symbol) {
is FirNamedFunctionSymbol -> FirTypeScope::processOverriddenFunctions as ProcessAllOverridden<FirCallableSymbol<*>><|endoftext|> |
assertTrue(eqLong(longArrayOf(1, 2, 3), LongArray(3) { it + 1L }))
assertTrue(eqLong(longArrayOf(1), longArrayOf(1).copyOf()))
assertTrue(eqLong(longArrayOf(1, 0), longArrayOf(1).copyOf(2))) | assertTrue(eqLong(longArrayOf(1), longArrayOf(1, 2).copyOf(1)))
assertTrue(eqLong(longArrayOf(1, 2), longArrayOf(1) + 2))
assertTrue(eqLong(longArrayOf(1, 2, 3), longArrayOf(1) + listOf(2L, 3L)))<|endoftext|> |
if (it.tokenType != AND) { //skip in forEachChildren?
children.add(convertType(it))
}
}
if (children.size != 2) {
return buildErrorTypeRef {
source = typeRefSource
diagnostic = ConeSyntaxDiagnostic("Wrong code")
}
}
return buildIntersectionTypeRef { | source = typeRefSource
isMarkedNullable = isNullable
leftType = children[0]
rightType = children[1]
}
}
/**
* @see org.jetbrains.kotlin.parsing.KotlinParsing.parseTypeRefContents
*/<|endoftext|> |
x = x<!UNSAFE_CALL!>.<!>equals(10)
} while (x !== null)
}
/*
* TESTCASE NUMBER: 6
* UNEXPECTED BEHAVIOUR
* ISSUES: KT-7508
*/
fun case_6() {
var x: Any? = null
if (x === null) return
do { | <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any?")!>x<!>
x = x<!UNSAFE_CALL!>.<!>equals(10)
} while (x != null)
}
/*
* TESTCASE NUMBER: 7
* UNEXPECTED BEHAVIOUR
* ISSUES: KT-7508
*/<|endoftext|> |
open class Foo10(x: Int = 10, y: Float = 0f)
class Foo11: Foo10 {
constructor(
x: Float
): super(1, 1f<!UNSUPPORTED_FEATURE!>,<!>)
}
class Foo12: Foo10 {
constructor(
x: Float | ): super(1, 1f<!UNSUPPORTED_FEATURE!>,<!>/**/)
}
fun main() {
val x1 = {
x: Comparable<Comparable<Number>>,
y: Iterable<Iterable<Number>><!UNSUPPORTED_FEATURE!>,<!>
->
println("1")
}<|endoftext|> |
public class J {
public static Iterator<@NotNull Integer> iteratorOfNotNull() {
return Collections.<Integer>singletonList(null).iterator();
}
}
// FILE: NotNull.java
package org.jetbrains.annotations;
import java.lang.annotation.*; | // org.jetbrains.annotations used in the compiler is version 13, whose @NotNull does not support the TYPE_USE target (version 15 does).
// We're using our own @org.jetbrains.annotations.NotNull for testing purposes.
@Documented
@Retention(RetentionPolicy.CLASS)<|endoftext|> |
// JVMS7 (4.7.6): a nested class or interface member will have InnerClasses information
// for each enclosing class and for each immediate member
parentClassCodegen?.innerClasses?.add(irClass)
for (codegen in generateSequence(this) { it.parentClassCodegen }.takeWhile { it.parentClassCodegen != null }) { | innerClasses.add(codegen.irClass)
}
// JVMS7 (4.7.7): A class must have an EnclosingMethod attribute if and only if
// it is a local class or an anonymous class.
//
// The attribute contains the innermost class that encloses the declaration of
// the current class. If the current class is immediately enclosed by a method<|endoftext|> |
visitor.visitResolvable(this, data)
@Suppress("UNCHECKED_CAST")
override fun <E : FirElement, D> transform(transformer: FirTransformer<D>, data: D): E =
transformer.transformResolvable(this, data) as E
fun replaceCalleeReference(newCalleeReference: FirReference) | fun <D> transformCalleeReference(transformer: FirTransformer<D>, data: D): FirResolvable
}<|endoftext|> |
@<!YIELD_IS_RESERVED!>yield<!>() p
@`yield`() p
for (yield in 1..5) {
}
{ yield: Int -> }
val (yield) = listOf(4)
}
fun <T> listOf(vararg e: T): List<T> = null!! | operator fun <T> List<T>.component1() = get(0)
// FILE: 2.kt
package p3
enum class yield {
yield
}
fun f1(yield: Int, foo: Int = <!YIELD_IS_RESERVED!>yield<!>) {}<|endoftext|> |
assertPrints(array.contentEquals(arrayOf("apples", "lime", "oranges")), "false")
}
@Sample
fun charArrayContentEquals() {
val array = charArrayOf('a', 'b', 'c')
// the same size and equal elements | assertPrints(array.contentEquals(charArrayOf('a', 'b', 'c')), "true")
// different size
assertPrints(array.contentEquals(charArrayOf('a', 'b')), "false")
// the elements at index 1 are not equal
assertPrints(array.contentEquals(charArrayOf('a', 'c', 'b')), "false")<|endoftext|> |
private val postponedComputationsAfterAllVariablesAreFixed = mutableListOf<() -> Unit>()
private val storage = MutableConstraintStorage()
private var state = State.BUILDING
private val typeVariablesTransaction: MutableList<TypeVariableMarker> = SmartList()
private val properTypesCache: MutableSet<KotlinTypeMarker> = SmartSet.create() | private val notProperTypesCache: MutableSet<KotlinTypeMarker> = SmartSet.create()
private val intersectionTypesCache: MutableMap<Collection<KotlinTypeMarker>, EmptyIntersectionTypeInfo?> = mutableMapOf()
override var typeVariablesThatAreCountedAsProperTypes: Set<TypeConstructorMarker>? = null<|endoftext|> |
// If the position is in KDoc, we want to pass the owning declaration to the ContextCollector.
// That way, the resulting scope will contain all the nested declarations which can be references by KDoc.
val parentKDoc = positionInFakeFile.parentOfType<KDoc>()
val correctedPosition = parentKDoc?.owner ?: positionInFakeFile
val context = ContextCollector.process( | fakeFile.getOrBuildFirFile(firResolveSession),
SessionHolderImpl(analysisSession.useSiteSession, getScopeSession()),
correctedPosition,
)
val towerDataContext =
context?.towerDataContext
?: errorWithAttachment("Cannot find context for ${positionInFakeFile::class}") {<|endoftext|> |
val annotationShortName = annotationEntry.shortName?.asString() ?: return@flatMap emptyList()
val experimentalAnnotations = when (annotationShortName) {
OPT_IN_ANNOTATION -> {
annotationEntry.valueArguments.mapNotNull mapArguments@{ argument ->
if (argument !is KtValueArgument) return@mapArguments null | val expression = argument.getArgumentExpression() as? KtClassLiteralExpression ?: return@mapArguments null
val classReference = expression.receiverExpression as? KtNameReferenceExpression ?: return@mapArguments null
classReference.getReferencedName().takeIf { it in ExperimentalAnnotations.experimentalAnnotationShortNames }
}
}<|endoftext|> |
private fun List<SerializedIrFileFingerprint>.joinIrFileFingerprints(): String {
return joinToString(FILE_FINGERPRINTS_SEPARATOR)
}
private fun String.parseSerializedIrFileFingerprints(): List<SerializedIrFileFingerprint> { | return split(FILE_FINGERPRINTS_SEPARATOR).mapNotNull(SerializedIrFileFingerprint::fromString)
}
fun serializeModuleIntoKlib(
moduleName: String,
configuration: CompilerConfiguration,
diagnosticReporter: DiagnosticReporter,
metadataSerializer: KlibSingleFileMetadataSerializer<*>,
klibPath: String,<|endoftext|> |
var k: B2 = <!TYPE_MISMATCH!>x<!>
var k2: A2 = <!TYPE_MISMATCH!>x<!>
var k3: C2 = <!TYPE_MISMATCH!>x<!>
var k4: Any? = x
}
else {
var k: Any = x
var k2: A2 = x | var k3: B2 = <!TYPE_MISMATCH!>x<!>
var k4 : C2 = <!TYPE_MISMATCH!>x<!>
}
}
fun test11(x:A2?) {
if (x !is B2 || <!USELESS_IS_CHECK!>x is B2<!>) {
var k: A2? = x<|endoftext|> |
descriptor is ConstructorDescriptor && isSealedClassConstructor(descriptor) -> false
// KT-42641. Don't expose componentN methods of data classes
// because they are useless in Objective-C/Swift.
isComponentNMethod(descriptor) && descriptor.overriddenDescriptors.isEmpty() -> false
descriptor.isHiddenFromObjC() -> false | else -> true
}
private fun CallableMemberDescriptor.isHiddenFromObjC(): Boolean = when {
// Note: the front-end checker requires all overridden descriptors to be either refined or not refined.
overriddenDescriptors.isNotEmpty() -> overriddenDescriptors.first().isHiddenFromObjC()
else -> annotations.any { annotation -><|endoftext|> |
val smartCastManager = resolutionFacade.frontendService<SmartCastManager>()
val dataFlowValue = dataFlowValueFactory.createDataFlowValue(receiverValue, bindingContext, moduleDescriptor)
return if (dataFlowValue.isStable || !stableSmartCastsOnly) { // we don't include smart cast receiver types for "unstable" receiver value to mark members grayed | smartCastManager.getSmartCastVariantsWithLessSpecificExcluded(
receiverValue,
bindingContext,
moduleDescriptor,
dataFlowInfo,
languageVersionSettings,
dataFlowValueFactory
)
} else {
listOf(receiverValue.type)
}
}<|endoftext|> |
// String>>` because we have lost the identity of the captured type at this point: we no longer know that the captured type is
// actually created because of type projection from `get`. Hence, to workaround this problem, we simply remove all the out
// projection and type capturing and compare the types after such erasure. This way, we won't incorrectly reject any valid code | // though we may accept some invalid code. But in presence of the unsound flexible types, we are allowing invalid code already.
val argTypeWithoutOutProjection = argType.removeOutProjection(isCovariant = true)
val lowerBoundWithoutCapturing = context.session.typeApproximator.approximateToSuperType(
lowerBound,<|endoftext|> |
) : Pretty(out, sourceOutput) {
companion object {
private const val ENUM = Flags.ENUM.toLong()
}
override fun print(s: Any) {
out.write(s.toString())
}
override fun visitVarDef(tree: JCVariableDecl) {
if ((tree.mods.flags and ENUM) != 0L) { | // Pretty does not print annotations for enum values for some reason
printExpr(TreeMaker.instance(context).Modifiers(0, tree.mods.annotations))
if (isJava11OrLater()) {
// Print enums fully, there is an issue when using Pretty in JDK 11.
// See https://youtrack.jetbrains.com/issue/KT-33052.<|endoftext|> |
// EXPECTED_REACHABLE_NODES: 1265
// RUN_PLAIN_BOX_FUNCTION
// INFER_MAIN_MODULE
// SKIP_MINIFICATION
// SKIP_NODE_JS
// SKIP_DCE_DRIVEN
// MODULE: exportProtectedMembers
// FILE: lib.kt
@JsExport
open class Foo protected constructor() { | protected fun bar(): String = "protected method"
private var _baz: String = "baz"
protected var baz: String
get() = _baz
set(value) {
_baz = value
}
protected val bazReadOnly: String
get() = _baz
protected val quux: String = "quux"<|endoftext|> |
// inlined
run {
var y = "K"
{
// no suspension
builder {
result = "OK"
}
// 1 suspension
builder {
if (suspendHere() != "56") return@builder
result = "OK"
}
// 2 suspensions
builder {
if (suspendHere() != "56") return@builder | suspendHere()
result = "OK"
}
}.let { it() }
}
return "OK"
}<|endoftext|> |
// Case of progression - for (i in 0 until array.size step n) or for (i in 0..<array.size step n)
if (loopHeader.headerInfo.first.isProgressionPropertyGetter("first") &&
loopHeader.headerInfo.last.isProgressionPropertyGetter("last")) { | val firstReceiver = ((loopHeader.headerInfo.first as IrCall).dispatchReceiver as? IrGetValue)?.symbol?.owner
val lastReceiver = ((loopHeader.headerInfo.last as IrCall).dispatchReceiver as? IrGetValue)?.symbol?.owner
if (firstReceiver == lastReceiver) {<|endoftext|> |
@kotlin.OverloadResolutionByLambdaReturnType
@kotlin.jvm.JvmName(name = "sumOfULong")
@kotlin.WasExperimental(markerClass = {kotlin.ExperimentalUnsignedTypes::class})
@kotlin.internal.InlineOnly | public inline fun <T> kotlin.Array<out T>.sumOf(selector: (T) -> kotlin.ULong): kotlin.ULong
@kotlin.SinceKotlin(version = "1.4")
@kotlin.OverloadResolutionByLambdaReturnType
@kotlin.jvm.JvmName(name = "sumOfDouble")<|endoftext|> |
<!RECEIVER_NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>a.foo(<!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>null<!>, x)<!>.foo()
a.bar().foo()
// jspecify_nullness_mismatch | <!RECEIVER_NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>a.field<!>.foo()
}<|endoftext|> |
.replaceDataFlowInfo(psiCallArgument.dataFlowInfoBeforeThisArgument).let {
if (builderInferenceSession != null) it.replaceInferenceSession(builderInferenceSession) else it
}
val functionTypeInfo = expressionTypingServices.getTypeInfo(psiCallArgument.expression, actualContext) | (temporaryTrace ?: trace).record(BindingContext.NEW_INFERENCE_LAMBDA_INFO, psiCallArgument.ktFunction, LambdaInfo.STUB_EMPTY)
if (builderInferenceSession?.hasInapplicableCall() == true) {
return ReturnArgumentsAnalysisResult(<|endoftext|> |
override fun deserializedSymbolNotFound(idSig: IdSignature): Nothing = delegate.deserializedSymbolNotFound(idSig)
override fun declareIrSymbol(symbol: IrSymbol) {
val signature = symbol.signature
if (signature != null && checkIsFunctionInterface(signature))
resolveFunctionalInterface(signature, symbol.kind()) | else delegate.declareIrSymbol(symbol)
}
override fun init() {
delegate.init(this)
}
override val klib: IrLibrary
get() = delegate.klib
override val strategyResolver: (String) -> DeserializationStrategy
get() = delegate.strategyResolver<|endoftext|> |
override fun getContributedDescriptors(
kindFilter: DescriptorKindFilter,
nameFilter: (Name) -> Boolean
): Collection<DeclarationDescriptor> = emptySet()
}
override fun printStructure(p: Printer) {
p.print(ErrorEntity.ERROR_SCOPE.debugText)
} | override val ownerDescriptor: DeclarationDescriptor =
ErrorClassDescriptor(Name.special(ErrorEntity.ERROR_CLASS.debugText.format("unknown")))
override val isOwnerDescriptorAccessibleByLabel: Boolean = false
override val implicitReceiver: ReceiverParameterDescriptor? = null<|endoftext|> |
fun testNoUnintendedDevDependencies(gradleVersion: GradleVersion) {
project("kotlin-js-browser-project", gradleVersion) {
buildGradleKts.modify(::transformBuildScriptWithPluginsDsl)
build("browserProductionWebpack") { | val appPackageJson = getSubprojectPackageJson(projectName = "kotlin-js-browser", subProject = "app")
val libPackageJson = getSubprojectPackageJson(projectName = "kotlin-js-browser", subProject = "lib")
assertTrue("${appPackageJson.name} should contain css-loader") {<|endoftext|> |
public fun kotlin.String.replaceFirst(oldValue: kotlin.String, newValue: kotlin.String, ignoreCase: kotlin.Boolean = ...): kotlin.String
@kotlin.SinceKotlin(version = "1.5")
@kotlin.WasExperimental(markerClass = {kotlin.ExperimentalStdlibApi::class}) | @kotlin.OverloadResolutionByLambdaReturnType
@kotlin.jvm.JvmName(name = "replaceFirstCharWithChar")
@kotlin.internal.InlineOnly
public inline fun kotlin.String.replaceFirstChar(transform: (kotlin.Char) -> kotlin.Char): kotlin.String<|endoftext|> |
dataFlowInfo: DataFlowInfo,
inferenceSession: InferenceSession,
trace: BindingTrace,
local: Boolean
): KotlinType {
val inferredType = expressionTypingServices.safeGetType(
scope, initializer, TypeUtils.NO_EXPECTED_TYPE, dataFlowInfo, inferenceSession, trace
) | val approximatedType = approximateType(inferredType, local)
return declarationReturnTypeSanitizer.sanitizeReturnType(approximatedType, wrappedTypeFactory, trace, languageVersionSettings)
}
private fun approximateType(type: KotlinType, local: Boolean): UnwrappedType =
typeApproximator.approximateDeclarationType(type, local)
}<|endoftext|> |
compiledSources.single().resolve("test/AnotherType.class").createNewFile()
}
SourceFileStructure(File("ReferencesTwoTypes.java").toURI()).also {
it.addDeclaredType("test.ReferencesTwoTypes")
it.addPrivateType("test.TwoTypes")
cache.javaCache.addSourceStructure(it) | compiledSources.single().resolve("test/ReferencesTwoTypes.class").createNewFile()
}
SourceFileStructure(File("ReferencesAnotherType.java").toURI()).also {
it.addDeclaredType("test.ReferencesAnotherType")
it.addPrivateType("test.AnotherType")
cache.javaCache.addSourceStructure(it)<|endoftext|> |
}
h.value += "fail"
return "OK_NONLOCAL"
},
{
h.value += ", OK_EXCEPTION"
return "OK_EXCEPTION"
},
{
h.value += ", OK_FINALLY"
return "OK_FINALLY"
}, h)
return "" + localResult;
} | fun box(): String {
var h = Holder()
val test0 = test0(h)
if (test0 != 2 || h.value != "OK_NONLOCAL, OK_EXCEPTION, OK_FINALLY, INLINE_CALL_FINALLY") return "test0: ${test0}, holder: ${h.value}"
h = Holder()
val test1 = test1(h)<|endoftext|> |
interface IA {
<!METHOD_OF_ANY_IMPLEMENTED_IN_INTERFACE!>override fun toString(): String = "IA"<!> | <!METHOD_OF_ANY_IMPLEMENTED_IN_INTERFACE!>override fun equals(other: Any?): Boolean = <!SUPERCLASS_NOT_ACCESSIBLE_FROM_INTERFACE!>super<!>.equals(other)<!>
<!METHOD_OF_ANY_IMPLEMENTED_IN_INTERFACE!>override fun hashCode(): Int {
return 42;<|endoftext|> |
println()
}
with(A()) {
<!MODIFIER_FORM_FOR_NON_BUILT_IN_SUSPEND!>suspend<!> {
println()
}
suspend() {
println()
}
suspend({ println() })
suspend<Unit> {
println()
}
} | A() <!MODIFIER_FORM_FOR_NON_BUILT_IN_SUSPEND!>suspend<!> {
println()
}
A() suspend ({
println()
})
}<|endoftext|> |
val atomicLongArrayIncrementAndGet: IrSimpleFunctionSymbol =
atomicLongArrayClassSymbol.owner.addFunction(name = "incrementAndGet", returnType = irBuiltIns.longType).apply {
addValueParameter("i", irBuiltIns.intType)
}.symbol
val atomicLongArrayGetAndIncrement: IrSimpleFunctionSymbol = | atomicLongArrayClassSymbol.owner.addFunction(name = "getAndIncrement", returnType = irBuiltIns.longType).apply {
addValueParameter("i", irBuiltIns.intType)
}.symbol
val atomicLongArrayDecrementAndGet: IrSimpleFunctionSymbol =<|endoftext|> |
yieldString(<!ARGUMENT_TYPE_MISMATCH!>1<!>) checkType { _<Unit>() }
await<String> { "123" } checkType { _<String>() }
// Inference from lambda return type
await { 123 } checkType { _<Int>() }
// Inference from expected type | checkSubtype<String>(await(567))
await<Double>(123) checkType { _<Double>() }
severalParams("", 89) checkType { _<Double>() }
// TODO: should we allow somehow to call with passing continuation explicitly?<|endoftext|> |
callIndent: Int,
originalInfo: SourceRangeInfo,
): ValueDisplay {
var indent = sourceRangeInfo.startColumnNumber - callIndent
var row = sourceRangeInfo.startLineNumber - originalInfo.startLineNumber
val source = text.replace("\n" + " ".repeat(callIndent), "\n") // Remove additional indentation | val columnOffset = findDisplayOffset(original, sourceRangeInfo, source)
val prefix = source.substring(0, columnOffset)
val rowShift = prefix.count { it == '\n' }
if (rowShift == 0) {
indent += columnOffset
} else {
row += rowShift
indent = columnOffset - (prefix.lastIndexOf('\n') + 1)<|endoftext|> |
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.ClassKind
import org.jetbrains.kotlin.descriptors.Modality
import org.jetbrains.kotlin.descriptors.VariableDescriptor
import org.jetbrains.kotlin.diagnostics.Errors.* | import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.resolve.*
import org.jetbrains.kotlin.resolve.calls.checkers.RttiExpressionInformation
import org.jetbrains.kotlin.resolve.calls.checkers.RttiOperation<|endoftext|> |
// FIR_IDENTICAL
// !OPT_IN: kotlin.RequiresOptIn
@RequiresOptIn
@Retention(AnnotationRetention.BINARY)
@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION)
annotation class MyAnn
interface MyInterface {
@MyAnn
fun foo()
@MyAnn
fun bar()
} | val field = object : MyInterface {
@MyAnn
override fun foo() {}
@OptIn(MyAnn::class)
override fun bar() {}
}<|endoftext|> |
sink.yieldDiagnostic(InapplicableCandidate)
}
}
private fun computeDefaultMappingForRawTypeMember(
owner: FirTypeParameterRefsOwner,
context: ResolutionContext
): TypeArgumentMapping.Mapped {
// There might be some minor inconsistencies where in K2, there might be a raw type, while in K1, there was a regular flexible type | // And in that case for K2 we would start a regular inference process leads to TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER because raw scopes
// don't leave type variables there (see KT-54526)
// Also, it might be a separate feature of K2, because even in cases where both compilers had a raw type, it's convenient not to<|endoftext|> |
// KJS_WITH_FULL_RUNTIME
// WITH_STDLIB
// JVM_ABI_K1_K2_DIFF: KT-63864
import kotlin.test.*
var order = StringBuilder()
inline fun expectOrder(at: String, expected: String, body: () -> Unit) { | order = StringBuilder() // have to do that in order to run this test in JS
body()
if (order.toString() != expected) throw AssertionError("$at: expected: $expected, actual: $order")
}
fun low(i: Int): Int {
order.append("L")
return i
}
fun high(i: Int): Int {<|endoftext|> |
0x3ff921fb54442d18UL, 0x3ff921fb54442d18UL, 0x3ff921fb54442d18UL, 0x3ff921fb54442d19UL, | 0x3ff921fb54442d19UL, 0x3ff921fb54442d19UL, 0x3ff921fb54442d19UL, 0x3ff921fb54442d19UL,<|endoftext|> |
// Different kinds of input
testEncoding(false, bytes(-16, -112, -128, -128, '1'.toInt(), -17, -65, -67, -17, -65, -67), "\uD800\uDC001\uDC00\uD800")
// Lone surrogate | testEncoding(false, bytes(-17, -65, -67, '1'.toInt(), '2'.toInt()), "\uD80012", )
testEncoding(false, bytes(-17, -65, -67, '1'.toInt(), '2'.toInt()), "\uDC0012")<|endoftext|> |
package org.jetbrains.kotlin.analysis.low.level.api.fir.api
import org.jetbrains.kotlin.fir.FirElement
import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol
import org.jetbrains.kotlin.fir.types.ConeKotlinType | import org.jetbrains.kotlin.fir.utils.exceptions.withConeTypeEntry
import org.jetbrains.kotlin.fir.utils.exceptions.withFirEntry
import org.jetbrains.kotlin.fir.utils.exceptions.withFirSymbolEntry
import org.jetbrains.kotlin.psi.KtElement<|endoftext|> |
val enhancedExpectedType = substitutor.substituteOrNull(expectedType)
// No enhancement on either side, nothing to check.
if (enhancedActualType == null && enhancedExpectedType == null) return null
val actualTypeForComparison = enhancedActualType ?: actualType
val expectedTypeForComparison = enhancedExpectedType ?: expectedType | return actualTypeForComparison to expectedTypeForComparison
}<|endoftext|> |
import org.jetbrains.kotlin.resolve.calls.model.ExpressionValueArgument
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
import org.jetbrains.kotlin.types.typeUtil.isBoolean
import org.jetbrains.kotlin.types.typeUtil.isNullableAny
object ContractsDslNames { | // Internal marker-annotation for distinguishing our API
val CONTRACTS_DSL_ANNOTATION_FQN = FqName("kotlin.internal.ContractsDsl")
// Types
val EFFECT = Name.identifier("Effect")
val CONDITIONAL_EFFECT = Name.identifier("ConditionalEffect")
val SIMPLE_EFFECT = Name.identifier("SimpleEffect")<|endoftext|> |
* Generated from: [org.jetbrains.kotlin.fir.tree.generator.FirTreeBuilder.lazyBlock]
*/
abstract class FirLazyBlock : FirBlock() {
abstract override val source: KtSourceElement?
@UnresolvedExpressionTypeAccess
abstract override val coneTypeOrNull: ConeKotlinType? | abstract override val annotations: List<FirAnnotation>
abstract override val statements: List<FirStatement>
override fun <R, D> accept(visitor: FirVisitor<R, D>, data: D): R =
visitor.visitLazyBlock(this, data)
@Suppress("UNCHECKED_CAST")<|endoftext|> |
import org.jetbrains.kotlin.konan.exec.Command
import org.jetbrains.kotlin.konan.file.*
import org.jetbrains.kotlin.konan.target.ClangArgs
import org.jetbrains.kotlin.konan.target.KonanTarget
private const val dumpBridges = false | internal class CStubsManager(private val target: KonanTarget, private val generationState: NativeGenerationState) {
fun getUniqueName(prefix: String) = generationState.fileLowerState.getCStubUniqueName(prefix)
fun addStub(kotlinLocation: CompilerMessageLocation?, lines: List<String>, language: String) {<|endoftext|> |
@Deprecated(message = "", level = DeprecationLevel.HIDDEN) private constructor()
}
internal fun TestDifferencesInPrivateAndInternalVisibilitiesA() {}
class TestDifferencesInPrivateAndInternalVisibilitiesAReverse {
private constructor()
}
@Deprecated(message = "", level = DeprecationLevel.HIDDEN) internal fun TestDifferencesInPrivateAndInternalVisibilitiesAReverse() {} | class TestDifferencesInPrivateAndInternalVisibilitiesB {
@Deprecated(message = "", level = DeprecationLevel.HIDDEN) internal constructor()
}
private fun TestDifferencesInPrivateAndInternalVisibilitiesB() {}
class TestDifferencesInPrivateAndInternalVisibilitiesBReverse {
internal constructor()
}<|endoftext|> |
This is a dataset for finetuning a model for Kotlin code completion
The data was scraped from JetBrains/Kotlin repository. The file 'kotlin_code_raw.jsonl' contains ~54k of raw files with code
Pipeline can be ssem here: https://github.com/rinapch/jb_intern