-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Remove PreName add (almost) all other implicit conversions #4077
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 2 commits
1e471b7
2aa965c
57df5b5
163509d
f4e9ccd
a50b2d4
b18fba5
e07a68d
ebe084f
d870b36
c064915
9866c74
27ee9a4
4f119bc
f2fba0b
c01612a
0bed6fd
01cc814
c49d246
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -73,3 +73,4 @@ compiler/after-pickling.txt | |
*.dotty-ide-version | ||
|
||
*.decompiled.out | ||
bench/compile.txt | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -154,9 +154,9 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma | |
lazy val Predef_classOf: Symbol = defn.ScalaPredefModule.requiredMethod(nme.classOf) | ||
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 prefer we leave PreName, but move the String -> PreName conversion to the companion object of PreName. 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 doesn't work as moving it the companion of PreName is not enough to make .toTermName and .toTypeName available on Strings. I guess we could have two implicit conversions, one in PreName's companion and one available by import, but I feel it would just make things worse... Are you sure you don't like this commit as is? In my opinion, completely removing an abstraction from the code base is a clear simplification. The diff might look large but in reality, most of the line changes are about making type more precise by having the TermName/TypeName instead of PreName. The balance sheet in term of added boilerplate is also reasonable: toTermName added: 22 toTypeName added: 12 +4 overloaded methods with String & Name 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 still think we should leave PreName. I don't like to have to overload methods, and the problem is, if you are systematic about it (and you should be!) you will end up with a lot more overloaded methods. I realize it's a contentious issue, but then the maxime "when in doubt, don't change it" applies. One other thing: We have to tell everyone working on the compiler that |
||
|
||
lazy val AnnotationRetentionAttr = ctx.requiredClass("java.lang.annotation.Retention") | ||
lazy val AnnotationRetentionSourceAttr = ctx.requiredClass("java.lang.annotation.RetentionPolicy").linkedClass.requiredValue("SOURCE") | ||
lazy val AnnotationRetentionClassAttr = ctx.requiredClass("java.lang.annotation.RetentionPolicy").linkedClass.requiredValue("CLASS") | ||
lazy val AnnotationRetentionRuntimeAttr = ctx.requiredClass("java.lang.annotation.RetentionPolicy").linkedClass.requiredValue("RUNTIME") | ||
lazy val AnnotationRetentionSourceAttr = ctx.requiredClass("java.lang.annotation.RetentionPolicy").linkedClass.requiredValue("SOURCE".toTermName) | ||
lazy val AnnotationRetentionClassAttr = ctx.requiredClass("java.lang.annotation.RetentionPolicy").linkedClass.requiredValue("CLASS".toTermName) | ||
lazy val AnnotationRetentionRuntimeAttr = ctx.requiredClass("java.lang.annotation.RetentionPolicy").linkedClass.requiredValue("RUNTIME".toTermName) | ||
lazy val JavaAnnotationClass = ctx.requiredClass("java.lang.annotation.Annotation") | ||
|
||
def boxMethods: Map[Symbol, Symbol] = defn.ScalaValueClasses().map{x => // @darkdimius Are you sure this should be a def? | ||
|
@@ -366,7 +366,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma | |
def getAnnotPickle(jclassName: String, sym: Symbol): Option[Annotation] = None | ||
|
||
|
||
def getRequiredClass(fullname: String): Symbol = ctx.requiredClass(fullname.toTermName) | ||
def getRequiredClass(fullname: String): Symbol = ctx.requiredClass(fullname) | ||
|
||
def getClassIfDefined(fullname: String): Symbol = NoSymbol // used only for android. todo: implement | ||
|
||
|
@@ -376,12 +376,12 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma | |
} | ||
|
||
def requiredClass[T](implicit evidence: ClassTag[T]): Symbol = | ||
ctx.requiredClass(erasureString(evidence.runtimeClass).toTermName) | ||
ctx.requiredClass(erasureString(evidence.runtimeClass)) | ||
|
||
def requiredModule[T](implicit evidence: ClassTag[T]): Symbol = { | ||
val moduleName = erasureString(evidence.runtimeClass) | ||
val className = if (moduleName.endsWith("$")) moduleName.dropRight(1) else moduleName | ||
ctx.requiredModule(className.toTermName) | ||
ctx.requiredModule(className) | ||
} | ||
|
||
|
||
|
@@ -1193,8 +1193,8 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma | |
val arity = field.meth.tpe.widenDealias.paramTypes.size - _1.size | ||
val returnsUnit = field.meth.tpe.widenDealias.resultType.classSymbol == UnitClass | ||
if (returnsUnit) | ||
ctx.requiredClass(("scala.compat.java8.JProcedure" + arity).toTermName) | ||
else ctx.requiredClass(("scala.compat.java8.JFunction" + arity).toTermName) | ||
ctx.requiredClass("scala.compat.java8.JProcedure" + arity) | ||
else ctx.requiredClass("scala.compat.java8.JFunction" + arity) | ||
} | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This commit LGTM