You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When using the latest snapshot of the proofs plugin (2.0.0-SNAPSHOT) and using it to test out a generic numeric function with given instances for Int and Double I encountered some strange behavior, where when I expected the proofs plugin to use the Double instance, it seems to be using the Int instance, and coercing the passed Doubles to and from Int.
To Reproduce
Run the following example with the proofs plugin, version 2.0.0-SNAPSHOT:
packagetestimportarrow.Context
@Context
@Retention(AnnotationRetention.RUNTIME)
@Target(
AnnotationTarget.CLASS,
AnnotationTarget.FUNCTION,
AnnotationTarget.PROPERTY,
AnnotationTarget.VALUE_PARAMETER
)
@MustBeDocumented
annotationclassGiveninlinefun <A> given(@Given identity:A): A= identity
interfaceNum<A> {
val zero:Aoperatorfun A.plus(other:A): Aoperatorfun A.times(other:A): A
}
@Given
internalval intNum =object:Num<Int> {
overrideval zero:Int=0overridefun Int.plus(other:Int): Int {
returnthis+ other
}
overridefun Int.times(other:Int): Int {
returnthis* other
}
}
@Given
internalval doubleNum =object:Num<Double> {
overrideval zero =0.0overridefun Double.plus(other:Double): Double {
returnthis+ other
}
overridefun Double.times(other:Double): Double {
returnthis* other
}
}
fun <A> someNumericFunction(
x:A, y:A,
@Given num:Num<A>
): A=with(num) {
return x + y
}
val x = someNumericFunction(2,2)
val y = someNumericFunction(2.2,2.2)
funmain() {
// Got: 4 4.0// Expected: 4 4.4println("$x$y")
}
Environment (please complete the following information):
Kotlin version [eg. 1.3.61]: 1.6.0
[Kotlin Intellij IDEA plugin version]: Not sure (I used the latest arrow MPP template)
Intellij IDEA version: 2021.3
The text was updated successfully, but these errors were encountered:
Describe the bug
When using the latest snapshot of the proofs plugin (2.0.0-SNAPSHOT) and using it to test out a generic numeric function with given instances for
Int
andDouble
I encountered some strange behavior, where when I expected the proofs plugin to use theDouble
instance, it seems to be using theInt
instance, and coercing the passedDouble
s to and fromInt
.To Reproduce
Run the following example with the proofs plugin, version
2.0.0-SNAPSHOT
:Environment (please complete the following information):
The text was updated successfully, but these errors were encountered: