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
How can I get a type symbol for a type alias to use TypeDef.apply?
You can get it from an existing type alias. We currently do not have a method to create new type symbol. We might want to add this as Symbol.newType or Symbol.newTypeAlias.
nicolasstucki
changed the title
> How can I get a type symbol for a type alias to use TypeDef.apply?
How can I get a type symbol for a type alias to use TypeDef.apply?
Jan 15, 2024
I was asked by @Gedochao to elaborate a bit on the requirements here.
The idea is to add Symbol.newType in scala.quoted.Quotes.reflectModule.SymbolModule implementation, which would generate a type alias/type member. This method would likely have a signature like:
It would have to work with the preexisting TypeDef.apply(symbol: Symbol), which means:
the aliased type should be included in the Symbol definition
the resulting type alias/member either cannot be made abstract, or we should include that information in Symbol.newType(parent: Symbol, name: String, tpe: Option[TypeRepr]).
I would personally prefer if it could be made abstract for completeness' sake, but the original issue raised in the discussion linked above does not require that.
the resulting type alias/member either cannot be made abstract, or we should include that information in Symbol.newType(parent: Symbol, name: String, tpe: Option[TypeRepr]).
Generally, type members define a lower and an upper bound. Maybe newType should take a TypeBounds instead of a TypeRepr (abstract types without explicit bounds could then be created using TypeBounds.empty):
I think, this would also be more consistent with the rest of the API.
Please also allow for passing a flags and a privateWithin argument, like for newMethod and newVal (unfortunately, newClass is missing this feature but it should also have it).
You can get it from an existing type alias. We currently do not have a method to create new type symbol. We might want to add this as
Symbol.newType
orSymbol.newTypeAlias
.Originally posted by @nicolasstucki in #19344 (comment)
The text was updated successfully, but these errors were encountered: