Skip to content

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

Closed
Show file tree
Hide file tree
Changes from 15 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,4 @@ compiler/after-pickling.txt
*.dotty-ide-version

*.decompiled.out
bench/compile.txt
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit LGTM

Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ object CollectEntryPoints{
def fail(msg: String, pos: Position = sym.pos) = {
ctx.warning( sym.name +
s" has a main method with parameter type Array[String], but ${toDenot(sym).fullName} will not be a runnable program.\n Reason: $msg",
sourcePos(sym.pos)
sym.pos
// TODO: make this next claim true, if possible
// by generating valid main methods as static in module classes
// not sure what the jvm allows here
Expand Down
34 changes: 18 additions & 16 deletions compiler/src/dotty/tools/backend/jvm/DottyBackendInterface.scala
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,9 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
lazy val Predef_classOf: Symbol = defn.ScalaPredefModule.requiredMethod(nme.classOf)
Copy link
Contributor

Choose a reason for hiding this comment

The 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.

Copy link
Contributor Author

@OlivierBlanvillain OlivierBlanvillain Apr 12, 2018

Choose a reason for hiding this comment

The 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
toTermName removed: 12

toTypeName added: 12
toTypeName removed: 4

+4 overloaded methods with String & Name arguments

Copy link
Contributor

Choose a reason for hiding this comment

The 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. PreName is a single abstraction which fixes this quite nicely. For me it is really analogous to IterableOnce in collections. Before we had some overloaded methods that took Iterables and Iterators respectively. At first there were only a few. Then people complained that, by rights, some other methods should also be dual purpose, and then some others more, and so on. The introduction of IterableOnce stopped the bleeding.

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 Decorators is a highly recommended (maybe mandatory?) input. I have seen so much awkward code because people did not know about it. Is there a good place where we can put it so people will read it?


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?
Expand Down Expand Up @@ -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

Expand All @@ -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)
}


Expand Down Expand Up @@ -498,7 +498,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
// unrelated change.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am against merging this as is. I believe the original version is both clearer and more efficient. Computing | on the fly as a cost, that's why we created all these flag set. Doing several flag tests in a row also has a cost. On the other hand, testing against a FlagConjunction with is is fast and does not require boxing.

ctx.base.settings.YnoGenericSig.value
|| sym.is(Flags.Artifact)
|| sym.is(Flags.allOf(Flags.Method, Flags.Lifted))
|| sym.isBoth(Flags.Method, and = Flags.Lifted)
|| sym.is(Flags.Bridge)
)

Expand Down Expand Up @@ -679,7 +679,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
def isConstructor: Boolean = toDenot(sym).isConstructor
def isAnonymousFunction: Boolean = toDenot(sym).isAnonymousFunction
def isMethod: Boolean = sym is Flags.Method
def isPublic: Boolean = sym.flags.is(Flags.EmptyFlags, Flags.Private | Flags.Protected)
def isPublic: Boolean = sym.flags.is(Flags.EmptyFlags, butNot=Flags.Private | Flags.Protected)
def isSynthetic: Boolean = sym is Flags.Synthetic
def isPackageClass: Boolean = sym is Flags.PackageClass
def isModuleClass: Boolean = sym is Flags.ModuleClass
Expand Down Expand Up @@ -716,7 +716,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
def isDeprecated: Boolean = false
def isMutable: Boolean = sym is Flags.Mutable
def hasAbstractFlag: Boolean =
(sym is Flags.Abstract) || (sym is Flags.JavaInterface) || (sym is Flags.Trait)
(sym is Flags.Abstract) || (sym is Flags.Trait)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

def hasModuleFlag: Boolean = sym is Flags.Module
def isSynchronized: Boolean = sym is Flags.Synchronized
def isNonBottomSubClass(other: Symbol): Boolean = sym.derivesFrom(other)
Expand Down Expand Up @@ -808,23 +808,25 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
else Nil

def annotations: List[Annotation] = toDenot(sym).annotations
def companionModuleMembers: List[Symbol] = {

def companionModuleMembers: List[Symbol] = {
// phase travel to exitingPickler: this makes sure that memberClassesOf only sees member classes,
// not local classes of the companion module (E in the exmaple) that were lifted by lambdalift.
if (linkedClass.isTopLevelModuleClass) /*exitingPickler*/ linkedClass.memberClasses
else Nil
}

def fieldSymbols: List[Symbol] = {
toDenot(sym).info.decls.filter(p => p.isTerm && !p.is(Flags.Method))
}

def methodSymbols: List[Symbol] =
for (f <- toDenot(sym).info.decls.toList if f.isMethod && f.isTerm && !f.isModule) yield f
def serialVUID: Option[Long] = None

def serialVUID: Option[Long] = None

def freshLocal(cunit: CompilationUnit, name: String, tpe: Type, pos: Position, flags: Flags): Symbol = {
ctx.newSymbol(sym, name.toTermName, FlagSet(flags), tpe, NoSymbol, pos)
}
def freshLocal(cunit: CompilationUnit, name: String, tpe: Type, pos: Position, flags: Flags): Symbol =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SymUtils is not used much, to this commit looks smallish. But we should use it more often because it gives us a way to add methods without overloading SymDenotation. In that case I think it is essential that it works for Symbol and SymDenotation in the same way. So my vote is to leave this as is.

ctx.newSymbol(sym, name.toTermName, FlagSet(flags), tpe, NoSymbol, pos.toCoord)

def getter(clz: Symbol): Symbol = decorateSymbol(sym).getter
def setter(clz: Symbol): Symbol = decorateSymbol(sym).setter
Expand Down Expand Up @@ -1193,8 +1195,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)
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions compiler/src/dotty/tools/dotc/ast/Desugar.scala
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ object desugar {
val ValDef(name, tpt, rhs) = vdef
val mods = vdef.mods
val setterNeeded =
(mods is Mutable) && ctx.owner.isClass && (!(mods is PrivateLocal) || (ctx.owner is Trait))
mods.is(Mutable) && ctx.owner.isClass && (!mods.isBoth(Private, and = Local) || ctx.owner.is(Trait))
if (setterNeeded) {
// TODO: copy of vdef as getter needed?
// val getter = ValDef(mods, name, tpt, rhs) withPos vdef.pos?
Expand All @@ -149,7 +149,7 @@ object desugar {

def makeImplicitParameters(tpts: List[Tree], forPrimaryConstructor: Boolean = false)(implicit ctx: Context) =
for (tpt <- tpts) yield {
val paramFlags: FlagSet = if (forPrimaryConstructor) PrivateLocalParamAccessor else Param
val paramFlags: FlagSet = if (forPrimaryConstructor) Private | Local | ParamAccessor else Param
val epname = EvidenceParamName.fresh()
ValDef(epname, tpt, EmptyTree).withFlags(paramFlags | Implicit)
}
Expand Down Expand Up @@ -260,9 +260,9 @@ object desugar {
@sharable private val synthetic = Modifiers(Synthetic)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this commit should not be merged. There is a reason for rawMods/modsDeco: mods should not be called on a typed tree because there mods is typically outdated - one should consult symbol.flags instead. The setup here makes sure that in code working with typed trees using a

import tpd._

import, mods is not visible, because modsDeco is not in scope. So this is a safety measure, not a convenience implicit.

private def toDefParam(tparam: TypeDef): TypeDef =
tparam.withMods(tparam.rawMods & EmptyFlags | Param)
tparam.withMods(tparam.mods & EmptyFlags | Param)
private def toDefParam(vparam: ValDef): ValDef =
vparam.withMods(vparam.rawMods & (Implicit | Erased) | Param)
vparam.withMods(vparam.mods & (Implicit | Erased) | Param)

/** The expansion of a class definition. See inline comments for what is involved */
def classDef(cdef: TypeDef)(implicit ctx: Context): Tree = {
Expand Down Expand Up @@ -314,7 +314,7 @@ object desugar {
lazy val derivedEnumParams = enumClass.typeParams.map(derivedTypeParam)
val impliedTparams =
if (isEnumCase && originalTparams.isEmpty)
derivedEnumParams.map(tdef => tdef.withFlags(tdef.mods.flags | PrivateLocal))
derivedEnumParams.map(tdef => tdef.withFlags(tdef.mods.flags | Private | Local))
else
originalTparams
val constrTparams = impliedTparams.map(toDefParam)
Expand Down Expand Up @@ -729,7 +729,7 @@ object desugar {
case _ =>
val tmpName = UniqueName.fresh()
val patMods =
mods & Lazy | Synthetic | (if (ctx.owner.isClass) PrivateLocal else EmptyFlags)
mods & Lazy | Synthetic | (if (ctx.owner.isClass) Private | Local else EmptyFlags)
val firstDef =
ValDef(tmpName, TypeTree(), matchExpr)
.withPos(pat.pos.union(rhs.pos)).withMods(patMods)
Expand Down
6 changes: 4 additions & 2 deletions compiler/src/dotty/tools/dotc/ast/Positioned.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ abstract class Positioned extends DotClass with Product {

setPos(initialPos)

/** The item's position.
*/
/** The item's position. */
def pos: Position = curPos

/** The item's coord. */
def coord: Coord = curPos.toCoord
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is wrong. "Coord" is an optimization for Symbols, so that they can take alternatively a Position or an Index. It's wrong to pollute other data types with this distinction - they should have no idea what a Coord is nor how to covert to it.


/** Destructively update `curPos` to given position. Also, set any missing
* positions in children.
*/
Expand Down
14 changes: 8 additions & 6 deletions compiler/src/dotty/tools/dotc/ast/Trees.scala
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ object Trees {
/** The type constructor at the root of the tree */
type ThisTree[T >: Untyped] <: Tree[T]

private[this] var myTpe: T = _
protected var myTpe: T @uncheckedVariance = _

/** Destructively set the type of the tree. This should be called only when it is known that
* it is safe under sharing to do so. One use-case is in the withType method below
Expand All @@ -91,7 +91,7 @@ object Trees {
/** The type of the tree. In case of an untyped tree,
* an UnAssignedTypeException is thrown. (Overridden by empty trees)
*/
def tpe: T @uncheckedVariance = {
final def tpe: T @uncheckedVariance = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit LGTM

if (myTpe == null)
throw new UnAssignedTypeException(this)
myTpe
Expand Down Expand Up @@ -310,7 +310,7 @@ object Trees {

private[this] var myMods: untpd.Modifiers = null

private[dotc] def rawMods: untpd.Modifiers =
def mods: untpd.Modifiers =
if (myMods == null) untpd.EmptyModifiers else myMods

def rawComment: Option[Comment] = getAttachment(DocComment)
Expand Down Expand Up @@ -338,7 +338,7 @@ object Trees {
*/
def namePos =
if (pos.exists)
if (rawMods.is(Synthetic)) Position(pos.point, pos.point)
if (mods.is(Synthetic)) Position(pos.point, pos.point)
else Position(pos.point, pos.point + name.stripModuleClassSuffix.lastPart.length, pos.point)
else pos
}
Expand Down Expand Up @@ -727,7 +727,6 @@ object Trees {
}

trait WithoutTypeOrPos[-T >: Untyped] extends Tree[T] {
override def tpe: T @uncheckedVariance = NoType.asInstanceOf[T]
override def withTypeUnchecked(tpe: Type) = this.asInstanceOf[ThisTree[Type]]
override def pos = NoPosition
override def setPos(pos: Position) = {}
Expand All @@ -740,6 +739,8 @@ object Trees {
*/
case class Thicket[-T >: Untyped](trees: List[Tree[T]])
extends Tree[T] with WithoutTypeOrPos[T] {
myTpe = NoType.asInstanceOf[T]

type ThisTree[-T >: Untyped] = Thicket[T]
override def isEmpty: Boolean = trees.isEmpty
override def toList: List[Tree[T]] = flatten(trees)
Expand All @@ -758,8 +759,9 @@ object Trees {

class EmptyValDef[T >: Untyped] extends ValDef[T](
nme.WILDCARD, genericEmptyTree[T], genericEmptyTree[T]) with WithoutTypeOrPos[T] {
myTpe = NoType.asInstanceOf[T]
override def isEmpty: Boolean = true
setMods(untpd.Modifiers(PrivateLocal))
setMods(untpd.Modifiers(Private | Local))
}

@sharable val theEmptyTree: Thicket[Type] = Thicket(Nil)
Expand Down
6 changes: 3 additions & 3 deletions compiler/src/dotty/tools/dotc/ast/tpd.scala
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
ta.assignType(untpd.ValDef(sym.name, TypeTree(sym.info), rhs), sym)

def SyntheticValDef(name: TermName, rhs: Tree)(implicit ctx: Context): ValDef =
ValDef(ctx.newSymbol(ctx.owner, name, Synthetic, rhs.tpe.widen, coord = rhs.pos), rhs)
ValDef(ctx.newSymbol(ctx.owner, name, Synthetic, rhs.tpe.widen, coord = rhs.coord), rhs)

def DefDef(sym: TermSymbol, tparams: List[TypeSymbol], vparamss: List[List[TermSymbol]],
resultType: Type, rhs: Tree)(implicit ctx: Context): DefDef =
Expand Down Expand Up @@ -270,7 +270,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
if (parents.head.classSymbol.is(Trait)) parents.head.parents.head :: parents
else parents
val cls = ctx.newNormalizedClassSymbol(owner, tpnme.ANON_CLASS, Synthetic, parents1,
coord = fns.map(_.pos).reduceLeft(_ union _))
coord = fns.map(_.pos).reduceLeft(_ union _).toCoord)
val constr = ctx.newConstructor(cls, Synthetic, Nil, Nil).entered
def forwarder(fn: TermSymbol, name: TermName) = {
val fwdMeth = fn.copy(cls, name, Synthetic | Method).entered.asTerm
Expand All @@ -284,7 +284,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
// { <label> def while$(): Unit = if (cond) { body; while$() } ; while$() }
def WhileDo(owner: Symbol, cond: Tree, body: List[Tree])(implicit ctx: Context): Tree = {
val sym = ctx.newSymbol(owner, nme.WHILE_PREFIX, Flags.Label | Flags.Synthetic,
MethodType(Nil, defn.UnitType), coord = cond.pos)
MethodType(Nil, defn.UnitType), coord = cond.coord)

val call = Apply(ref(sym), Nil)
val rhs = If(cond, Block(body, call), unitLiteral)
Expand Down
16 changes: 4 additions & 12 deletions compiler/src/dotty/tools/dotc/ast/untpd.scala
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
mods: List[Mod] = Nil) extends Positioned with Cloneable {

def is(fs: FlagSet): Boolean = flags is fs
def is(fc: FlagConjunction): Boolean = flags is fc
def isBoth(fc: FlagSet, and: FlagSet): Boolean = flags.isBoth(fc, and)
def is(fc: FlagSet, butNot: FlagSet): Boolean = flags.is(fc, butNot = butNot)

def | (fs: FlagSet): Modifiers = withFlags(flags | fs)
Expand Down Expand Up @@ -349,7 +349,7 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
makeConstructor(Nil, Nil)

def makeSelfDef(name: TermName, tpt: Tree)(implicit ctx: Context) =
ValDef(name, tpt, EmptyTree).withFlags(PrivateLocal)
ValDef(name, tpt, EmptyTree).withFlags(Private | Local)

def makeTupleOrParens(ts: List[Tree])(implicit ctx: Context) = ts match {
case t :: Nil => Parens(t)
Expand All @@ -365,7 +365,7 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
ValDef(pname, tpe, EmptyTree).withMods(mods | Param)

def makeSyntheticParameter(n: Int = 1, tpt: Tree = TypeTree())(implicit ctx: Context): ValDef =
ValDef(nme.syntheticParamName(n), tpt, EmptyTree).withFlags(SyntheticTermParam)
ValDef(nme.syntheticParamName(n), tpt, EmptyTree).withFlags(Synthetic | TermParam)

def lambdaAbstract(tparams: List[TypeDef], tpt: Tree)(implicit ctx: Context) =
if (tparams.isEmpty) tpt else LambdaTypeTree(tparams, tpt)
Expand All @@ -381,14 +381,6 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
/** A repeated argument such as `arg: _*` */
def repeated(arg: Tree)(implicit ctx: Context) = Typed(arg, Ident(tpnme.WILDCARD_STAR))

// ----- Accessing modifiers ----------------------------------------------------

abstract class ModsDecorator { def mods: Modifiers }

implicit class modsDeco(val mdef: MemberDef)(implicit ctx: Context) {
def mods = mdef.rawMods
}

// --------- Copier/Transformer/Accumulator classes for untyped trees -----

override val cpy: UntypedTreeCopier = new UntypedTreeCopier
Expand All @@ -400,7 +392,7 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {

def postProcess(tree: Tree, copied: MemberDef): copied.ThisTree[Untyped] = {
tree match {
case tree: MemberDef => copied.withMods(tree.rawMods)
case tree: MemberDef => copied.withMods(tree.mods)
case _ => copied
}
}.asInstanceOf[copied.ThisTree[Untyped]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ case class AggregateClassPath(aggregates: Seq[ClassPath]) extends ClassPath {
override private[dotty] def list(inPackage: String): ClassPathEntries = {
val (packages, classesAndSources) = aggregates.map { cp =>
try {
cp.list(inPackage)
cp.list(inPackage).toTuple
} catch {
case ex: java.io.IOException =>
val e = new FatalError(ex.getMessage)
Expand Down
8 changes: 2 additions & 6 deletions compiler/src/dotty/tools/dotc/classpath/ClassPath.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,8 @@ package dotty.tools.dotc.classpath
import dotty.tools.io.AbstractFile
import dotty.tools.io.ClassRepresentation

case class ClassPathEntries(packages: Seq[PackageEntry], classesAndSources: Seq[ClassRepresentation])

object ClassPathEntries {
import scala.language.implicitConversions
// to have working unzip method
implicit def entry2Tuple(entry: ClassPathEntries): (Seq[PackageEntry], Seq[ClassRepresentation]) = (entry.packages, entry.classesAndSources)
case class ClassPathEntries(packages: Seq[PackageEntry], classesAndSources: Seq[ClassRepresentation]) {
def toTuple = (packages, classesAndSources)
}

trait ClassFileEntry extends ClassRepresentation {
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/config/JavaPlatform.scala
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class JavaPlatform extends Platform {

/** Is the SAMType `cls` also a SAM under the rules of the JVM? */
def isSam(cls: ClassSymbol)(implicit ctx: Context): Boolean =
cls.is(NoInitsTrait) &&
cls.isBoth(NoInits, and = Trait) &&
cls.superClass == defn.ObjectClass &&
cls.directlyInheritedTraits.forall(_.is(NoInits)) &&
!ExplicitOuter.needsOuterIfReferenced(cls) &&
Expand Down
3 changes: 0 additions & 3 deletions compiler/src/dotty/tools/dotc/core/Contexts.scala
Original file line number Diff line number Diff line change
Expand Up @@ -685,9 +685,6 @@ object Contexts {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit LGTM

object Context {

/** Implicit conversion that injects all printer operations into a context */
implicit def toPrinter(ctx: Context): Printer = ctx.printer

/** implicit conversion that injects all ContextBase members into a context */
implicit def toBase(ctx: Context): ContextBase = ctx.base

Expand Down
9 changes: 2 additions & 7 deletions compiler/src/dotty/tools/dotc/core/Decorators.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,10 @@ import printing.Formatting._

/** This object provides useful implicit decorators for types defined elsewhere */
object Decorators {

/** Turns Strings into PreNames, adding toType/TermName methods */
implicit class PreNamedString(val s: String) extends AnyVal with PreName {
implicit class StringDecorator(val s: String) extends AnyVal {
def toTypeName: TypeName = typeName(s)
def toTermName: TermName = termName(s)
def toText(printer: Printer): Text = Str(s)
}

implicit class StringDecorator(val s: String) extends AnyVal {
def splitWhere(f: Char => Boolean, doDropIndex: Boolean): Option[(String, String)] = {
def splitAt(idx: Int, doDropIndex: Boolean): Option[(String, String)] =
if (idx == -1) None
Expand Down Expand Up @@ -165,7 +160,7 @@ object Decorators {
}
}

implicit def sourcePos(pos: Position)(implicit ctx: Context): SourcePosition = {
def sourcePos(pos: Position)(implicit ctx: Context): SourcePosition = {
def recur(inlinedCalls: List[Tree], pos: Position): SourcePosition = inlinedCalls match {
case inlinedCall :: rest =>
sourceFile(inlinedCall).atPos(pos).withOuter(recur(rest, inlinedCall.pos))
Expand Down
Loading