Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Issue #8319: Update to Kotlin 1.4 and Coroutines 1.3.9. #8359

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions build.gradle
Expand Up @@ -204,6 +204,8 @@ subprojects {

packagingOptions {
exclude 'META-INF/atomicfu.kotlin_module'
exclude 'META-INF/AL2.0'
exclude 'META-INF/LGPL2.1'
}

aaptOptions {
Expand Down
6 changes: 3 additions & 3 deletions buildSrc/src/main/java/Dependencies.kt
Expand Up @@ -4,8 +4,8 @@

// Synchronized version numbers for dependencies used by (some) modules
object Versions {
const val kotlin = "1.3.71"
const val coroutines = "1.3.5"
const val kotlin = "1.4.10"
const val coroutines = "1.3.9"

const val junit = "4.12"
const val robolectric = "4.1"
Expand All @@ -17,7 +17,7 @@ object Versions {
const val dokka = "0.9.17"
const val android_gradle_plugin = "3.5.3"
const val android_maven_publish_plugin = "3.6.2"
const val lint = "26.3.2"
const val lint = "27.0.1"
const val detekt = "1.9.1"

const val sentry = "1.7.21"
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Expand Up @@ -215,7 +215,7 @@ class UrlMatcher {
jsonReader -> loadCategories(jsonReader, categoryMap)
}

var whiteList: WhiteList? = null
var whiteList: WhiteList?
JsonReader(white).use { jsonReader -> whiteList = WhiteList.fromJson(jsonReader) }
return UrlMatcher(enabledCategories, supportedCategories, categoryMap, whiteList)
}
Expand Down
Expand Up @@ -60,7 +60,7 @@ private fun IconRequest.Resource.Type.rank(): Int {
}

private val IconRequest.Resource.maxSize: Int
get() = sizes.asSequence().map { size -> size.minLength }.max() ?: 0
get() = sizes.asSequence().map { size -> size.minLength }.maxOrNull() ?: 0

private val IconRequest.Resource.isContainerType: Boolean
get() = mimeType != null && containerTypes.contains(mimeType)
Expand Down
Expand Up @@ -15,7 +15,7 @@ internal fun List<Pair<Int, Int>>.findBestSize(targetSize: Int, maxSize: Int, ma
x >= targetSize && y >= targetSize && x <= maxSize && y <= maxSize
}.filter { (x, y) ->
x == y
}.minBy { (x, _) ->
}.minByOrNull { (x, _) ->
x
}

Expand All @@ -33,7 +33,7 @@ internal fun List<Pair<Int, Int>>.findBestSize(targetSize: Int, maxSize: Int, ma
downScaledY >= targetSize &&
downScaledX <= maxSize &&
downScaledY <= maxSize
}.minBy { (x, _) ->
}.minByOrNull { (x, _) ->
x
}

Expand All @@ -51,7 +51,7 @@ internal fun List<Pair<Int, Int>>.findBestSize(targetSize: Int, maxSize: Int, ma
upscaledY >= targetSize &&
upscaledX <= maxSize &&
upscaledY <= maxSize
}.maxBy { (x, _) ->
}.maxByOrNull { (x, _) ->
x
}

Expand Down
Expand Up @@ -117,7 +117,7 @@ class InMemoryHistoryStorage : HistoryStorage {
}
// Calculate maxScore so that we can invert our scoring.
// Lower Levenshtein distance should produce a higher score.
val maxScore = urlMatches.maxBy { it.score }?.score ?: return@synchronized listOf()
val maxScore = urlMatches.maxByOrNull { it.score }?.score ?: return@synchronized listOf()

// TODO exclude non-matching results entirely? Score that implies complete mismatch.
matchedUrls.asSequence().sortedBy { it.value }.map {
Expand All @@ -126,8 +126,8 @@ class InMemoryHistoryStorage : HistoryStorage {
}

override fun getAutocompleteSuggestion(query: String): HistoryAutocompleteResult? = synchronized(pages) {
segmentAwareDomainMatch(query, pages.keys)?.let { urlMatch ->
return HistoryAutocompleteResult(
return segmentAwareDomainMatch(query, pages.keys)?.let { urlMatch ->
HistoryAutocompleteResult(
query, urlMatch.matchedSegment, urlMatch.url, AUTOCOMPLETE_SOURCE_NAME, pages.size)
}
}
Expand Down
Expand Up @@ -54,7 +54,7 @@ fun List<MenuCandidate>.findNestedMenuCandidate(id: Int): NestedMenuCandidate? =
/**
* Select the highlight with the highest priority.
*/
fun Sequence<MenuEffect>.max() = maxBy {
fun Sequence<MenuEffect>.max() = maxByOrNull {
// Select the highlight with the highest priority
when (it) {
is HighPriorityHighlightEffect -> 2
Expand Down
Expand Up @@ -154,7 +154,7 @@ class BookmarksStorageSuggestionProviderTest {
}
// Calculate maxScore so that we can invert our scoring.
// Lower Levenshtein distance should produce a higher score.
urlMatches.maxBy { it.score }?.score
urlMatches.maxByOrNull { it.score }?.score
?: return@synchronized listOf()

// TODO exclude non-matching results entirely? Score that implies complete mismatch.
Expand Down
Expand Up @@ -220,8 +220,7 @@ internal class RustPushConnection(
// Query for the scope so that we can notify observers who the decrypted message is for.
val scope = pushApi.dispatchInfoForChid(channelId)?.scope

scope?.let {

if (scope != null) {
if (body == null) {
return DecryptedMessage(scope, null)
}
Expand All @@ -235,6 +234,8 @@ internal class RustPushConnection(
)

return DecryptedMessage(scope, data)
} else {
return null
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting that the previous compiler didn't catch this! I wonder if it did some implicit return null.

}
}

Expand Down
Expand Up @@ -92,7 +92,7 @@ class MozillaSocorroService(
if (versionName == DEFAULT_VERSION_NAME) {
try {
versionName = applicationContext.packageManager
.getPackageInfo(applicationContext.packageName, 0).versionName
.getPackageInfo(applicationContext.packageName, 0).versionName ?: DEFAULT_VERSION_NAME
} catch (e: PackageManager.NameNotFoundException) {
logger.error("package name not found, failed to get application version")
} catch (e: IllegalStateException) {
Expand Down
Expand Up @@ -86,23 +86,23 @@ internal class CrashListAdapter(
val text = StringBuilder()

text.append(crashWithReports.crash.uuid)
text.appendln()
text.appendLine()
text.append(crashWithReports.crash.stacktrace.lines().first())
text.appendln()
text.appendLine()

crashWithReports.reports.forEach { report ->
val service = crashReporter.getCrashReporterServiceById(report.serviceId)
text.append(" * ")
text.append(service?.name ?: report.serviceId)
text.append(": ")
text.append(service?.createCrashReportUrl(report.reportId) ?: "<No URL>")
text.appendln()
text.appendLine()
}

text.append("----")
text.appendln()
text.appendLine()
text.append(crashWithReports.crash.stacktrace)
text.appendln()
text.appendLine()

val intent = Intent(Intent.ACTION_SEND)
intent.type = "text/plain"
Expand Down
Expand Up @@ -177,7 +177,7 @@ private fun buildNodeDescription(
append(" ( $name )")

withinHeader()
appendln()
appendLine()

block()
}
Expand Down
Expand Up @@ -100,7 +100,7 @@ internal class Lexer(private val grammar: Grammar) {

@Suppress("ReturnCount")
private fun isElement(input: LexerInput, elements: Map<String, GrammarElement>): Boolean {
val max = elements.keys.map { it.length }.max() ?: return false
val max = elements.keys.map { it.length }.maxOrNull() ?: return false

for (steps in max downTo 1) {
val candidate = input.peekRange(steps)
Expand Down
7 changes: 7 additions & 0 deletions components/tooling/detekt/build.gradle
Expand Up @@ -17,6 +17,13 @@ dependencies {
testImplementation Dependencies.tools_detekt_test
}

tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
// Gradle keeps warning about different Kotlin versions being on the classpath. I am unsure
// how to resolve that and if it is even resolvable in this cross-library setup. Anyhow,
// since it is only a warning I am going to suppress them for this project specifically.
kotlinOptions.allWarningsAsErrors = false
}

tasks.register("lintRelease") {
doLast {
// Do nothing. We execute the same set of tasks for all our modules in parallel on taskcluster.
Expand Down
7 changes: 7 additions & 0 deletions components/tooling/glean-gradle-plugin/build.gradle
Expand Up @@ -13,6 +13,13 @@ repositories {
mavenCentral()
}

tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
// Gradle keeps warning about different Kotlin versions being on the classpath. I am unsure
// how to resolve that and if it is even resolvable in this cross-library setup. Anyhow,
// since it is only a warning I am going to suppress them for this project specifically.
kotlinOptions.allWarningsAsErrors = false
}

dependencies {
implementation gradleApi()
implementation localGroovy()
Expand Down
9 changes: 9 additions & 0 deletions components/tooling/lint/build.gradle
Expand Up @@ -10,7 +10,16 @@ sourceCompatibility = JavaVersion.VERSION_1_8

dependencies {
compileOnly Dependencies.tools_lintapi

// Force the usage of /our/ Kotlin version and not what we get transitively from the lint
// dependencies. Otherwise we end up with a warning that there are multiple versions on the
// classpath.
compileOnly Dependencies.kotlin_stdlib
compileOnly "org.jetbrains.kotlin:kotlin-stdlib-jdk8:${Versions.kotlin}"
compileOnly Dependencies.kotlin_reflect
testImplementation Dependencies.kotlin_stdlib
testImplementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:${Versions.kotlin}"
testImplementation Dependencies.kotlin_reflect

testImplementation Dependencies.tools_lint
testImplementation Dependencies.tools_linttests
Expand Down
Expand Up @@ -9,7 +9,6 @@ import com.android.SdkConstants.FQCN_IMAGE_BUTTON
import com.android.SdkConstants.FQCN_IMAGE_VIEW
import com.android.SdkConstants.IMAGE_BUTTON
import com.android.SdkConstants.IMAGE_VIEW
import com.android.annotations.VisibleForTesting
import com.android.resources.ResourceFolderType
import com.android.tools.lint.detector.api.Category
import com.android.tools.lint.detector.api.Implementation
Expand All @@ -18,6 +17,7 @@ import com.android.tools.lint.detector.api.ResourceXmlDetector
import com.android.tools.lint.detector.api.Scope
import com.android.tools.lint.detector.api.Severity
import com.android.tools.lint.detector.api.XmlContext
import com.google.common.annotations.VisibleForTesting
import org.w3c.dom.Element

/**
Expand Down