Ben Woodworth
09/30/2020, 7:00 AMBen Woodworth
10/01/2020, 4:59 AMinterface NumberExtensions<T> {
fun T.squared(): T
}
@Given
object IntExtensions : NumberExtensions<Int> {
override fun Int.squared(): Int = this * this
}
class MyClass(
/*with*/ val intExtensions: NumberExtensions<Int> = given, // Something like KEEP-87's 'with'
) /*: NumberExtensions<Int> by intExtensions*/ { // Without needing to delegate like this
fun printTwoSquared(): Unit =
println(2.squared()) // Unresolved reference: squared
}
Petr Makagon
10/01/2020, 8:43 PMimport org.jetbrains.kotlin.gradle.tasks.KotlinCompile
buildscript {
repositories {
maven { url = uri("<https://oss.jfrog.org/artifactory/oss-snapshot-local/>") }
}
dependencies {
classpath("io.arrow-kt:gradle-plugin:1.4.10-SNAPSHOT")
}
}
plugins {
kotlin("jvm") version "1.4.10"
}
apply(plugin = "io.arrow-kt.arrow")
dependencies {
compileOnly( "io.arrow-kt:arrow-meta-prelude:1.4.10-SNAPSHOT")
testImplementation(kotlin("test-junit"))
}
tasks.withType<KotlinCompile>() {
kotlinOptions.jvmTarget = "1.8"
kotlinOptions.freeCompilerArgs = listOf("-Xallow-jvm-ir-dependencies")
}
repositories {
mavenCentral()
maven("<https://oss.jfrog.org/artifactory/oss-snapshot-local/>")
}
Ben Woodworth
10/04/2020, 7:12 PM@Given
. The code compiles fine without the arrow meta gradle plugin (with runtime exceptions because of the given
default parameters), but with the plugin, I'm getting a compiler error:
java.lang.IllegalArgumentException: Unbound type parameters are forbidden: [Unbound private symbol org.jetbrains.kotlin.ir.symbols.impl.IrTypeParameterSymbolImpl@9d89209]
Project: Repo (3.2-arrow-meta branch, build with ./gradlew build
)
Stack trace: Gradle build scan
Is there a good way for me to go about debugging this? And if this is the same issue, then it might just be an issue in Kotlin that'll be fixed in 1.4.20.Leandro Ocampo
10/07/2020, 2:18 PMval Meta.irLogTest: CliPlugin
get() =
"IR log CLI" {
meta(
enableIr(),
irBody { this.irLogBody(it) },
irDump()
)
}
fun IrUtils.irLogBody(irBody: IrBody): IrBody? {...}
So my questions are:
1- are those extension phases enough to transform the code? Assuming irLogBody is applying some transformation. In this case by using
irBody.transformChildrenVoid
2- is it okay to test this changes with quoteOutputMatches? As far I can see it should, but maybe I am missing something.
I was able to achieve this result with Arrow meta in the parsing phase.marios proto
10/08/2020, 2:54 PMdalexander
10/09/2020, 2:34 PMDataClass.from(internalRepresentation)
without requiring developers to hand write the from
adapter. I would do this using annotation processing but there's data missing in the kapt Java stubs (default values). I want to eventually add some validation as well, but generating adapters is the first step.
1) How safe would Arrow Meta would be for doing this for production? ie. How likely are there to be breaking API changes (especially non-trivial ones). I know there's some compiler revision going on right now so there's potentially a lot of uncertainty.
2) Is it reasonable to want to use Arrow Meta/a compiler plugin to do this?
jimn
10/09/2020, 7:14 PMmarios proto
10/10/2020, 7:02 PMTransform.newSources
function with a simple example to generate some code, within Android Studio
the code is taken from arrow-meta documentation, as
val Meta.transformNewSource: CliPlugin
get() = "Transform New Source" {
meta(
classDeclaration(this, { name == "TestClass" }) {
Transform.newSources(
"""
package com.example.arrowexplorer
//metadebug
class ${name}_Generated {
fun sayHi() = println("Hi!")
}
""".file("${name}_Generated")
)
}
)
}
The problem is I cannot find the generated class file or reference it later.
The file actually exists here on this path
/Users/userA/Library/Application Support/kotlin/daemon/build/generated/source/kapt/main/TestClass_Generated.kt
Also tried to use the
file("${name}_Generated", filePath ="/path")
without success.
Any help how can I include the generated file in my project?dalexander
10/17/2020, 10:50 AMdalexander
10/21/2020, 6:31 PMkotlin/daemon
path issue, is this the right syntax? I can't find any references to doing this in the context of arrow meta. I'm getting a build error (the path matches what's found in META-INF/services/org.jetbrains.kotlin.compiler.plugin.ComponentRegistrar
):
e: Invalid argument: -P plugin:com.abcd.MetaPlugin:buildPath=qwerasdf
Is there also something I need to do in the quote syntax to make this work? Also does anyone know where this will show up, just in the compilerContext.configuration
object?
Just to clarify the syntax I'm using is -P plugin:<path-to-plugin>:param=value
heyitsmohit
10/22/2020, 9:43 PMAlex
10/26/2020, 9:07 PMdalexander
10/29/2020, 2:39 PMgenerate()
function is never called by the compiler (sample code in comment).dalexander
11/04/2020, 8:53 PMTransformation.newSources
from within that function, or how to create a new KtFile successfully (the KtFile I've created and added to the files list have led to a NPE with the message 'VirtualFile is null for KtFile'). Any insight into how to create the provider in a second phase of analysis would be helpful, or a way of incrementally building a file during analysis that would only be written out when analysis was completed.radekm
11/25/2020, 10:01 AMBar
data class. My program builds and runs successfully but IntelliJ thinks it is wrong:Karin-Aleksandra Monoid
11/25/2020, 1:26 PMdalexander
12/09/2020, 2:52 PMAhmed Mourad
12/12/2020, 1:20 AMgenerateAllViolations
returns some code (String) that needs to be generated and that is referenced and used by other parts of the user's codebase.
internal fun Meta.violationsGenerator(): AnalysisHandler = analysis(
doAnalysis = Noop.nullable7<AnalysisResult>(),
analysisCompleted = { _, _, bindingTrace, _ ->
// this returns the code to generate
val (location, code) = generateAllViolations(bindingTrace)
null
}
)
Jolan Rensen [JetBrains]
12/16/2020, 4:37 PMproperty(ctx, { ... }) { prop: KtProperty ->
// now where is this property used?
Transform.replace(
replacing = prop,
newDeclaration = ...
)
}
Krzysiek Zgondek
12/17/2020, 2:47 PMAhmed Mourad
12/18/2020, 10:36 AMKotlinType
(type parameter) is pointing to, in the analysis phase?Ahmed Mourad
12/24/2020, 2:37 PMKotlinType#getJetTypeFqName
, but I just noticed that it doesn't print the type arguments of the type arguments of this KotlinType
.
For example: If we have a type projection A<B<C>>
, and we have A
as a KotlinType
, executing getJetTypeFqName
on A
returns A<B>
and the arguments of B
are simply ignored or erased. How do we get around this?Ahmed Mourad
12/24/2020, 2:42 PMT
, it is replaced with kotlin.Any
, if it's of type T : List<*>
, it's of type List<kotlin.Any>
.
I know that type-erasure is a thing, but what if I want to get the generic type (T
) where the type is generic, and the regular fq name when it is not? Is there a way to check if a type is a generic one?Youssef Shoaib [MOD]
01/10/2021, 2:29 PMjvmMain
sourceset in a very basic test multiplatform project and nothing is being replaced at all. I tried both @Given
and @Coercion
but to no avail. This is with the 1.4.10 snapshot. Oddly enough, I do recall it working on the jvmMain
sourceset before with the 1.3.61 snapshot but I'm not sure. So yeah, is it maybe another issue, or does the plugin just not go through these sourcesets yet? And if so, is there a way to edit its configuration options to add the jvmMain
directory manually as a user? Kinda like how it already goes through main
and test
, or should I just admit defeat and use a normal kotlin jvm project?dalexander
01/14/2021, 2:19 PMNikita Klimenko [JB]
01/27/2021, 11:45 AMMax Härtwig
02/11/2021, 10:57 AMprintln
doesn't seem to show up...dalexander
02/11/2021, 3:27 PMBig Chungus
02/11/2021, 3:56 PMBig Chungus
02/11/2021, 3:56 PMraulraja
02/11/2021, 5:00 PM