forked from scala/scala3
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix regression in cyclic constraint handling
This regressed in 50eb0e9 when `current.ensureNonCyclic` was incorrectly replaced by `validBoundsFor` which operates on `this`, not `current`. This isn't the first time we make this error (cf a8641c5), maybe we should refactor OrderingConstraint so that operations on `current` are done in the companion object where `this` isn't accessible. Fixes scala#16471.
- Loading branch information
Showing
2 changed files
with
50 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
object tag { | ||
type Tag[U] | ||
opaque type Tagged[U] = Tag[U] | ||
type @@[+T, U] = (T & Tagged[U]) | Null | ||
} | ||
import tag.* | ||
|
||
trait FromInput[Val] | ||
object FromInput { | ||
trait CoercedScalaResult | ||
implicit def optionInput[T](implicit ev: FromInput[T]): FromInput[Option[T]] = ??? | ||
implicit def coercedScalaInput[T]: FromInput[T @@ CoercedScalaResult] = ??? | ||
} | ||
import FromInput.CoercedScalaResult | ||
|
||
object schema { | ||
trait InputType[+T] // This is critical! Making InputType invariant allows to compile | ||
|
||
case class OptionInputType[T](ofType: InputType[T]) extends InputType[Option[T]] | ||
class ScalarType[T] extends InputType[T @@ CoercedScalaResult] | ||
implicit val IntType: ScalarType[Int] = ??? | ||
} | ||
export schema.* | ||
|
||
trait WithoutInputTypeTags[T] { type Res } | ||
object WithoutInputTypeTags { | ||
implicit def coercedArgTpe[T]: WithoutInputTypeTags[T @@ CoercedScalaResult] { type Res = T } = ??? | ||
implicit def coercedOptArgTpe[T]: WithoutInputTypeTags[Option[T @@ CoercedScalaResult]] { type Res = Option[T] } = ??? | ||
} | ||
|
||
trait Argument[T] | ||
object Argument { | ||
def apply[T](argumentType: InputType[T])(implicit | ||
fromInput: FromInput[T], | ||
res: WithoutInputTypeTags[T] | ||
): Argument[res.Res] = ??? | ||
} | ||
|
||
@main def Test = { | ||
// Does not compile | ||
val optionalArgument = Argument( | ||
argumentType = OptionInputType(IntType), | ||
) | ||
|
||
// // This would compile | ||
// val hintedArg = Argument[Option[Int @@ CoercedScalaResult]]( | ||
// argumentType = OptionInputType(IntType) | ||
// ) | ||
} |