Skip to content

Commit b92708b

Browse files
serrasnomisRev
andauthored
Update Kotlin and Arrow versions (#60)
Co-authored-by: Simon Vergauwen <[email protected]>
1 parent edd4ca7 commit b92708b

File tree

16 files changed

+95
-83
lines changed

16 files changed

+95
-83
lines changed

analysis/common/build.gradle.kts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ plugins {
1010

1111
kotlin {
1212
explicitApi = null
13+
jvmToolchain {
14+
(this as JavaToolchainSpec).languageVersion.set(JavaLanguageVersion.of(11))
15+
}
1316
}
1417

1518
dependencies {

analysis/common/src/main/kotlin/arrow/meta/plugins/analysis/phases/analysis/solver/check/EntryPoint.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ public fun SolverState.checkDeclarationConstraints(
143143
/**
144144
* Only elements which are not
145145
* - inside another "callable declaration" (function, property, etc.) (b/c this is not yet
146-
* supported)
146+
* supported)
147147
* - or constructors (b/c they are handled at the level of class)
148148
*/
149149
private fun Declaration.shouldBeAnalyzed() = !(this.parents.any { it is CallableDeclaration })

analysis/common/src/main/kotlin/arrow/meta/plugins/analysis/phases/analysis/solver/collect/FromAnnotations.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@ internal fun SolverState.parseFormula(
143143
"""
144144
(declare-fun this () $VALUE_TYPE)
145145
(declare-fun $RESULT_VAR_NAME () $VALUE_TYPE)
146-
""".trimIndent(
147-
)
146+
"""
147+
.trimIndent()
148148
val fullString = "$params\n$deps\n$rest\n(assert $formula)"
149149
return solver.parse(fullString)
150150
}

analysis/common/src/main/kotlin/arrow/meta/plugins/analysis/phases/analysis/solver/errors/ErrorIds.kt

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ sealed interface ErrorIds {
4444
The compiler won't catch these errors in its own analysis phase (like it would do with a
4545
type error), since this is perfectly good code. However, it seems desirable for the
4646
programmer to know that a particular language feature cannot be used in these blocks.
47-
""".trimIndent(
48-
)
47+
"""
48+
.trimIndent()
4949
}
5050

5151
enum class Laws : ErrorIds {
@@ -64,8 +64,8 @@ sealed interface ErrorIds {
6464
6565
- It must call **exactly one** function at the end,
6666
- The call must use the parameters **in order**.
67-
""".trimIndent(
68-
)
67+
"""
68+
.trimIndent()
6969
}
7070

7171
enum class Unsupported : ErrorIds {
@@ -92,8 +92,8 @@ sealed interface ErrorIds {
9292
```kotlin
9393
val wrong = 1 / 0 // does not satisfy '0 != 0' in Int.div law
9494
```
95-
""".trimIndent(
96-
)
95+
"""
96+
.trimIndent()
9797
},
9898
UnsatBodyPost {
9999
override val shortDescription: String
@@ -113,8 +113,8 @@ sealed interface ErrorIds {
113113
// does not satisfy 'x + x > 1'
114114
}
115115
```
116-
""".trimIndent(
117-
)
116+
"""
117+
.trimIndent()
118118
},
119119
UnsatInvariants {
120120
override val shortDescription: String
@@ -133,8 +133,8 @@ sealed interface ErrorIds {
133133
...
134134
}
135135
```
136-
""".trimIndent(
137-
)
136+
"""
137+
.trimIndent()
138138
}
139139
}
140140

@@ -154,8 +154,8 @@ sealed interface ErrorIds {
154154
...
155155
}
156156
```
157-
""".trimIndent(
158-
)
157+
"""
158+
.trimIndent()
159159
},
160160
InconsistentDefaultValues {
161161
override val fullDescription: String
@@ -170,8 +170,8 @@ sealed interface ErrorIds {
170170
...
171171
}
172172
```
173-
""".trimIndent(
174-
)
173+
"""
174+
.trimIndent()
175175
},
176176
InconsistentConditions {
177177
override val fullDescription: String
@@ -192,8 +192,8 @@ sealed interface ErrorIds {
192192
}
193193
}
194194
```
195-
""".trimIndent(
196-
)
195+
"""
196+
.trimIndent()
197197

198198
override val level: SeverityLevel
199199
get() = SeverityLevel.Warning
@@ -205,8 +205,8 @@ sealed interface ErrorIds {
205205
The post-conditions gathered after calling a function imply
206206
that this function could not be called at all.
207207
_This is really uncommon in practice_.
208-
""".trimIndent(
209-
)
208+
"""
209+
.trimIndent()
210210

211211
override val level: SeverityLevel
212212
get() = SeverityLevel.Warning
@@ -225,8 +225,8 @@ sealed interface ErrorIds {
225225
}
226226
227227
```
228-
""".trimIndent(
229-
)
228+
"""
229+
.trimIndent()
230230
};
231231

232232
override val shortDescription: String
@@ -245,8 +245,8 @@ sealed interface ErrorIds {
245245
the one declared in its parent. This guarantees that we can
246246
always replace a call to the parent with a call to the child
247247
(Liskov Substitution Principle).
248-
""".trimIndent(
249-
)
248+
"""
249+
.trimIndent()
250250
},
251251
NotStrongerPostcondition {
252252
override val shortDescription: String
@@ -259,8 +259,8 @@ sealed interface ErrorIds {
259259
the one declared in its parent. This guarantees that we can
260260
always replace a call to the parent with a call to the child
261261
(Liskov Substitution Principle).
262-
""".trimIndent(
263-
)
262+
"""
263+
.trimIndent()
264264
}
265265
}
266266

analysis/common/src/main/kotlin/arrow/meta/plugins/analysis/phases/analysis/solver/errors/ErrorMessages.kt

Lines changed: 20 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import org.sosy_lab.java_smt.api.Model
3131
* // c -> h()
3232
* // d -> f(g(2), h())
3333
* ```
34+
*
3435
* We can leverage this information to write better error messages. If we have a constraint which
3536
* states b > 0, we can replace it with g(2) > 0.
3637
*/
@@ -41,7 +42,6 @@ object ErrorMessages {
4142
* SMT formulae.
4243
*
4344
* For example, we cannot translate method calls to SMT:
44-
*
4545
* ```kotlin
4646
* fun f(xs: List[String]): String {
4747
* pre({ !xs.get(0).isEmpty() }) { ... }
@@ -95,14 +95,13 @@ object ErrorMessages {
9595
*
9696
* See [arrow.meta.plugins.analysis.phases.analysis.solver.checkImplicationOf] for the code which
9797
* produces the errors.
98-
*
9998
* - The _one_ constraint name and Boolean formula which could not be satisfied.
10099
* - A _counter-example_ (also called a _model_), which is an assignment of values to
101-
* variableswhich show a specific instance in which the constraint is false.
100+
* variableswhich show a specific instance in which the constraint is false.
102101
* - In the `f` function above in the `UnsatBodyPost` epigraph, one such counter-example is `x ==
103-
* 0`, since in that case `0 + 0 > 1` is false.
102+
* 0`, since in that case `0 + 0 > 1` is false.
104103
* - By looking at the values of the model for the arguments, we can derive one specific trace for
105-
* which the function fails.
104+
* which the function fails.
106105
*/
107106
object Unsatisfiability {
108107

@@ -111,7 +110,6 @@ object ErrorMessages {
111110
* property, function) call are not satisfied.
112111
*
113112
* For example:
114-
*
115113
* ```kotlin
116114
* val wrong = 1 / 0 // does not satisfy '0 != 0' in Int.div law
117115
* ```
@@ -126,16 +124,15 @@ object ErrorMessages {
126124
| -> unsatisfiable constraint: `${callPreCondition.formula.dumpKotlinLike()}`
127125
| -> ${template(callPreCondition, this)}
128126
| -> ${branch(branch)}
129-
""".trimMargin(
130-
)
127+
"""
128+
.trimMargin()
131129

132130
/**
133131
* (attached to the return value)
134132
*
135133
* the post-condition declared in a function body is not true.
136134
*
137135
* For example:
138-
*
139136
* ```kotlin
140137
* fun f(x: Int): Int {
141138
* pre(x >= 0) { "non-negative" }
@@ -152,15 +149,14 @@ object ErrorMessages {
152149
): String =
153150
"""|declaration `${declaration.name}` fails to satisfy the post-condition: ${postCondition.formula.dumpKotlinLike()}
154151
| -> ${branch(branch)}
155-
""".trimMargin(
156-
)
152+
"""
153+
.trimMargin()
157154

158155
/**
159156
* (attached to the new value): the invariant declared for a mutable variable is not satisfied
160157
* by the new value.
161158
*
162159
* For example:
163-
*
164160
* ```kotlin
165161
* fun g(): Int {
166162
* var r = 1.invariant({ it > 0 }) { "it > 0" }
@@ -179,8 +175,8 @@ object ErrorMessages {
179175
"""|invariants are not satisfied in `${expression.text}`
180176
| -> unsatisfiable constraint: `${constraint.formula.dumpKotlinLike()}`
181177
| -> ${branch(branch)}
182-
""".trimMargin(
183-
)
178+
"""
179+
.trimMargin()
184180
}
185181

186182
/**
@@ -205,7 +201,6 @@ object ErrorMessages {
205201
* The set of pre-conditions given to the function leaves no possible way to call the function.
206202
*
207203
* For example:
208-
*
209204
* ```kotlin
210205
* fun h(x: Int): Int {
211206
* pre({ x > 0 }) { "greater than 0" }
@@ -226,7 +221,6 @@ object ErrorMessages {
226221
* The default values do not satisfy the pre-conditions.
227222
*
228223
* For example:
229-
*
230224
* ```kotlin
231225
* fun h(x: Int = 0): Int {
232226
* pre({ x > 0 }) { "greater than 0" }
@@ -245,7 +239,6 @@ object ErrorMessages {
245239
* condition it hangs upon conflicts with the rest of the information about the function.
246240
*
247241
* For example, if a condition goes against a pre-condition:
248-
*
249242
* ```kotlin
250243
* fun i(x: Int): Int {
251244
* pre({ x > 0 }) { "greater than 0" }
@@ -265,8 +258,8 @@ object ErrorMessages {
265258
): String =
266259
"""|unreachable code due to conflicting conditions: ${unsatCore.dumpKotlinLike()}
267260
| -> ${branch(branch)}
268-
""".trimMargin(
269-
)
261+
"""
262+
.trimMargin()
270263

271264
/**
272265
* (attached to the function call): the post-conditions gathered after calling a function imply
@@ -278,15 +271,14 @@ object ErrorMessages {
278271
): String =
279272
"""|unreachable code due to post-conditions: ${unsatCore.dumpKotlinLike()}
280273
| -> ${branch(branch)}
281-
""".trimMargin(
282-
)
274+
"""
275+
.trimMargin()
283276

284277
/**
285278
* (attached to a local declaration): there is no way in which the invariant attached to a
286279
* declaration may be satisfied.
287280
*
288281
* For example:
289-
*
290282
* ```kotlin
291283
* fun j(x: Int): Int {
292284
* pre({ x > 0 }) { "greater than 0" }
@@ -301,22 +293,22 @@ object ErrorMessages {
301293
): String =
302294
"""|invariants are inconsistent: ${it.dumpKotlinLike()}
303295
| -> ${branch(branch)}
304-
""".trimMargin(
305-
)
296+
"""
297+
.trimMargin()
306298
}
307299

308300
object Liskov {
309301
internal fun KotlinPrinter.notWeakerPrecondition(constraint: NamedConstraint): String =
310302
"""|pre-condition `${constraint.msg}` is not weaker than those from overridden members
311303
| -> problematic constraint: `${constraint.formula.dumpKotlinLike()}`
312-
""".trimMargin(
313-
)
304+
"""
305+
.trimMargin()
314306

315307
internal fun KotlinPrinter.notStrongerPostcondition(constraint: NamedConstraint): String =
316308
"""|post-condition `${constraint.msg}` from overridden member is not satisfied
317309
| -> problematic constraint: `${constraint.formula.dumpKotlinLike()}`
318-
""".trimMargin(
319-
)
310+
"""
311+
.trimMargin()
320312
}
321313

322314
object Exception {

analysis/example/build.gradle.kts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,17 @@ plugins {
44
id(libs.plugins.kotlin.multiplatform.get().pluginId)
55
alias(libs.plugins.arrowGradleConfig.kotlin)
66
alias(libs.plugins.arrowGradleConfig.formatter)
7+
alias(libs.plugins.arrowGradleConfig.versioning)
78
}
89

910

1011
kotlin {
1112
explicitApi = null
1213

14+
jvmToolchain {
15+
(this as JavaToolchainSpec).languageVersion.set(JavaLanguageVersion.of(11))
16+
}
17+
1318
sourceSets {
1419
commonMain {
1520
dependencies {

analysis/java-gradle-plugin/build.gradle.kts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ tasks.processResources {
1616
}
1717
}
1818

19+
kotlin {
20+
explicitApi = null
21+
jvmToolchain {
22+
(this as JavaToolchainSpec).languageVersion.set(JavaLanguageVersion.of(11))
23+
}
24+
}
25+
1926
dependencies {
2027
api(libs.arrowGradlePluginCommons)
2128
runtimeOnly(libs.classgraph)

analysis/java-plugin/build.gradle.kts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ plugins {
99

1010
kotlin {
1111
explicitApi = null
12+
jvmToolchain {
13+
(this as JavaToolchainSpec).languageVersion.set(JavaLanguageVersion.of(11))
14+
}
1215
}
1316

1417
dependencies {

analysis/kotlin-gradle-plugin/build.gradle.kts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ tasks.processResources {
1616
}
1717
}
1818

19+
kotlin {
20+
explicitApi = null
21+
jvmToolchain {
22+
(this as JavaToolchainSpec).languageVersion.set(JavaLanguageVersion.of(11))
23+
}
24+
}
25+
1926
dependencies {
2027
api(libs.arrowGradlePluginCommons)
2128
runtimeOnly(libs.classgraph)

analysis/kotlin-plugin/build.gradle.kts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ plugins {
1010

1111
kotlin {
1212
explicitApi = null
13+
jvmToolchain {
14+
(this as JavaToolchainSpec).languageVersion.set(JavaLanguageVersion.of(11))
15+
}
1316
}
1417

1518
dependencies {

0 commit comments

Comments
 (0)