Repro:
class Expr
typealias Expression = Expr|String(startsWith("${"), endsWith("}"))
class A {
username: String|Expression
}
x: A = new {
username = "admin"
// ^^^^^^^
// Constraint violation.
// Required: startsWith("${")
// Found: "admin"
}
This goes away if Expression is aliased to just the constrained string or if the alias is "dereferenced" and copied directly into the type annotation of A.username