-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update Gradle Plugin to 7.4.2 + Fix Overflowing Poetry #257
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,13 +23,10 @@ import com.squareup.kotlinpoet.AnnotationSpec | |
import com.squareup.kotlinpoet.FunSpec | ||
import com.squareup.kotlinpoet.KModifier | ||
import com.squareup.kotlinpoet.ParameterSpec | ||
import com.squareup.kotlinpoet.javapoet.KotlinPoetJavaPoetPreview | ||
import com.squareup.kotlinpoet.javapoet.toKTypeName | ||
import com.uber.xprocessing.ext.modifiers | ||
import javax.lang.model.element.Modifier | ||
import motif.compiler.KotlinTypeWorkaround.javaToKotlinType | ||
|
||
@OptIn(KotlinPoetJavaPoetPreview::class) | ||
object XFunSpec { | ||
/** Copied from [FunSpec.overriding] and modified to leverage [javaToKotlinType]& XProcessing. */ | ||
fun overriding( | ||
|
@@ -50,23 +47,13 @@ object XFunSpec { | |
env.requireType(method.returnType.typeName) | ||
} | ||
|
||
val builder = overriding(methodElement) | ||
builder.returns(javaToKotlinType(returnType)) | ||
|
||
var i = 0 | ||
val size = builder.parameters.size | ||
val resolvedParameterTypes = method.parameterTypes | ||
while (i < size) { | ||
val parameter = builder.parameters[i] | ||
val type = javaToKotlinType(resolvedParameterTypes[i]) | ||
builder.parameters[i] = parameter.toBuilder(parameter.name, type).build() | ||
i++ | ||
} | ||
|
||
return builder | ||
return overriding(methodElement, method.parameterTypes).returns(javaToKotlinType(returnType)) | ||
} | ||
|
||
private fun overriding(method: XMethodElement): FunSpec.Builder { | ||
private fun overriding( | ||
method: XMethodElement, | ||
resolvedParameterTypes: List<XType> | ||
): FunSpec.Builder { | ||
var modifiers: Set<Modifier> = method.modifiers.toMutableSet() | ||
require( | ||
Modifier.PRIVATE !in modifiers && | ||
|
@@ -90,9 +77,10 @@ object XFunSpec { | |
.forEach { funBuilder.addTypeVariable(it) } | ||
*/ | ||
|
||
method.parameters.forEach { | ||
method.parameters.forEachIndexed { index, parameter -> | ||
funBuilder.addParameter( | ||
ParameterSpec.builder(it.name, it.type.typeName.toKTypeName()).build()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This |
||
ParameterSpec.builder(parameter.name, javaToKotlinType(resolvedParameterTypes[index])) | ||
.build()) | ||
} | ||
if (method.isVarArgs()) { | ||
funBuilder.parameters[funBuilder.parameters.lastIndex] = | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,15 @@ | ||
plugins { | ||
id 'org.jetbrains.kotlin.jvm' | ||
id 'org.jetbrains.dokka' | ||
id 'com.vanniktech.maven.publish' | ||
} | ||
|
||
sourceCompatibility = 1.8 | ||
kotlin { | ||
jvmToolchain(11) | ||
} | ||
|
||
dependencies { | ||
api project(':models') | ||
|
||
implementation deps.kotlin.stdlib | ||
} | ||
|
||
apply plugin: 'com.vanniktech.maven.publish' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
plugins { | ||
id 'org.jetbrains.kotlin.jvm' | ||
id 'org.jetbrains.dokka' | ||
id 'com.vanniktech.maven.publish' | ||
} | ||
|
||
sourceCompatibility = 1.8 | ||
|
||
kotlin { | ||
jvmToolchain(11) | ||
} | ||
|
||
dependencies { | ||
implementation deps.kotlin.stdlib | ||
implementation project(':core') | ||
} | ||
|
||
apply plugin: 'com.vanniktech.maven.publish' |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,13 +42,13 @@ ext.deps = [ | |
targetSdkVersion: 30, | ||
|
||
gradlePlugins: [ | ||
android: 'com.android.tools.build:gradle:4.2.0', | ||
android: 'com.android.tools.build:gradle:7.4.2', | ||
kotlin: "org.jetbrains.kotlin:kotlin-gradle-plugin:${versions.kotlin}", | ||
ksp: "com.google.devtools.ksp:com.google.devtools.ksp.gradle.plugin:${versions.ksp}", | ||
dokka: "org.jetbrains.dokka:dokka-gradle-plugin:${versions.dokka}", | ||
mavenPublish: 'com.vanniktech:gradle-maven-publish-plugin:0.18.0', | ||
spotless: "com.diffplug.spotless:spotless-plugin-gradle:5.11.0", | ||
shadow: "com.github.jengelman.gradle.plugins:shadow:6.1.0", | ||
shadow: "com.github.johnrengelman:shadow:8.1.0", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks questionable - but it is still the same library - upgrade is needed for the new gradle plugin version. |
||
] | ||
], | ||
"kotlin": [ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-all.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,10 @@ plugins { | |
id 'org.jetbrains.kotlin.android' | ||
} | ||
|
||
kotlin { | ||
jvmToolchain(11) | ||
} | ||
|
||
android { | ||
compileSdkVersion deps.build.compileSdkVersion | ||
buildToolsVersion deps.build.buildToolsVersion | ||
|
@@ -26,8 +30,8 @@ android { | |
} | ||
|
||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_1_8 | ||
targetCompatibility JavaVersion.VERSION_1_8 | ||
sourceCompatibility JavaVersion.VERSION_11 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure how useful these are, much of the code is already in kotlin. |
||
targetCompatibility JavaVersion.VERSION_11 | ||
} | ||
|
||
variantFilter { variant -> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright (c) 2023 Uber Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package testcases.KT006_reference_self | ||
|
||
@motif.Scope | ||
interface Child { | ||
|
||
@motif.Objects | ||
abstract class Objects : ObjectComponent<Bar> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the key ingredient of the repro case, that an |
||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the real
type
we want, but we can only get it frommethod
(which has the enclosing generic context), but notmethodElement
(which has the unresolvedT
as type). Hence, we passmethod.parameterTypes
into theoverriding
function.