Rob Elliot
01/30/2023, 10:20 AMString
into a URI
.
For untrusted input ideally I want a function that forces the caller to handle the bad case - fun String.toUri(): Either<URISyntaxException, URI>
.
But that's a colossal pain when constructing from a string literal; I don't want "<http://www.example.com>".toUri()
to return an Either
, I want a URI
!
Of course you can provide two methods, one for untrusted input, one for trusted, but that immediately opens up the possibility of human error choosing the wrong one.
So I was wondering if a compiler plugin could actually infer that the function's arguments are known at compile time and actually call the function to prove that it returns a Right<URI>
, and in that case allow val uri: URI = "<http://www.example.com>".toUri()
to compile, and throw a compile error on val uri: URI = "not a uri".toUri()
.PHondogo
01/31/2023, 8:16 PMoverride fun visitClassNew(declaration: IrClass): IrStatement {
declaration.isSubclassOf(pluginContext.referenceClass(FqName("a.b.c.InterfaceThatDeclarationHave"))!!.owner) // in 1.8.0 version start to return false
...
}
If declaration change to (pluginContext.referenceClass(declaration.fqNameWhenAvailable!!)!!.owner) then isSubclassOf return true.
(pluginContext.referenceClass(declaration.fqNameWhenAvailable!!)!!.owner).isSubclassOf(pluginContext.referenceClass(FqName("a.b.c.InterfaceThatDeclarationHave"))!!.owner) // as an ugly workaround
Is it a bug? If no, how should I work with class references now?PHondogo
01/31/2023, 9:53 PMCharlie Tapping
02/01/2023, 3:08 PMExample.foo(x: Any)
Then for every given different type of x, I would need to add an implementation for a interface to that type.
The interface basically encodes the type to and from a hashmap by iterating all of the properties in the class recursively, turning the object into a HashMap<String, String>
For example if you called:
Example.foo(user: User)
and
data class User(
private val name: String,
private val age: Int
)
I would generate
data class User(
private val name: String,
private val age: Int
) : Adapter {
fun fromHashmap() {
...
}
fun toHashmap() {
...
}
}
Is this possible? Any help would be greatly appreciated!ursus
02/06/2023, 11:58 PMjvmTarget
should I use? Is there anything to gain when bumping ˙1.8` to 11
, when java language features are irrelevant to me?
Performance?jw
02/07/2023, 4:05 AM<http://IrConstImpl.int|IrConstImpl.int>
from a Function0<Int>
lambda/local function that i've created?mcpiroman
02/07/2023, 1:19 PMTracey Yoshima
02/07/2023, 11:49 PMQuantum64
02/09/2023, 7:57 PMTravis Griggs
02/13/2023, 9:41 PM@kotlin.ExperimentalUnsignedTypes
globally to a whole project, so I don't have to annotate 500+ sites? I had this with gradle compiler options once upon a time, but I think that's evolved and the names may have changed since then (sorry if this belongs in another channel, please direct if so?)ralf
02/14/2023, 12:48 AM-Dorg.gradle.debug=true -Dkotlin.compiler.execution.strategy=in-process
But with 1.8.20 you can’t run the compiler in-process anymore.
In other tickets I found
-Dkotlin.daemon.jvm.options="-agentlib:jdwp=transport=dt_socket\,server=y\,suspend=n\,address=*:5005"
But no luck there, the connection is refused. Any advice?Olaf Gottschalk
02/14/2023, 4:44 PMsealed class Blah<T> {
abstract fun doSomething(): T
abstract fun doAnotherThing(a: T)
}
object A : Blah<Int>() {
override fun doSomething(): Int = 42
override fun doAnotherThing(a: Int) {}
}
object B : Blah<String>() {
override fun doSomething(): String = "42"
override fun doAnotherThing(a: String) {}
}
// inferred type is Blah<out Any>
fun gimmeBlah() = if (Random.nextBoolean()) A else B
// error is Type mismatch. Required: Blah<Any?> Found: A
fun doesNotCompile(): Blah<Any?> = if (Random.nextBoolean()) A else B
I do NOT understand, why the inferred type introduces the "out" variance.... it does not make sense to me (and does not work in my context....)eygraber
02/14/2023, 6:25 PMprotected
and internal
visibility? Pretty sure the answer is no, but just checking. Are there any proposals for adding something like that?
Use case is where I want to invoke an abstract function from a class in the same module, and have subclasses implement them.Charlie Tapping
02/17/2023, 2:43 PMinterface SynkAdapter<T : Any> : IDResolver<T>, MapEncoder<T>
An impl like this does not count as the aggregated type (SynkAdapter)
class FooSynkAdapter(
private val fooResolver: IDResolver<Foo> = FooResolver(),
private val fooMapEncoder: MapEncoder<Foo> = FooMapEncoder()
) : IDResolver<Foo> by fooResolver, MapEncoder<Foo> by fooMapEncoder
You have to do this??
class FooSynkAdapter(
private val fooResolver: IDResolver<Foo> = FooResolver(),
private val fooMapEncoder: MapEncoder<Foo> = FooMapEncoder()
) : SynkAdapter<Foo>, IDResolver<Foo> by fooResolver, MapEncoder<Foo> by fooMapEncoder
Surely if an interface is just a union of two other interfaces then implementing those interfaces should make it compatible? I’m sure there must be a good reason for having to be explicit?juliocbcotta
02/21/2023, 2:45 PM...
e: /Users/julio.buenocotta/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.8.10/6d5560a229477df9406943d5feda5618e98eb64c/kotlin-stdlib-1.8.10.jar!/META-INF/kotlin-stdlib-jdk8.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.8.0, expected version is 1.6.0.
e: /Users/julio.buenocotta/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.8.10/6d5560a229
Any pointers? I googled it and couldn't find anything that would fix it for me. Thankslouiscad
02/21/2023, 4:41 PMDanil
02/23/2023, 9:36 AMnapperley
02/24/2023, 10:26 PMAkshit Sinha
02/25/2023, 5:30 PMgradlew dist
but getting this error. Any idea what might be the cause? Is it the JDK version or something?vladimirsitnikov
02/27/2023, 9:24 AMclass Named<Value>(
val value: Value,
@CallerArgumentExpression("value") val name: String = ""
) {
override fun toString(): String = "Named(value=$value, name='$name')"
}
Named(2+2) // the plugin would transform the call to Named(2+2, "2+2")
It might be helpful for tests, preconditions, asserts, etc, so you can have better outputs with almost no overhead.napperley
02/27/2023, 11:08 PM./gradlew :kotlin-native:dist
Many of these references already exist in the Kotlin fork, and should be picked up during the compilation process. Below is one of the error messages:
kotlin/kotlin-native/shared/src/main/kotlin/org/jetbrains/kotlin/konan/target/ClangArgs.kt:201:24 Unresolved reference: RP2040
The reference referred to in the error message above exists in this file: https://github.com/napperley/kotlin/blob/rp2040/native/utils/src/org/jetbrains/kotlin/konan/target/KonanTarget.kt#L35napperley
03/02/2023, 1:58 AMAmejonah 1200
03/02/2023, 4:56 PMnapperley
03/03/2023, 12:20 AMFamily.BARE_METAL
. Nothing can be done to fix the issue since it isn't known how references are resolved/handled with the :kotlin-native-shared:compileKotlin task, even though it is processing some of the same source files as the :compile-kotlin task.Sebastian Schuberth
03/03/2023, 2:59 PMNivaldo H Bondança
03/03/2023, 3:45 PMThiago
03/03/2023, 6:44 PMkotlinc
create ABI Snapshot for my files?napperley
03/04/2023, 4:52 AMsdeleuze
03/04/2023, 1:11 PMjohnaqel
03/06/2023, 2:14 AMjohnaqel
03/06/2023, 2:14 AMephemient
03/06/2023, 3:15 AMjohnaqel
03/06/2023, 4:21 AM