Closed rolman243 closed 3 months ago
Describe the bug Scala environment: JVM Scala version: 3.4.2 Iron version: 2.6.0
Reproduction steps Minimal Example:
Refined type
package issue import io.github.iltotore.iron.* import io.github.iltotore.iron.constraint.collection.Empty opaque type NonEmptyString <: String :| Not[Empty] = String :| Not[Empty] object NonEmptyString extends RefinedTypeOps[String, Not[Empty], NonEmptyString]
Avro4s SchemaFor according to example from documentation site
package issue import com.sksamuel.avro4s.SchemaFor import io.github.iltotore.iron.RefinedTypeOps inline given[T](using mirror: RefinedTypeOps.Mirror[T], ev: SchemaFor[mirror.IronType]): SchemaFor[T] = ev.asInstanceOf[SchemaFor[T]]
using SchmeaFor auto generating for NonEmptyString type
package issue import com.sksamuel.avro4s.{AvroSchema, FromRecord, RecordFormat, ToRecord} import NonEmptyString.given import org.apache.avro.Schema final case class Message( nonEmptyString: NonEmptyString ) object Message: val schema: Schema = AvroSchema[Message] given ToRecord[Message] = ToRecord.apply(schema) given FromRecord[Message] = FromRecord.apply(schema) val format: RecordFormat[Message] = RecordFormat.apply(schema)
Expected behavior I would expect to compile this code without error.
Current behavior Unfortunately this code compiles with the following error and I can't figure out, how to fix it.
[error] 12 | val schema: Schema = AvroSchema[Message] [error] | ^ [error] |No given instance of type com.sksamuel.avro4s.SchemaFor[issue.NonEmptyString] was found. [error] |I found: [error] | [error] | issue.given_SchemaFor_T[issue.NonEmptyString]( [error] | { [error] | val $proxy1: [error] | [error] | issue.NonEmptyString$package.type{ [error] | type NonEmptyString = [error] | io.github.iltotore.iron.IronType[String, [error] | io.github.iltotore.iron.constraint.any.Not[ [error] | io.github.iltotore.iron.constraint.collection.Empty] [error] | ] [error] | } [error] | [error] | = [error] | issue.NonEmptyString$package.$asInstanceOf[ [error] | [error] | issue.NonEmptyString$package.type{ [error] | type NonEmptyString = [error] | io.github.iltotore.iron.IronType[String, [error] | io.github.iltotore.iron.constraint.any.Not[ [error] | io.github.iltotore.iron.constraint.collection.Empty] [error] | ] [error] | } [error] | [error] | ] [error] | val RefinedTypeOps_this: $proxy1.NonEmptyString.type = [error] | $proxy1.NonEmptyString [error] | (new RefinedTypeOps_this.given_Mirror_T():RefinedTypeOps_this.given_Mirror_T [error] | ) [error] | }.$asInstanceOf[ [error] | [error] | (issue.NonEmptyString.given_Mirror_T : [error] | => issue.NonEmptyString.given_Mirror_T) [error] | [error] | ], [error] | issue.given_SchemaFor_T[ [error] | io.github.iltotore.iron.IronType[?1.BaseType, ?1.ConstraintType]]( [error] | /* missing */ [error] | summon[ [error] | io.github.iltotore.iron.RefinedTypeOps.Mirror[ [error] | io.github.iltotore.iron.IronType[?1.BaseType, ?1.ConstraintType]] [error] | ] [error] | , [error] | ???) [error] | ) [error] | [error] |But no implicit values were found that match type io.github.iltotore.iron.RefinedTypeOps.Mirror[ [error] | io.github.iltotore.iron.IronType[?1.BaseType, ?1.ConstraintType]] [error] | [error] |where: ?1 is an unknown value of type issue.NonEmptyString.given_Mirror_T [error] |. [error] |---------------------------------------------------------------------------- [error] |Inline stack trace [error] |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - [error] |This location contains code that was inlined from impl.scala:86 [error] |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - [error] |This location contains code that was inlined from impl.scala:86 [error] |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - [error] |This location contains code that was inlined from impl.scala:86 [error] |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - [error] |This location contains code that was inlined from impl.scala:86 [error] |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - [error] |This location contains code that was inlined from impl.scala:86 [error] |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - [error] |This location contains code that was inlined from impl.scala:86 [error] ---------------------------------------------------------------------------- [error] one error found
I don't think it is an actual bug of Iron so it should belong to a discussion.
Describe the bug Scala environment: JVM Scala version: 3.4.2 Iron version: 2.6.0
Reproduction steps Minimal Example:
Refined type
Avro4s SchemaFor according to example from documentation site
using SchmeaFor auto generating for NonEmptyString type
Expected behavior I would expect to compile this code without error.
Current behavior Unfortunately this code compiles with the following error and I can't figure out, how to fix it.