Skip to content

eliminate self symbol in Template and ClassInfo #1245

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

Merged
merged 1 commit into from
May 4, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions src/dotty/tools/dotc/transform/FirstTransform.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import StdNames._
* - ensures there are companion objects for all classes except module classes
* - eliminates some kinds of trees: Imports, NamedArgs
* - stubs out native methods
* - eliminate self tree in Template and self symbol in ClassInfo
*/
class FirstTransform extends MiniPhaseTransform with IdentityDenotTransformer with AnnotationTransformer { thisTransformer =>
import ast.tpd._
Expand All @@ -44,7 +45,14 @@ class FirstTransform extends MiniPhaseTransform with IdentityDenotTransformer wi
this
}

def transformInfo(tp: Type, sym: Symbol)(implicit ctx: Context): Type = tp/*{
/** eliminate self symbol in ClassInfo */
def transformInfo(tp: Type, sym: Symbol)(implicit ctx: Context): Type = tp match {
case tp@ClassInfo(_, _, _, _, self: Symbol) =>
tp.derivedClassInfo(selfInfo = self.info)
case _ =>
tp
}
/*
tp match {
//create companions for value classes that are not from currently compiled source file
case tp@ClassInfo(_, cls, _, decls, _)
Expand All @@ -59,7 +67,8 @@ class FirstTransform extends MiniPhaseTransform with IdentityDenotTransformer wi
case _ => tp
}
}
*/
*/

override def checkPostCondition(tree: Tree)(implicit ctx: Context): Unit = {
tree match {
case Select(qual, _) if tree.symbol.exists =>
Expand Down Expand Up @@ -132,6 +141,11 @@ class FirstTransform extends MiniPhaseTransform with IdentityDenotTransformer wi
(modul, mcComp, classComp)
}

/** elimiate self in Template */
override def transformTemplate(impl: Template)(implicit ctx: Context, info: TransformerInfo): Tree = {
cpy.Template(impl)(self = EmptyValDef)
}

override def transformDefDef(ddef: DefDef)(implicit ctx: Context, info: TransformerInfo) = {
if (ddef.symbol.hasAnnotation(defn.NativeAnnot)) {
ddef.symbol.resetFlag(Deferred)
Expand Down