prompt
stringlengths 1
924
| completion
stringlengths 14
937
|
|---|---|
// so we're trying to restore original type by the type name stored in the evalResult.type
val resultClass = evalResult.value?.javaClass
val resultClassTypeName = resultClass?.typeName ?: return null
val expectedType = evalResult.type?.substringBefore('<') ?: return null
if (expectedType == resultClassTypeName) return null
|
val expectedTypesPossiblyInner = generateSequence(expectedType) {
val lastDot = it.lastIndexOf('.')
if (lastDot > 0) buildString {
append(it.substring(0, lastDot))
append('$')
append(it.substring(lastDot + 1))
} else null
}<|endoftext|>
|
import org.jetbrains.kotlin.psi.psiUtil.isContractDescriptionCallPsiCheck
import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.resolve.BindingTrace
import org.jetbrains.kotlin.resolve.calls.util.getResolvedCall
|
import org.jetbrains.kotlin.resolve.scopes.LexicalScope
import org.jetbrains.kotlin.storage.StorageManager
class ContractParsingServices(val languageVersionSettings: LanguageVersionSettings, private val storageManager: StorageManager) {
/**
* ! IMPORTANT NOTICE !
*
* This function has very important non-obvious implicit contract:<|endoftext|>
|
): Foo1(x, y,) {
constructor(
x: Float,
y: Int = 10,
): this(1, 1f,) {}
var x1: Int
get() = 10
set(value,) {
}
var x2: Int
get() = 10
set(
x2,
) {}
|
var x3: (Int) -> Unit
get() = {}
set(x2: (Int) -> Unit,) {}
var x4: (Int) -> Unit
get() = {}
set(x2: (Int) -> Unit,/**/) {}
}
enum class Foo3(x: Int, )
fun foo4(x: Int, y: Comparable<Float>,) {}<|endoftext|>
|
@kotlin.SinceKotlin(version = "1.9")
@kotlin.WasExperimental(markerClass = {kotlin.time.ExperimentalTime::class})
public interface ComparableTimeMark : kotlin.time.TimeMark, kotlin.Comparable<kotlin.time.ComparableTimeMark> {
|
public open override operator fun compareTo(other: kotlin.time.ComparableTimeMark): kotlin.Int
public abstract override operator fun equals(other: kotlin.Any?): kotlin.Boolean
public abstract override fun hashCode(): kotlin.Int
public abstract operator fun minus(other: kotlin.time.ComparableTimeMark): kotlin.time.Duration<|endoftext|>
|
private val transitiveExportCollector = TransitiveExportCollector(context)
fun generateExport(file: IrPackageFragment): List<ExportedDeclaration> {
val namespaceFqName = file.packageFqName
val exports = file.declarations.memoryOptimizedMapNotNull { declaration ->
|
declaration.takeIf { it.couldBeConvertedToExplicitExport() != true }?.let(::exportDeclaration)
}
return when {
exports.isEmpty() -> emptyList()
!generateNamespacesForPackages || namespaceFqName.isRoot -> exports
else -> listOf(ExportedNamespace(namespaceFqName.toString(), exports))
}<|endoftext|>
|
// WITH_STDLIB
import kotlin.test.assertEquals
fun box(): String {
val indexList = mutableListOf<Int>()
val valueList = mutableListOf<Int>()
for ((i, v) in ((4..11).reversed() step 2).withIndex()) {
indexList += i
valueList += v
}
|
assertEquals(listOf(0, 1, 2, 3), indexList)
assertEquals(listOf(11, 9, 7, 5), valueList)
return "OK"
}<|endoftext|>
|
throw MyException("exception")
} catch (e: MyException) {
status += "exception"
return Holder("fail")
} finally {
status += "finally1"
return status
}
} finally {
status += "finally2"
}
}
return Holder("fail")
}
fun nonLocalNestedFinally(): Holder {
|
use {
try {
try {
underMutexFun()
return status
} finally {
status += "finally1"
status
}
} finally {
status += "finally2"
}
}
return Holder("fail")
}
override fun close() {
status += "closed"
throw MyException("error")
}<|endoftext|>
|
* Returns the result of the coroutine or throws its exception if it does not suspend or [COROUTINE_SUSPENDED] if it suspends.
* In the latter case, the [completion] continuation is invoked when the coroutine completes with a result or an exception.
*
* The coroutine is started directly in the invoker's thread without going through the [ContinuationInterceptor] that might
|
* be present in the completion's [CoroutineContext]. It is the invoker's responsibility to ensure that a proper invocation
* context is established.
*
* This function is designed to be used from inside of [suspendCoroutineUninterceptedOrReturn] to resume the execution of the suspended
* coroutine using a reference to the suspending function.
*/
@SinceKotlin("1.3")<|endoftext|>
|
0x4010000000000000UL, 0x4010000000000000UL, 0x4010000000000000UL, 0x4010000000000000UL,
0x4010000000000000UL, 0x4010000000000000UL, 0x40107e0f66afed07UL, 0x40107e0f66aff7b2UL,
|
0x40107e0f66afe25cUL, 0x40101fe03f61bad0UL, 0x4011e3779b97f4a8UL, 0x401007fe00ff6070UL,<|endoftext|>
|
import kotlin.coroutines.intrinsics.*
import kotlin.coroutines.jvm.internal.*
private fun BaseContinuationImpl.getSourceFileAndLineNumber(): Pair<String, Int> {
return (getStackTraceElement()?.fileName ?: "") to (getStackTraceElement()?.lineNumber ?: -1)
}
|
suspend fun getSourceFileAndLineNumberFromContinuation() = suspendCoroutineUninterceptedOrReturn<Pair<String, Int>> {
(it as BaseContinuationImpl).getSourceFileAndLineNumber()
}
var continuation: Continuation<*>? = null
suspend fun suspendHere() = suspendCoroutineUninterceptedOrReturn<Unit> {
continuation = it<|endoftext|>
|
private val doNotGenerateInLightClassMode = setOf(CLASS_MEMBER_DELEGATION_TO_DEFAULT_IMPL, BRIDGE, COLLECTION_STUB, AUGMENTED_BUILTIN_API)
private class LazyJvmDiagnostics(compute: () -> Diagnostics) : Diagnostics {
|
private val delegate by lazy(LazyThreadSafetyMode.SYNCHRONIZED, compute)
override val modificationTracker: ModificationTracker
get() = delegate.modificationTracker
override fun all(): Collection<Diagnostic> = delegate.all()
override fun forElement(psiElement: PsiElement) = delegate.forElement(psiElement)<|endoftext|>
|
if (c != null) <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Unit? & kotlin.Unit")!>c<!>
if (this.c != null) this.c.equals(null)
if (this.c != null) this.c.propT
if (this.c != null) this.c.propAny
|
if (this.c != null) this.c.propNullableT
if (this.c != null) this.c.propNullableAny
if (this.c != null) this.c.funT()
if (this.c != null) this.c.funAny()
if (this.c != null) this.c.funNullableT()<|endoftext|>
|
// Add marker interface
if (superType is KtNonErrorClassType) {
listBuilder.addMarkerInterfaceIfNeeded(superType.classId)
}
}
}
}
return listBuilder
}
context(KtAnalysisSession)
internal fun KtSymbolWithMembers.createInnerClasses(
manager: PsiManager,
|
containingClass: SymbolLightClassBase,
classOrObject: KtClassOrObject?
): List<SymbolLightClassBase> {
val result = SmartList<SymbolLightClassBase>()
getStaticDeclaredMemberScope().getClassifierSymbols().filterIsInstance<KtNamedClassOrObjectSymbol>().mapNotNullTo(result) {<|endoftext|>
|
@DisplayName("Downloading pod from git without specifying neither tag not commit")
@GradleTest
fun testPodDownloadGitNoTagNorCommit(gradleVersion: GradleVersion) {
doTestGit(gradleVersion)
}
@DisplayName("Downloading pod from git with specifying tag")
@GradleTest
|
fun testPodDownloadGitTag(gradleVersion: GradleVersion) {
doTestGit(gradleVersion, tag = "4.0.0")
}
@DisplayName("Downloading pod from git with specifying commit")
@GradleTest
fun testPodDownloadGitCommit(gradleVersion: GradleVersion) {<|endoftext|>
|
return """{"version":3,"file":"single-platform${addToProlog}.js","sources":["SOURCE"],"sourcesContent":[null],"names":[],"mappings":"$mappings"}"""
}
private fun doTest(repeatMappings: Int, addToProlog: String = "") {
val mappings0 =
|
";;;;;;;;;;;;;;;;;;;;;;;;;IAQc,c;EAAA,C;;IAQc,O;IACJ,W;EAAA,C;;IAFA,aAAE,wBAAF,kBAA4B,gCAA5B," +<|endoftext|>
|
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R> ULongArray.foldIndexed(initial: R, operation: (index: Int, acc: R, ULong) -> R): R {
var index = 0
var accumulator = initial
|
for (element in this) accumulator = operation(index++, accumulator, element)
return accumulator
}
/**
* Accumulates value starting with [initial] value and applying [operation] from left to right
* to current accumulator value and each element with its index in the original array.
*
* Returns the specified [initial] value if the array is empty.
*<|endoftext|>
|
// WITH_STDLIB
// IGNORE_BACKEND: WASM
// WASM_MUTE_REASON: STDLIB_COLLECTION_INHERITANCE
// DONT_TARGET_EXACT_BACKEND: NATIVE
open class A : ArrayList<String>()
class B : A()
fun box(): String {
val b = B()
b += "OK"
|
return b.single()
}<|endoftext|>
|
abstract class B : SortedSet<Any>, HashSet<Any>() {
override fun spliterator(): Spliterator<Any> {
return null!!
}
override val size: Int
get() = 5
override fun remove(element: Any): Boolean {
return true
}
}
fun test(a: A, b: B) {
a.size
|
a.add(1)
a.add(null)
a.first()
a.remove(1)
a.removeAll(listOf(null))
b.size
b.add(1)
b.add(null)
b.first()
b.remove(1)
b.removeAll(listOf(null))
}<|endoftext|>
|
constructor(arg: UserKlass = sameDefaultArgument)
}
class TestValueParameterWithAliasedDefaultArgumentsReverse {
constructor(arg: UserKlass = defaultArgument)
@Deprecated(message = "", level = DeprecationLevel.HIDDEN) constructor(arg: UserKlass = sameDefaultArgument)
}
|
class TestIdenticalTypeParametersA<T> {
@Deprecated(message = "", level = DeprecationLevel.HIDDEN) constructor()
constructor()
}
class TestIdenticalTypeParametersB<T> {
@Deprecated(message = "", level = DeprecationLevel.HIDDEN) constructor(arg: T)
constructor(arg: T)
}<|endoftext|>
|
@kotlin.internal.InlineOnly
public inline fun UShortArray.sumOf(selector: (UShort) -> ULong): ULong {
var sum: ULong = 0.toULong()
for (element in this) {
sum += selector(element)
}
return sum
}
/**
|
* Returns a list of pairs built from the elements of `this` array and the [other] array with the same index.
* The returned list has length of the shortest collection.
*
* @sample samples.collections.Iterables.Operations.zipIterable
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes<|endoftext|>
|
import org.jetbrains.kotlin.extensions.StorageComponentContainerContributor
import org.jetbrains.kotlin.fir.extensions.FirExtensionRegistrarAdapter
import org.jetbrains.kotlin.js.translate.extensions.JsSyntheticTranslateExtension
import org.jetbrains.kotlin.library.metadata.KlibMetadataSerializerProtocol
|
import org.jetbrains.kotlin.metadata.SerializationPluginMetadataExtensions
import org.jetbrains.kotlin.metadata.jvm.deserialization.JvmProtoBufUtil
import org.jetbrains.kotlin.platform.TargetPlatform
import org.jetbrains.kotlin.resolve.extensions.SyntheticResolveExtension<|endoftext|>
|
private val outlinedJsCodeFunctions = WeakHashMap<IrFunctionSymbol, JsFunction>()
fun addOutlinedJsCode(symbol: IrSimpleFunctionSymbol, outlinedJsCode: JsFunction) {
outlinedJsCodeFunctions[symbol] = outlinedJsCode
}
fun getJsCodeForFunction(symbol: IrFunctionSymbol): JsFunction? {
|
val jsFunction = outlinedJsCodeFunctions[symbol]
if (jsFunction != null) return jsFunction
val jsFunAnnotation = symbol.owner.getAnnotation(JsAnnotations.jsFunFqn) ?: return null
val jsCode = jsFunAnnotation.getValueArgument(0)
?: compilationException("@JsFun annotation must contain an argument", jsFunAnnotation)<|endoftext|>
|
abstractInBaseClassNoImpl.add(descriptor)
}
override fun multipleImplementationsMemberNotImplemented(descriptor: CallableMemberDescriptor) {
multipleImplementations.add(descriptor)
}
override fun conflictingInterfaceMemberNotImplemented(descriptor: CallableMemberDescriptor) {
|
conflictingInterfaceMembers.add(descriptor)
}
override fun typeMismatchOnInheritance(descriptor1: CallableMemberDescriptor, descriptor2: CallableMemberDescriptor) {
conflictingReturnTypes.add(descriptor1)
conflictingReturnTypes.add(descriptor2)<|endoftext|>
|
| kotlinOptions.sourceMapEmbedSources = "inlining"
| }
|}
|
""".trimMargin()
)
build("compileDevelopmentExecutableKotlinJs") {
val mapFilePath = projectPath.resolve("build/js/packages/$projectName-app/kotlin/$projectName-app.js.map")
|
assertFileDoesNotContain(
mapFilePath,
"fun main(args: Array<String>) {"
)
assertFileContains(
mapFilePath,
"inline fun foo(): String {",
)
}
}
}
@DisplayName("smoke test of org.jetbrains.kotlin.js plugin")
@GradleTest<|endoftext|>
|
} else if (passedTime > frameDuration * 1.5){
lastFrameTime = now // we fell behind more than half frame, reset time
}
// Play frame
video.nextFrame(frame.buffer.pointed.data!!, frame.lineSize)
frame.unref()
}
private fun checkPause() {
while (state == State.PAUSED) {
|
audio.pause()
input.check()
usleep(1u * 1000u)
}
audio.resume()
}
private fun syncAV(info: CodecInfo) {
if (info.hasVideo) {
if (info.hasAudio) {
// Use sound for A/V sync.
if (!decoder.audioVideoSynced()) {<|endoftext|>
|
fun case_1(value_1: Any?) {
if (!(value_1.case_1_1() || value_1.case_1_2() == null)) {
println(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
}
}
/*
* TESTCASE NUMBER: 2
* UNEXPECTED BEHAVIOUR
|
* ISSUES: KT-1982
*/
fun case_2(value_1: Any?) {
if (value_1.case_2_1() || !value_1.case_2_2()) {
println(value_1.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>toByte<!>())
}
}<|endoftext|>
|
<!CONFLICTING_OVERLOADS!>@Deprecated(message = "", level = DeprecationLevel.HIDDEN) open fun <T> testTypeParameterWithMultipleTypeAliasedUpperBoundsAAB(arg: T)<!> where T: UserInterfaceA, T: UserInterfaceB {}
|
<!CONFLICTING_OVERLOADS!>open fun <T> testTypeParameterWithMultipleTypeAliasedUpperBoundsAAB(arg: T)<!> where T: UserInterfaceA, T: SameUserInterfaceB {}<|endoftext|>
|
<!DEBUG_INFO_EXPRESSION_TYPE("T")!>x<!>
}
}
inner class C(x: () -> T){
init {
x checkType { check<() -> T>() }
<!DEBUG_INFO_EXPRESSION_TYPE("() -> T")!>x<!>
}
}
|
inner class D<T : Enum<*>>(x: T){
init {
x checkType { check<T>() }
<!DEBUG_INFO_EXPRESSION_TYPE("T")!>x<!>
}
}
inner class E(n: Nothing, x: T){
init {
x checkType { check<T>() }<|endoftext|>
|
@OptIn(ExperimentalContracts::class)
fun FirClassSymbol<*>.isSuitableJavaClass(): Boolean {
contract {
returns(true) implies (this@isSuitableJavaClass is FirRegularClassSymbol)
}
return (this is FirRegularClassSymbol) && origin == FirDeclarationOrigin.Java.Source
}
@OptIn(SymbolInternals::class)
|
fun List<FirFunction>.filterClashingDeclarations(classSymbol: FirClassSymbol<*>): List<FirFunctionSymbol<*>> {
@Suppress("UNCHECKED_CAST")
val allStaticFunctionsAndConstructors = classSymbol.fir.declarations.filterIsInstance<FirFunction>().toMutableList()
val result = mutableListOf<FirFunction>()<|endoftext|>
|
public fun kotlin.ShortArray.first(): kotlin.Short
public inline fun kotlin.ShortArray.first(predicate: (kotlin.Short) -> kotlin.Boolean): kotlin.Short
@kotlin.SinceKotlin(version = "1.3")
@kotlin.ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
|
public inline fun kotlin.UByteArray.first(): kotlin.UByte
@kotlin.SinceKotlin(version = "1.3")
@kotlin.ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun kotlin.UByteArray.first(predicate: (kotlin.UByte) -> kotlin.Boolean): kotlin.UByte<|endoftext|>
|
assertEquals(110, atomicIntArr.getAndAdd(1, -100), "getAndAdd: FAIL 3")
assertEquals(10, atomicIntArr[1], "getAndAdd: FAIL 4")
assertFailsWith<IndexOutOfBoundsException> {
val res = atomicIntArr.getAndAdd(22, 33535)
}.let { ex ->
|
assertEquals("The index 22 is out of the bounds of the AtomicIntArray with size 10.", ex.message)
}
assertFailsWith<IndexOutOfBoundsException> {
val res = atomicIntArr.getAndAdd(-1, 33535)
}.let { ex ->
assertEquals("The index -1 is out of the bounds of the AtomicIntArray with size 10.", ex.message)<|endoftext|>
|
case.boo.boo(1, 2)
//to (1.1)
case.boo.<!DEBUG_INFO_CALL("fqName: testPackCase2.Case2.Companion.boo; typeCall: extension function")!>boo(x = 1, y = 2)<!>
//(1.1) return type is String
|
case.boo.boo(x = 1, y = 2)
case.apply { 1.<!DEBUG_INFO_CALL("fqName: testPackCase2.Case2.Companion.boo; typeCall: extension function")!>boo(1, 1)<!> }
case.apply { 1.boo(1, 1) }<|endoftext|>
|
mfvc: IrClass,
leaves: List<LeafMfvcNode>,
newPrimaryConstructor: IrConstructor?,
) = context.irFactory.buildFun {
name = Name.identifier(KotlinTypeMapper.BOX_JVM_METHOD_NAME)
origin = JvmLoweredDeclarationOrigin.SYNTHETIC_MULTI_FIELD_VALUE_CLASS_MEMBER
|
returnType = mfvc.defaultType
}.apply {
parent = mfvc
copyTypeParametersFrom(mfvc)
val mapping = mfvc.typeParameters.zip(typeParameters) { classTypeParameter, functionTypeParameter ->
classTypeParameter.symbol to functionTypeParameter.defaultType
}.toMap()
returnType = returnType.substitute(mapping)<|endoftext|>
|
open class B {
val x = 1
}
class A : B() {
fun getX() = 1
fun getA(): Int = 1
val a: Int = 1
}
fun getB(): Int = 1
val b: Int = 1
interface Tr {
fun getTr() = 1
}
class SubTr : Tr {
val tr = 1
}
|
// Clashing synthetic accessors are only reported in compiler, IDE doesn't see them
class C {
private fun f() {}
fun `access$f`(c: C) {}
class Nested {
fun test() {
C().f()
}
}
}<|endoftext|>
|
CXCursor_NotImplemented(72),
CXCursor_InvalidCode(73),
CXCursor_UnexposedExpr(100),
CXCursor_DeclRefExpr(101),
CXCursor_MemberRefExpr(102),
CXCursor_CallExpr(103),
CXCursor_ObjCMessageExpr(104),
|
CXCursor_BlockExpr(105),
CXCursor_IntegerLiteral(106),
CXCursor_FloatingLiteral(107),
CXCursor_ImaginaryLiteral(108),
CXCursor_StringLiteral(109),
CXCursor_CharacterLiteral(110),
CXCursor_ParenExpr(111),<|endoftext|>
|
while (stack.isNotEmpty()) {
val insn = stack.popLast()
// In Unit-returning functions, the last statement is followed by POP + GETSTATIC Unit.INSTANCE
// if it is itself not Unit-returning.
if (insn.opcode == Opcodes.ARETURN || (optimizeReturnUnit && insn.isPopBeforeReturnUnit)) {
|
if (frames[instructions.indexOf(insn)]?.top() !is FromSuspensionPointValue?) {
return false
}
} else if (insn !== this && !insn.isSafe()) {
return false
} else {
for (nextIndex in controlFlowGraph.getSuccessorsIndices(insn)) {<|endoftext|>
|
$i$a$-f2-LibraryKt$foo$11\45\492\1:int=0:int
|
// library.kt:56 box: $i$f$foo\1\64:int=0:int, array\1:java.lang.Integer[]=java.lang.Integer[], myClass\1:MyClass=MyClass, this_\43:MyClass=MyClass, $i$f$f2\43\477:int=0:int,<|endoftext|>
|
with(parameters) {
val execClang = ExecClang.create(objects, platformManager.get())
val args = clangFlags.get() + listOf(llvmLinkOutputFile.asFile.get().absolutePath, "-o", compilerOutputFile.asFile.get().absolutePath)
compilerOutputFile.asFile.get().parentFile.mkdirs()
|
if (target.family.isAppleFamily) {
execClang.execToolchainClang(target) {
executable = "clang++"
this.args = args
}
} else {
execClang.execBareClang {
executable = "clang++"
this.args = args
}
}
}
}<|endoftext|>
|
package org.jetbrains.kotlin.native.interop.skia
import clang.*
import kotlinx.cinterop.CValue
import org.jetbrains.kotlin.native.interop.indexer.*
fun buildSkiaNativeIndexImpl(library: NativeLibrary, verbose: Boolean): IndexerResult {
val result = SkiaNativeIndexImpl(library, verbose)
|
return buildNativeIndexImpl(result)
}
class SkiaNativeIndexImpl(library: NativeLibrary, verbose: Boolean) : NativeIndexImpl(library, verbose) {
override fun convertType(type: CValue<CXType>, typeAttributes: CValue<CXTypeAttributes>?): Type {
if (type.kind == CXTypeKind.CXType_Record) {<|endoftext|>
|
package org.jetbrains.kotlin.psi
import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
import org.jetbrains.kotlin.lexer.KtTokens
|
import org.jetbrains.kotlin.test.KotlinTestUtils
import org.jetbrains.kotlin.test.KotlinTestWithEnvironment
import org.junit.Assert
class KtPsiFactoryTest : KotlinTestWithEnvironment() {
fun testCreateModifierList() {
val psiFactory = KtPsiFactory(project)<|endoftext|>
|
// 2 public _\$_findCachedViewById
// 2 public _\$_clearFindViewByIdCache
// 1 INVOKEVIRTUAL android/app/Fragment\.getView
// 1 GETSTATIC test/R\$id\.login : I
// 1 GETSTATIC test/R\$id\.loginButton : I
// 1 INVOKEVIRTUAL test/MyActivity\._\$_findCachedViewById
|
// 1 INVOKEVIRTUAL test/MyFragment\._\$_findCachedViewById
// 2 CHECKCAST android/widget/Button<|endoftext|>
|
candidate.diagnostics.all { it.isSuccess || it.applicability == CandidateApplicability.K2_VISIBILITY_ERROR }
} else false
}
private fun createErrorReferenceForSingleCandidate(
candidate: Candidate?,
diagnostic: ConeDiagnostic,
callInfo: CallInfo,
source: KtSourceElement?
): FirNamedReference {
|
if (candidate == null) return buildReferenceWithErrorCandidate(callInfo, diagnostic, source)
return when (diagnostic) {
is ConeUnresolvedError, is ConeHiddenCandidateError -> buildReferenceWithErrorCandidate(callInfo, diagnostic, source)
else -> createErrorReferenceWithExistingCandidate(
candidate,
diagnostic,
source,
transformer.resolutionContext,<|endoftext|>
|
DependencyCase.DEPENDENCY_NOT_SET -> {
logger.error("Dependency not set")
null
}
null -> null
}
}
fun IdeaKotlinDependency.toByteArray(context: IdeaKotlinSerializationContext): ByteArray {
return context.IdeaKotlinDependencyProto(this).toByteArray()
}
|
fun IdeaKotlinSerializationContext.IdeaKotlinDependency(data: ByteArray): IdeaKotlinDependency? {
return try {
val proto = IdeaKotlinDependencyProto.parseFrom(data)
IdeaKotlinDependency(proto)
} catch (e: InvalidProtocolBufferException) {<|endoftext|>
|
/** Appends [value] to this [StringBuilder], followed by a line separator. */
@Suppress("DEPRECATION")
@Deprecated(
"Use appendLine instead. Note that the new method always appends the line feed character '\\n' regardless of the system line separator.",
ReplaceWith("appendLine(value)"),
level = DeprecationLevel.WARNING
)
|
@kotlin.internal.InlineOnly
public inline fun StringBuilder.appendln(value: Short): StringBuilder = append(value.toInt()).appendln()
/** Appends [value] to this [StringBuilder], followed by a line separator. */
@Suppress("DEPRECATION")
@Deprecated(<|endoftext|>
|
fun loadValueParameterAnnotations(
container: ProtoContainer,
callableProto: MessageLite,
kind: AnnotatedCallableKind,
parameterIndex: Int,
proto: ProtoBuf.ValueParameter
): List<A>
fun loadExtensionReceiverParameterAnnotations(
container: ProtoContainer,
proto: MessageLite,
|
kind: AnnotatedCallableKind
): List<A>
fun loadTypeAnnotations(
proto: ProtoBuf.Type,
nameResolver: NameResolver
): List<A>
fun loadTypeParameterAnnotations(
proto: ProtoBuf.TypeParameter,
nameResolver: NameResolver
): List<A><|endoftext|>
|
interface A {
fun foo(a1: Int, a2: Double)
}
interface B {
fun foo(b1: Int, b2: Double)
}
interface C : A, B { // Warning here, this is correct, C.foo has no named parameters
}
interface D : C {
override fun foo(d1: Int, d2: Double)
}
|
fun test1(d: D) {
d.foo(d1 = 1, d2 = 1.0)
}
fun test2(c: C) {
c.foo(<!NAME_FOR_AMBIGUOUS_PARAMETER!>b1<!> = 1, <!NAME_FOR_AMBIGUOUS_PARAMETER!>b2<!> = 1.0)<|endoftext|>
|
struct { char b1; int64_t b2; };
};
char second;
struct {
char x;
struct { int64_t b11, b12; } Y2;
int32_t f;
} __attribute__((aligned(16)));
char last;
} __attribute__ ((packed));
#pragma pack()
|
#define INIT(T, x) struct T x = \
{ \
.first = 'a', \
.b1 = 'b', \
.b2 = 42, \
.second = 's', \
.last = 'z', \
.f = 314, \
.Y2 = {11, 12} \
}<|endoftext|>
|
sealed class ExportedDeclaration {
val attributes = mutableListOf<ExportedAttribute>()
}
sealed class ExportedAttribute {
class DeprecatedAttribute(val message: String): ExportedAttribute()
}
data class ExportedModule(
val name: String,
val moduleKind: ModuleKind,
val declarations: List<ExportedDeclaration>
)
class ExportedNamespace(
|
val name: String,
val declarations: List<ExportedDeclaration>,
val isPrivate: Boolean = false
) : ExportedDeclaration()
data class ExportedFunction(
val name: String,
val returnType: ExportedType,
val parameters: List<ExportedParameter>,
val typeParameters: List<ExportedType.TypeParameter> = emptyList(),<|endoftext|>
|
operator fun invoke(x: Short): Unit = print(3) // (1)
companion object {
operator fun invoke(x: Int): Unit = print(3) // (2)
}
fun case() {
<!DEBUG_INFO_CALL("fqName: Case2.invoke; typeCall: operator function")!>invoke(1)<!>
|
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String")!>invoke(1)<!>
}
}
interface I3 {
operator fun invoke(x: Int): String = "print(3)" // (3)
}<|endoftext|>
|
import org.jetbrains.kotlin.analysis.api.descriptors.components.base.Fe10KtAnalysisSessionComponent
import org.jetbrains.kotlin.analysis.api.descriptors.types.base.KtFe10Type
import org.jetbrains.kotlin.analysis.api.lifetime.KtLifetimeToken
|
import org.jetbrains.kotlin.analysis.api.types.KtType
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.builtins.functions.FunctionTypeKind
import org.jetbrains.kotlin.builtins.getFunctionTypeKind<|endoftext|>
|
@kotlin.internal.InlineOnly
public inline operator fun StyleSheetList.get(index: Int): StyleSheet? = asDynamic()[index]
/**
* Exposes the JavaScript [LinkStyle](https://developer.mozilla.org/en/docs/Web/API/LinkStyle) to Kotlin
*/
public external interface LinkStyle {
val sheet: StyleSheet?
|
get() = definedExternally
}
/**
* Exposes the JavaScript [CSSRuleList](https://developer.mozilla.org/en/docs/Web/API/CSSRuleList) to Kotlin
*/
public external abstract class CSSRuleList : ItemArrayLike<CSSRule> {
override fun item(index: Int): CSSRule?
}<|endoftext|>
|
private fun ExceptionAttachmentBuilder.buildAttachments(key: K, context: CONTEXT, value: V) {
withEntry("key", key.toString())
if (context is PsiElement) {
withPsiEntry("context", context)
} else {
withEntry("context", context.toString())
}
|
val unwrapped = (value as? Collection<*>)?.singleOrNull() ?: value
when (unwrapped) {
is FirElement -> withFirEntry("value", unwrapped)
is FirBasedSymbol<*> -> withFirSymbolEntry("value", unwrapped)
else -> withEntry("value", unwrapped.toString())
}
}
}<|endoftext|>
|
if (this === other) return true
if (this === null || other === null) return false
if (size != other.size) return false
for (i in indices) {
if (this[i] != other[i]) return false
}
return true
}
/**
* Checks if the two specified arrays are *structurally* equal to one another.
*
|
* Two arrays are considered structurally equal if they have the same size, and elements at corresponding indices are equal.
*
* The arrays are also considered structurally equal if both are `null`.
*
* @param other the array to compare with this array.
* @return `true` if the two arrays are structurally equal, `false` otherwise.
*<|endoftext|>
|
dependsOn(firPluginJvmAnnotations, firPluginJsAnnotations)
val localFirPluginJvmAnnotations: FileCollection = firPluginJvmAnnotations
val localFirPluginJsAnnotations: FileCollection = firPluginJsAnnotations
doFirst {
systemProperty("firPluginAnnotations.jvm.path", localFirPluginJvmAnnotations.singleFile.canonicalPath)
|
systemProperty("firPluginAnnotations.js.path", localFirPluginJsAnnotations.singleFile.canonicalPath)
}
}
}
private fun Project.optInTo(annotationFqName: String) {
tasks.withType<KotlinCompilationTask<*>>().configureEach {
compilerOptions.optIn.add(annotationFqName)
}<|endoftext|>
|
fun myNotEquals(a: Float?, b: Float?) = a != b
fun myNotEquals1(a: Float?, b: Float) = a != b
fun myNotEquals2(a: Float, b: Float?) = a != b
fun myNotEquals0(a: Float, b: Float) = a != b
fun box(): String {
|
if (myNotEquals(null, null)) return "fail 1"
if (!myNotEquals(null, 0.0F)) return "fail 2"
if (!myNotEquals(0.0F, null)) return "fail 3"
if (myNotEquals(0.0F, 0.0F)) return "fail 4"<|endoftext|>
|
* Note that this constant is experimental.
* In the future it could be deprecated in favour of another constant of a `CodePoint` type.
*/
@ExperimentalNativeApi
public const val MAX_CODE_POINT: Int = 0X10FFFF
/**
* The minimum radix available for conversion to and from strings.
*/
|
@Deprecated("Introduce your own constant with the value of `2`", ReplaceWith("2"))
@DeprecatedSinceKotlin(warningSince = "1.9")
public const val MIN_RADIX: Int = 2
/**
* The maximum radix available for conversion to and from strings.
*/<|endoftext|>
|
result[index] = element
return result
}
/**
* Returns an array containing all elements of the original array and then the given [element].
*/
public actual operator fun BooleanArray.plus(element: Boolean): BooleanArray {
val index = size
val result = copyOfUninitializedElements(index + 1)
result[index] = element
return result
}
/**
|
* Returns an array containing all elements of the original array and then the given [element].
*/
public actual operator fun CharArray.plus(element: Char): CharArray {
val index = size
val result = copyOfUninitializedElements(index + 1)
result[index] = element
return result
}
/**<|endoftext|>
|
import org.jetbrains.kotlin.fir.expressions.builder.buildBlock
import org.jetbrains.kotlin.fir.generateTemporaryVariable
import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol
import org.jetbrains.kotlin.fir.types.FirTypeRef
|
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.name.SpecialNames
data class DestructuringDeclaration(
val isVar: Boolean,
val entries: List<DestructuringEntry>,
val initializer: FirExpression,
val source: KtSourceElement,
val annotations: List<FirAnnotation>,
) {<|endoftext|>
|
}
// TESTCASE NUMBER: 2
inline fun <reified T : Any?> T?.case_2(value_2: Number, value_3: Any?, value_4: String?) {
contract { returns() implies ((this@case_2 is Number || this@case_2 is Int) && value_2 is Int && value_3 != null && value_3 is Number && value_4 != null) }
|
if (!((this is Number || this is Int) && value_2 is Int && value_3 != null && value_3 is Number && value_4 != null)) throw Exception()
}
// FILE: main.kt
import contracts.*
// TESTCASE NUMBER: 1
fun case_1(value_1: Any?) {
value_1.case_1()<|endoftext|>
|
@GCUnsafeCall("Kotlin_NSArrayAsKList_get")
external override fun get(index: Int): Any?
}
internal class NSMutableArrayAsKMutableList : AbstractMutableList<Any?>(), RandomAccess, ObjCObjectWrapper {
override val size: Int get() = getSize()
|
@GCUnsafeCall("Kotlin_NSArrayAsKList_getSize")
private external fun getSize(): Int
@GCUnsafeCall("Kotlin_NSArrayAsKList_get")
external override fun get(index: Int): Any?
@GCUnsafeCall("Kotlin_NSMutableArrayAsKMutableList_add")<|endoftext|>
|
fun <T> materialize(): T = TODO()
val a: () -> Unit = l@{
// Expected type 'Unit' is used here for inference
if (true) return@l materialize()
// Expected type here is Unit, but it also implies coercion,
// so we can end lambda body with statement
if (true) 42
}
val b: () -> Unit = l@{
|
// Error, coercion can't be applied at this position!
if (true) return@l <!RETURN_TYPE_MISMATCH!>"hello"<!>
// However, this is OK, because here coercion is applied
"hello"
}
val c: () -> Unit = {
// Interesting enough, for such expessions we use expected type Unit<|endoftext|>
|
for ((from, until) in listOf(
(0uL to 32uL),
(1uL to 6uL),
(0uL to 0x1_0000_0000.toULong()),
(0x10uL to 0x4_0000_0010.toULong()),
(0uL to ULong.MAX_VALUE)
)) {
|
repeat(1000) {
val x = subject.nextULong(from, until)
if (x !in from until until) {
fail("Value $x must be in range [$from, $until)")
}
}
}
}
@Suppress("EmptyRange")
@Test
fun nextLongInLongRange() {<|endoftext|>
|
fun testR1xE3() {
// with possible local optimizations
if ('3' in '3'..'1' != range1.contains('3')) throw AssertionError()
if ('3' !in '3'..'1' != !range1.contains('3')) throw AssertionError()
|
if (!('3' in '3'..'1') != !range1.contains('3')) throw AssertionError()
if (!('3' !in '3'..'1') != range1.contains('3')) throw AssertionError()
// no local optimizations
if (element3 in '3'..'1' != range1.contains(element3)) throw AssertionError()<|endoftext|>
|
isStaticFramework: Boolean,
needLazyHeaderCheck: Boolean,
) {
Assumptions.assumeTrue(targets.testTarget.family.isAppleFamily)
val doLazyHeaderCheck = needLazyHeaderCheck && testRunSettings.get<PipelineType>() == PipelineType.K1
|
val lazyHeader: File = buildDir.resolve("lazy-$suffix.h").also { it.delete() } // Clean up lazy header after previous runs
// Compile a couple of KLIBs
val library = compileToLibrary(
testSuiteDir.resolve("objcexport/library"),
buildDir,<|endoftext|>
|
var x = <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any")!>foo1 { 1 }<!>
if (b) {
x = <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any")!>foo1 { 2 }<!>
}
x.<!UNRESOLVED_REFERENCE!>bar<!>()
}
|
fun test2(b: Boolean) {
var x = <!DEBUG_INFO_EXPRESSION_TYPE("I1")!>foo2 { 1 }<!>
if (b) {
x = <!DEBUG_INFO_EXPRESSION_TYPE("I1")!>foo2 { 2 }<!>
}
x.<!UNRESOLVED_REFERENCE!>bar<!>()<|endoftext|>
|
}.toByteArray()
private data class GCData(val name: String, val collectionTime: Long, val collectionCount: Long) {
constructor(bean: GarbageCollectorMXBean) : this(bean.name, bean.collectionTime, bean.collectionCount)
}
fun renderCompilerPerformance(): String {
val relevantMeasurements = getMeasurementResults().filter {
|
it is CompilerInitializationMeasurement || it is CodeAnalysisMeasurement || it is CodeGenerationMeasurement || it is PerformanceCounterMeasurement
}
return "Compiler perf stats:\n" + relevantMeasurements.joinToString(separator = "\n") { " ${it.render()}" }
}
}<|endoftext|>
|
}
// TESTCASE NUMBER: 6
fun case_6(z: Any?) {
val y = z.let {
when (it) {
is Class? -> it!!
is Class -> return@let it
is Float -> Class()
else -> return@let Class()
}
}
|
<!DEBUG_INFO_EXPRESSION_TYPE("Class")!>y<!>
<!DEBUG_INFO_EXPRESSION_TYPE("Class")!>y<!>.fun_1()
}
// TESTCASE NUMBER: 7
fun case_7(z: Any?) {
val y = z.let {
it as Class
}<|endoftext|>
|
import org.jetbrains.kotlin.resolve.jvm.JvmPrimitiveType
import javax.lang.model.type.TypeKind
abstract class TreeBasedType<out T : JCTree>(
val tree: T,
val compilationUnit: CompilationUnitTree,
val javac: JavacWrapper,
private val allAnnotations: Collection<JavaAnnotation>,
|
protected val containingElement: JavaElement
) : JavaType, JavaAnnotationOwner {
override val annotations: Collection<JavaAnnotation>
get() = allAnnotations.filterTypeAnnotations()
companion object {
fun create(
tree: JCTree, compilationUnit: CompilationUnitTree,
javac: JavacWrapper, annotations: Collection<JavaAnnotation>,<|endoftext|>
|
// It would be better to call them like JavaSomeTypeImpl, but these names are already occupied by the PSI based types
internal class PlainJavaArrayType(override val componentType: JavaType) : JavaPlainType(), JavaArrayType
internal class PlainJavaWildcardType(override val bound: JavaType?, override val isExtends: Boolean) : JavaPlainType(), JavaWildcardType
|
internal class PlainJavaPrimitiveType(override val type: PrimitiveType?) : JavaPlainType(), JavaPrimitiveType
internal class PlainJavaClassifierType(
// calculation of classifier and canonicalText
classifierComputation: () -> ClassifierResolutionContext.Result,
override val typeArguments: List<JavaType>
) : JavaPlainType(), JavaClassifierType {<|endoftext|>
|
// library.kt:45 baz: param:int=6:int, b:int=2:int, inlineCallParam1\1:int=1:int, inlineCallParam2\1:int=2:int, $i$f$inlineCall\1\10:int=0:int, e\1:int=5:int, baz1Param\2:int=1:int,
|
$i$f$baz1\2\50:int=0:int, baz1Var\2:int=3:int, baz1BlockParam\4:int=1:int, $i$a$-baz1-LibraryKt$inlineCall$1\4\53\1:int=0:int, baz1LambdaVar\4:int=1:int,<|endoftext|>
|
private fun TranslationContext.addFunctionDeclaration(name: JsName, function: JsFunction, source: Any?) {
addFunctionButNotExport(name, if (isPublicInlineFunction) {
InlineMetadata.wrapFunction(this, FunctionWithWrapper(function, null), source)
}
else {
function
})
}
fun JsFunction.withCapturedParameters(
|
context: TranslationContext,
functionName: JsName,
invokingContext: TranslationContext,
source: KtDeclaration
): JsExpression {
invokingContext.addFunctionDeclaration(functionName, this, source)
val ref = JsAstUtils.pureFqn(functionName, null)<|endoftext|>
|
package mobi.porquenao.poc.kotlin.ui
import android.os.Bundle
import android.support.v7.widget.LinearLayoutManager
import android.support.v7.widget.RecyclerView
import android.view.Menu
import android.view.MenuItem
import mobi.porquenao.poc.kotlin.R
class MainActivity : BaseActivity() {
|
lateinit var listAdapter: MainAdapter
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
with (findViewById(R.id.list) as RecyclerView) {
setHasFixedSize(true)
layoutManager = LinearLayoutManager(this@MainActivity)<|endoftext|>
|
km.receiverParameterType = property.receiverType?.map()
km.returnType = property.type.map()
val kind = property.kind
if (kind is PropertyStub.Kind.Var) {
kind.setter.annotations.mapTo(km.setterAnnotations) { it.map() }
// TODO: Maybe it's better to explicitly add setter parameter in stub.
|
km.setterParameter = FunctionParameterStub("value", property.type).map()
}
km.getterAnnotations += when (kind) {
is PropertyStub.Kind.Val -> kind.getter.annotations.map { it.map() }
is PropertyStub.Kind.Var -> kind.getter.annotations.map { it.map() }<|endoftext|>
|
import org.jetbrains.kotlin.script.loadScriptingPlugin
import org.jetbrains.kotlin.scripting.compiler.plugin.configureScriptDefinitions
import org.jetbrains.kotlin.test.ConfigurationKind
import org.jetbrains.kotlin.test.TargetBackend
import org.jetbrains.kotlin.test.TestJdkKind
|
import org.jetbrains.kotlin.utils.PathUtil
import org.jetbrains.kotlin.utils.PathUtil.KOTLIN_SCRIPTING_COMMON_JAR
import org.jetbrains.kotlin.utils.PathUtil.KOTLIN_SCRIPTING_COMPILER_IMPL_JAR<|endoftext|>
|
*/
class FirJvmMangleComputer(
builder: StringBuilder,
mode: MangleMode,
) : FirMangleComputer(builder, mode) {
override fun FirFunction.platformSpecificSuffix(): String? =
if (this is FirSimpleFunction && name.asString() == "main")
|
this.moduleData.session.firProvider.getFirCallableContainerFile(symbol)?.name
else null
override fun addReturnType(): Boolean = true
override fun copy(newMode: MangleMode): FirJvmMangleComputer =
FirJvmMangleComputer(builder, newMode)
}<|endoftext|>
|
classWithUnstableParameterNames.constructors.forEach { assertTrue(Flag.Constructor.HAS_NON_STABLE_PARAMETER_NAMES(_flagAccess(it))) }
classWithUnstableParameterNames.functions.forEach { assertTrue(Flag.Function.HAS_NON_STABLE_PARAMETER_NAMES(_flagAccess(it))) }
|
classWithUnstableParameterNames.constructors.forEach { assertTrue(it.hasNonStableParameterNames) }
classWithUnstableParameterNames.functions.forEach { assertTrue(it.hasNonStableParameterNames) }
}
@Test
@OptIn(UnstableMetadataApi::class)
fun metadataVersionEarlierThan1_4() {<|endoftext|>
|
import kotlin.io.encoding.Base64.Default.mimeLineSeparatorSymbols
import kotlin.io.encoding.Base64.Default.padSymbol
import kotlin.io.encoding.Base64.Default.symbolsPerGroup
/**
* Returns an input stream that decodes symbols from this input stream using the specified [base64] encoding.
*
|
* Reading from the returned input stream leads to reading some symbols from the underlying input stream.
* The symbols are decoded using the specified [base64] encoding and the resulting bytes are returned.
* Symbols are decoded in 4-symbol blocks.
*
* The symbols for decoding are not required to be padded.
* However, if there is a padding character present, the correct amount of padding character(s) must be present.<|endoftext|>
|
override fun removeAt(index: Int): E {
checkIsMutable()
checkForComodification()
AbstractList.checkElementIndex(index, length)
return removeAtInternal(offset + index)
}
override fun remove(element: E): Boolean {
checkIsMutable()
checkForComodification()
val i = indexOf(element)
|
if (i >= 0) removeAt(i)
return i >= 0
}
override fun removeAll(elements: Collection<E>): Boolean {
checkIsMutable()
checkForComodification()
return retainOrRemoveAllInternal(offset, length, elements, false) > 0
}
override fun retainAll(elements: Collection<E>): Boolean {<|endoftext|>
|
package test
typealias OI = Outer.Inner
class Outer {
open inner class Inner
inner class Test : OI()
}
typealias GI<T> = Generic<T>.Inner
typealias GIInt = Generic<Int>.Inner
typealias GIStar = Generic<*>.Inner
typealias GG<T1, T2> = Generic<T1>.Generic<T2>
|
typealias GIntG<T2> = Generic<Int>.Generic<T2>
typealias GGInt<T1> = Generic<T1>.Generic<Int>
class Generic<T1> {
open inner class Inner
open inner class Generic<T2>
inner class Test1 : GI<T1>()<|endoftext|>
|
fun convert(v: String, from: UnsignedType, to: UnsignedType) = if (from == to) v else "$v.to${to.capitalized}()"
fun convert(v: String, from: PrimitiveType, to: PrimitiveType) = if (from == to) v else "$v.to${to.capitalized}()"
|
fun PrintWriter.printDoc(documentation: String, indent: String) {
val docLines = documentation.lines()
if (docLines.size == 1) {
this.println("$indent/** $documentation */")
} else {
this.println("$indent/**")
docLines.forEach { this.println("$indent * $it".trimEnd()) }<|endoftext|>
|
assertFalse(classpathHasKNStdlib(getClasspath(":compileJvmAndJsMainKotlinMetadata")))
}
}
}
private fun classpathHasKNStdlib(classpath: Iterable<String>) = classpath.any { "klib/common/stdlib" in it.replace("\\", "/") }
|
private fun BuildResult.getClasspath(taskPath: String): Iterable<String> {
val argsPrefix = " $taskPath Kotlin compiler args:"
return output.lines().single { argsPrefix in it }
.substringAfter("-classpath ").substringBefore(" -").split(File.pathSeparator)
}<|endoftext|>
|
* This, however, shall not be shown to users, as the String is hard to read
* The identityString is not stable across Kotlin versions, hence not intended to be parsed.
*/
val identityString: String
get() = buildString {
append("$group:$module")
if (sourceSetName != null) append(":$sourceSetName")
|
if (version != null) append(":$version")
if (capabilities.isNotEmpty()) {
append(capabilities.joinToString(", ", "(", ")"))
}
if (attributes.isNotEmpty()) {
append("+attributes(${attributes.hashCode()})")
}
}
/**<|endoftext|>
|
Checks(ITERATOR, MemberOrExtension, NoValueParameters),
Checks(NEXT, MemberOrExtension, NoValueParameters),
Checks(HAS_NEXT, MemberOrExtension, NoValueParameters, ReturnsBoolean),
Checks(RANGE_TO, MemberOrExtension, SingleValueParameter, NoDefaultAndVarargsCheck),
|
Checks(RANGE_UNTIL, MemberOrExtension, SingleValueParameter, NoDefaultAndVarargsCheck),
Checks(EQUALS, Member) {
fun DeclarationDescriptor.isAny() = this is ClassDescriptor && KotlinBuiltIns.isAny(this)<|endoftext|>
|
ULONGARRAY(ClassId.fromString("kotlin/ULongArray"));
val typeName = classId.shortClassName
}
object UnsignedTypes {
private val unsignedTypeNames = enumValues<UnsignedType>().map { it.typeName }.toSet()
private val unsignedArrayTypeNames = enumValues<UnsignedArrayType>().map { it.typeName }.toSet()
|
private val arrayClassIdToUnsignedClassId = hashMapOf<ClassId, ClassId>()
private val unsignedClassIdToArrayClassId = hashMapOf<ClassId, ClassId>()
val unsignedArrayTypeToArrayCall = hashMapOf(
UnsignedArrayType.UBYTEARRAY to Name.identifier("ubyteArrayOf"),<|endoftext|>
|
// TARGET_BACKEND: JVM
// FILE: Unsound.java
import test.Wrap;
public class Unsound {
public static <T> Wrap<T> get() {
return new Wrap<T>(null);
}
}
// FILE: 1.kt
package test
class Wrap<T>(val x: T)
|
fun box(): String = if ((Unsound.get<String>() as Wrap<String>).x == null) "OK" else "Fail"<|endoftext|>
|
override fun process(data: TowerData): List<Collection<C>> {
val variablesResult = variableProcessor.process(data)
val objectResult = objectProcessor.process(data)
if (objectResult.isEmpty()) return variablesResult
if (objectResult.none { level ->
level.any {
it.isEnumEntryCandidate()
}
}
|
) return variablesResult + objectResult
val result = mutableListOf<List<C>>()
result.addAll(variablesResult.map { it.toMutableList() })
for ((index, objectLevel) in objectResult.withIndex()) {
val enumEntryLevel = objectLevel.filter { it.isEnumEntryCandidate() }
if (enumEntryLevel.isEmpty()) continue<|endoftext|>
|
while (parameterClassDeclaration.isInner) {
val outerClass = parameterClassDeclaration.parentAsClass
val outerClassThis = outerClass.thisReceiver ?: error("${outerClass.name} has a null `thisReceiver` property")
val parameterToArgument = ParameterToArgument(
parameter = outerClassThis,
argumentExpression = IrGetFieldImpl(
|
UNDEFINED_OFFSET,
UNDEFINED_OFFSET,
innerClassesSupport.getOuterThisField(parameterClassDeclaration).symbol,
outerClassThis.type,
IrGetValueImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, currentThisSymbol)
)
)
allParametersReplacements.add(parameterToArgument)<|endoftext|>
|
* - If [newSize] is less than the size of the original array, the copy array is truncated to the [newSize].
* - If [newSize] is greater than the size of the original array, the extra elements in the copy array are filled with null char (`\u0000`) values.
*
* @sample samples.collections.Arrays.CopyOfOperations.resizedPrimitiveCopyOf
*/
|
public actual fun CharArray.copyOf(newSize: Int): CharArray {
return this.copyOfUninitializedElements(newSize)
}
/**
* Returns new array which is a copy of the original array, resized to the given [newSize].
* The copy is either truncated or padded at the end with `null` values if necessary.
*<|endoftext|>
|
open var borderBottomColor: String
open var borderBottomLeftRadius: String
open var borderBottomRightRadius: String
open var borderBottomStyle: String
open var borderBottomWidth: String
open var borderCollapse: String
open var borderColor: String
open var borderImage: String
open var borderImageOutset: String
open var borderImageRepeat: String
|
open var borderImageSlice: String
open var borderImageSource: String
open var borderImageWidth: String
open var borderLeft: String
open var borderLeftColor: String
open var borderLeftStyle: String
open var borderLeftWidth: String
open var borderRadius: String
open var borderRight: String
open var borderRightColor: String
open var borderRightStyle: String<|endoftext|>
|
// GETSTATIC My.my
return my
}
// PUTSTATIC My.my into clinit
// PUTSTATIC My.my into 'access$setMy$cp'
// GETSTATIC My.my into 'access$getMy$cp'
}
// 2 PUTSTATIC My.my
|
// 0 INVOKESTATIC My\$Companion.access\$getMy\$p
// 1 INVOKESTATIC My.access\$setMy\$cp
// 1 INVOKESPECIAL My\$Companion.setMy
// JVM_TEMPLATES
// 2 GETSTATIC My.my
// 1 INVOKESTATIC My\$Companion.access\$setMy\$p<|endoftext|>
|
inline class IC<T: I>(val i: T): I by i
fun box(): String {
val i = object : I {}
val ic1 = IC(i)
var res = ic1.o()
if (res != "OK") return "FAIL 1: $res"
res = ic1.o("KK")
|
if (res != "OKK") return "FAIL 2: $res"
val ic2: I = IC(i)
res = ic2.o()
if (res != "OK") return "FAIL 3: $res"
res = ic2.o("KK")
if (res != "OKK") return "FAIL 4: $res"
return "OK"
}<|endoftext|>
|
package org.jetbrains.kotlin.buildtools.internal
import org.jetbrains.kotlin.buildtools.api.SourcesChanges
import org.jetbrains.kotlin.buildtools.api.jvm.ClasspathSnapshotBasedIncrementalCompilationApproachParameters
|
import org.jetbrains.kotlin.buildtools.api.jvm.ClasspathSnapshotBasedIncrementalJvmCompilationConfiguration
import org.jetbrains.kotlin.incremental.ChangedFiles
import org.jetbrains.kotlin.incremental.ClasspathChanges
import org.jetbrains.kotlin.incremental.ClasspathSnapshotFiles
internal val SourcesChanges.asChangedFiles<|endoftext|>
|
import org.jetbrains.kotlin.test.directives.JvmEnvironmentConfigurationDirectives.ENABLE_DEBUG_MODE
import org.jetbrains.kotlin.test.directives.JvmEnvironmentConfigurationDirectives.INCLUDE_JAVA_AS_BINARY
import org.jetbrains.kotlin.test.directives.JvmEnvironmentConfigurationDirectives.JVM_TARGET
|
import org.jetbrains.kotlin.test.directives.JvmEnvironmentConfigurationDirectives.LAMBDAS
import org.jetbrains.kotlin.test.directives.JvmEnvironmentConfigurationDirectives.SAM_CONVERSIONS
import org.jetbrains.kotlin.test.directives.JvmEnvironmentConfigurationDirectives.SERIALIZE_IR<|endoftext|>
|
import org.jetbrains.kotlin.fir.FirModuleData
import org.jetbrains.kotlin.fir.builder.FirBuilderDsl
import org.jetbrains.kotlin.fir.declarations.FirDeclaration
import org.jetbrains.kotlin.fir.declarations.FirDeclarationAttributes
|
import org.jetbrains.kotlin.fir.declarations.FirDeclarationOrigin
import org.jetbrains.kotlin.fir.declarations.FirResolvePhase
import org.jetbrains.kotlin.fir.expressions.FirAnnotation
@FirBuilderDsl
interface FirDeclarationBuilder {
abstract var source: KtSourceElement?<|endoftext|>
|
}
return isLowerCaseImpl()
}
/**
* Returns `true` if this character is a title case letter.
*
* A character is considered to be a title case letter if its [category] is [CharCategory.TITLECASE_LETTER].
*
* @sample samples.text.Chars.isTitleCase
*/
@SinceKotlin("1.5")
|
public actual fun Char.isTitleCase(): Boolean {
if (this < '\u0080') {
return false
}
return getCategoryValue() == CharCategory.TITLECASE_LETTER.value
}
/**
* Returns `true` if this character is an ISO control character.
*
* A character is considered to be an ISO control character if its [category] is [CharCategory.CONTROL],<|endoftext|>
|
override fun getParent(): BuildTime? = parent
override fun children(): List<BuildTime>? {
return children[this]
}
override fun getAllMetrics(): List<BuildTime> {
return entries
}
override fun getName(): String = this.name
companion object {
const val serialVersionUID = 2L
|
val children by lazy {
entries.filter { it.parent != null }.groupBy { it.parent }
}
}
}<|endoftext|>
|
fun ExceptionAttachmentBuilder.withFirSymbolIdEntry(name: String, symbol: FirBasedSymbol<*>?) {
when (symbol) {
is FirClassifierSymbol -> withFirLookupTagEntry(name, symbol.toLookupTag())
is FirCallableSymbol -> withEntry(name, symbol.callableId.toString())
|
else -> withEntry(name, symbol.toString())
}
}
fun ExceptionAttachmentBuilder.withFirLookupTagEntry(name: String, lookupTag: ConeClassifierLookupTag?) {
withEntry(name, lookupTag) { tag ->
when (tag) {
is ConeClassLikeLookupTag -> tag.classId.asString()<|endoftext|>
|
public inline fun UIntArray.reduceIndexed(operation: (index: Int, acc: UInt, UInt) -> UInt): UInt {
if (isEmpty())
throw UnsupportedOperationException("Empty array can't be reduced.")
var accumulator = this[0]
for (index in 1..lastIndex) {
accumulator = operation(index, 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 with its index in the original array.
*
* Throws an exception if this array is empty. If the array can be empty in an expected way,
* please use [reduceIndexedOrNull] instead. It returns `null` when its receiver is empty.<|endoftext|>
|
var c: Continuation<Any>? = null
suspend fun <T> suspendMe(): T = suspendCoroutine {
@Suppress("UNCHECKED_CAST")
c = it as Continuation<Any>
}
class Test() : IBar {
override suspend fun bar(): IC = suspendMe()
suspend fun test1(): String {
val b: IBar = this
|
return (b.bar() as IC).s
}
suspend fun test2(): String = bar().s
}
fun box(): String {
var result = "FAIL 1"
builder {
result = Test().test1()
}
c?.resume(IC("OK"))
if (result != "OK") return "FAIL 1 $result"<|endoftext|>
|
if (arrayBufferIsView(destination) && arrayBufferIsView(source)) {
val subrange = source.asDynamic().subarray(startIndex, endIndex)
destination.asDynamic().set(subrange, destinationOffset)
} else {
if (source !== destination || destinationOffset <= startIndex) {
for (index in 0 until rangeSize) {
|
destination[destinationOffset + index] = source[startIndex + index]
}
} else {
for (index in rangeSize - 1 downTo 0) {
destination[destinationOffset + index] = source[startIndex + index]
}
}
}
}
// no singleton map implementation in js, return map as is<|endoftext|>
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.