-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Homogenize Reflect Type constructors #9744
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
+2 −2 | src/main/scala/cps/forest/ApplyTreeTransform.scala | |
+6 −6 | src/main/scala/cps/forest/ThrowTransform.scala | |
+11 −11 | src/main/scala/cps/forest/TryTransform.scala |
+1 −1 | utest/src-0/utest/asserts/Asserts.scala | |
+1 −1 | utest/src-0/utest/asserts/Tracer.scala |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1336,20 +1336,20 @@ trait Reflection extends reflect.Types { reflectSelf: CompilerInterface => | |
// TYPES // | ||
/////////////// | ||
|
||
/** Returns the type (Type) of T */ | ||
def typeOf[T](using qtype: scala.quoted.Type[T], ctx: Context): Type = | ||
qtype.asInstanceOf[scala.internal.quoted.Type[T]].typeTree.asInstanceOf[TypeTree].tpe | ||
|
||
|
||
// ----- Types ---------------------------------------------------- | ||
|
||
given (using ctx: Context) as TypeTest[Type, Type] = reflectSelf.Type_TypeTest | ||
given TypeOps as Type.type = Type | ||
|
||
object Type: | ||
|
||
def apply(clazz: Class[_])(using ctx: Context): Type = | ||
reflectSelf.Type_apply(clazz) | ||
/** Returns the type or kind (Type) of T */ | ||
def of[T <: AnyKind](using qtype: scala.quoted.Type[T], ctx: Context): Type = | ||
qtype.asInstanceOf[scala.internal.quoted.Type[TypeTree]].typeTree.tpe | ||
|
||
/** Returns the type or kind of the class of the type T */ | ||
def ofClass[T](using ct: scala.reflect.ClassTag[T]): Type = | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The existence of both def apply[T <: AnyKind](using qtype: scala.quoted.Type[T]): Type[T] = qtype
// usage
Type[T] I see in the test code we write Then we can rename There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did not notice the
The apply is not good because it leads to easy mistakes as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I only see 2 tests files with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If it takes an explicit argument no one will use it as they would have to write much more code for something that they should be encouraged to do. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This concept is in the middle between There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I have exhausted my arguments ;) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't mind the name but I am not sure what the benefit is except to conveniently have an unapplied polymorphic type (when generating ClassTag still requires a statically known type) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That is unfortunately unavoidable for any |
||
reflectSelf.Type_ofClass(ct.runtimeClass) | ||
|
||
extension (self: Type): | ||
|
||
|
@@ -1626,13 +1626,9 @@ trait Reflection extends reflect.Types { reflectSelf: CompilerInterface => | |
end MatchType | ||
|
||
|
||
/** | ||
* An accessor for `scala.internal.MatchCase[_,_]`, the representation of a `MatchType` case. | ||
*/ | ||
def MatchCaseType(using ctx: Context): Type = { | ||
import scala.internal.MatchCase | ||
Type(classOf[MatchCase[_,_]]) | ||
} | ||
/** An accessor for `scala.internal.MatchCase[_,_]`, the representation of a `MatchType` case. */ | ||
def MatchCaseType(using ctx: Context): Type = | ||
Type.ofClass[scala.internal.MatchCase[_,_]] | ||
|
||
given (using ctx: Context) as TypeTest[Type, ByNameType] = reflectSelf.ByNameType_TypeTest | ||
given ByNameTypeOps as ByNameType.type = ByNameType | ||
|
Uh oh!
There was an error while loading. Please reload this page.