Just bumped into it and thought that it might be u...
# language-proposals
e
Just bumped into it and thought that it might be useful to have something like parameter alias in addition to typealias. I had a situation where I needed to create the following typealias to keep compatibility with previous versions of source code:
Copy code
typealias Spacing = Horizontal
Where
Spacing
was a
data class
with property
size: Int
, and
Horizontal
is a new
data class
with property
height: Int
. Nothing was broken after that little conversion, although it occured to me that if someone had used named arguments, e.g.
Spacing(size = 8)
, then it wouldn't have been valid, and I don't like the idea that I would have had to rename my
height: Int
back to
size: Int
. So I'm suggesting that typealiasing classes would also support parameter names aliasing. Off-hand syntax proposal:
Copy code
typealias Type1 = Type2 {
  namealias property11 = property21
  namealias property12 = property22
  ...
}
I'm not sure about this feature design though. It might get abused in order to implement polymorphism (might not) which I don't think is a good idea