Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 0 additions & 1 deletion compiler/src/dotty/tools/dotc/config/ScalaSettings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ class ScalaSettings extends Settings.SettingGroup {
val YtraceContextCreation: Setting[Boolean] = BooleanSetting("-Ytrace-context-creation", "Store stack trace of context creations.")
val YshowSuppressedErrors: Setting[Boolean] = BooleanSetting("-Yshow-suppressed-errors", "Also show follow-on errors and warnings that are normally suppressed.")
val YdetailedStats: Setting[Boolean] = BooleanSetting("-Ydetailed-stats", "show detailed internal compiler stats (needs Stats.enabled to be set to true).")
val Yheartbeat: Setting[Boolean] = BooleanSetting("-Yheartbeat", "show heartbeat stack trace of compiler operations (needs Stats.enabled to be set to true).")
val YkindProjector: Setting[Boolean] = BooleanSetting("-Ykind-projector", "allow `*` as wildcard to be compatible with kind projector")
val YprintPos: Setting[Boolean] = BooleanSetting("-Yprint-pos", "show tree positions.")
val YprintPosSyms: Setting[Boolean] = BooleanSetting("-Yprint-pos-syms", "show symbol definitions positions.")
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/core/SymDenotations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1783,7 +1783,7 @@ object SymDenotations {
} else computeNPMembersNamed(name)
}

private[core] def computeNPMembersNamed(name: Name)(implicit ctx: Context): PreDenotation = /*>|>*/ Stats.track("computeNPMembersNamed") /*<|<*/ {
private[core] def computeNPMembersNamed(name: Name)(implicit ctx: Context): PreDenotation = {
Stats.record("computeNPMembersNamed after fingerprint")
ensureCompleted()
val ownDenots = info.decls.denotsNamed(name, selectNonPrivate)
Expand Down
6 changes: 4 additions & 2 deletions compiler/src/dotty/tools/dotc/core/TypeApplications.scala
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@ class TypeApplications(val self: Type) extends AnyVal {
* For a refinement type, the type parameters of its parent, dropping
* any type parameter that is-rebound by the refinement.
*/
final def typeParams(implicit ctx: Context): List[TypeParamInfo] = /*>|>*/ track("typeParams") /*<|<*/ {
final def typeParams(implicit ctx: Context): List[TypeParamInfo] = {
record("typeParams")
def isTrivial(prefix: Type, tycon: Symbol) = prefix match {
case prefix: ThisType => prefix.cls `eq` tycon.owner
case NoPrefix => true
Expand Down Expand Up @@ -353,7 +354,8 @@ class TypeApplications(val self: Type) extends AnyVal {
* @param self = `T`
* @param args = `U1,...,Un`
*/
final def appliedTo(args: List[Type])(implicit ctx: Context): Type = /*>|>*/ track("appliedTo") /*<|<*/ {
final def appliedTo(args: List[Type])(implicit ctx: Context): Type = {
record("appliedTo")
val typParams = self.typeParams
val stripped = self.stripTypeVar
val dealiased = stripped.safeDealias
Expand Down
68 changes: 45 additions & 23 deletions compiler/src/dotty/tools/dotc/core/Types.scala
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,8 @@ object Types {
* Inherited by all type proxies. Overridden for And and Or types.
* `Nil` for all other types.
*/
def baseClasses(implicit ctx: Context): List[ClassSymbol] = track("baseClasses") {
def baseClasses(implicit ctx: Context): List[ClassSymbol] = {
record("baseClasses")
this match {
case tp: TypeProxy =>
tp.underlying.baseClasses
Expand Down Expand Up @@ -501,12 +502,13 @@ object Types {
* The result is either a SymDenotation or a MultiDenotation of SymDenotations.
* The info(s) are the original symbol infos, no translation takes place.
*/
final def decl(name: Name)(implicit ctx: Context): Denotation = track("decl") {
final def decl(name: Name)(implicit ctx: Context): Denotation = {
record("decl")
findDecl(name, EmptyFlags)
}

/** A denotation containing the non-private declaration(s) in this type with the given name */
final def nonPrivateDecl(name: Name)(implicit ctx: Context): Denotation = track("nonPrivateDecl") {
final def nonPrivateDecl(name: Name)(implicit ctx: Context): Denotation = {
findDecl(name, Private)
}

Expand All @@ -526,12 +528,14 @@ object Types {
}

/** The member of this type with the given name */
final def member(name: Name)(implicit ctx: Context): Denotation = /*>|>*/ track("member") /*<|<*/ {
final def member(name: Name)(implicit ctx: Context): Denotation = /*>|>*/ {
record("member")
memberBasedOnFlags(name, required = EmptyFlags, excluded = EmptyFlags)
}

/** The non-private member of this type with the given name. */
final def nonPrivateMember(name: Name)(implicit ctx: Context): Denotation = track("nonPrivateMember") {
final def nonPrivateMember(name: Name)(implicit ctx: Context): Denotation = {
record("nonPrivateMember")
memberBasedOnFlags(name, required = EmptyFlags, excluded = Flags.Private)
}

Expand Down Expand Up @@ -759,31 +763,36 @@ object Types {
}

/** The set of abstract term members of this type. */
final def abstractTermMembers(implicit ctx: Context): Seq[SingleDenotation] = track("abstractTermMembers") {
final def abstractTermMembers(implicit ctx: Context): Seq[SingleDenotation] = {
record("abstractTermMembers")
memberDenots(abstractTermNameFilter,
(name, buf) => buf ++= nonPrivateMember(name).altsWith(_.is(Deferred)))
}

/** The set of abstract type members of this type. */
final def abstractTypeMembers(implicit ctx: Context): Seq[SingleDenotation] = track("abstractTypeMembers") {
final def abstractTypeMembers(implicit ctx: Context): Seq[SingleDenotation] = {
record("abstractTypeMembers")
memberDenots(abstractTypeNameFilter,
(name, buf) => buf += nonPrivateMember(name).asSingleDenotation)
}

/** The set of abstract type members of this type. */
final def nonClassTypeMembers(implicit ctx: Context): Seq[SingleDenotation] = track("nonClassTypeMembers") {
final def nonClassTypeMembers(implicit ctx: Context): Seq[SingleDenotation] = {
record("nonClassTypeMembers")
memberDenots(nonClassTypeNameFilter,
(name, buf) => buf += member(name).asSingleDenotation)
}

/** The set of type alias members of this type */
final def typeAliasMembers(implicit ctx: Context): Seq[SingleDenotation] = track("typeAlias") {
final def typeAliasMembers(implicit ctx: Context): Seq[SingleDenotation] = {
record("typeAliasMembers")
memberDenots(typeAliasNameFilter,
(name, buf) => buf += member(name).asSingleDenotation)
}

/** The set of type members of this type */
final def typeMembers(implicit ctx: Context): Seq[SingleDenotation] = track("typeMembers") {
final def typeMembers(implicit ctx: Context): Seq[SingleDenotation] = {
record("typeMembers")
memberDenots(typeNameFilter,
(name, buf) => buf += member(name).asSingleDenotation)
}
Expand All @@ -792,31 +801,36 @@ object Types {
* @param kind A subset of {Implicit, Given} that specifies what kind of implicit should
* be returned
*/
final def implicitMembers(kind: FlagSet)(implicit ctx: Context): List[TermRef] = track("implicitMembers") {
final def implicitMembers(kind: FlagSet)(implicit ctx: Context): List[TermRef] = {
record("implicitMembers")
memberDenots(implicitFilter,
(name, buf) => buf ++= member(name).altsWith(_.isOneOf(GivenOrImplicitVal & kind)))
.toList.map(d => TermRef(this, d.symbol.asTerm))
}

/** The set of member classes of this type */
final def memberClasses(implicit ctx: Context): Seq[SingleDenotation] = track("memberClasses") {
final def memberClasses(implicit ctx: Context): Seq[SingleDenotation] = {
record("memberClasses")
memberDenots(typeNameFilter,
(name, buf) => buf ++= member(name).altsWith(x => x.isClass))
}

final def fields(implicit ctx: Context): Seq[SingleDenotation] = track("fields") {
final def fields(implicit ctx: Context): Seq[SingleDenotation] = {
record("fields")
memberDenots(fieldFilter,
(name, buf) => buf ++= member(name).altsWith(x => !x.is(Method)))
}

/** The set of members of this type that have all of `required` flags but none of `excluded` flags set. */
final def membersBasedOnFlags(required: FlagSet, excluded: FlagSet)(implicit ctx: Context): Seq[SingleDenotation] = track("membersBasedOnFlags") {
final def membersBasedOnFlags(required: FlagSet, excluded: FlagSet)(implicit ctx: Context): Seq[SingleDenotation] = {
record("membersBasedOnFlags")
memberDenots(takeAllFilter,
(name, buf) => buf ++= memberBasedOnFlags(name, required, excluded).alternatives)
}

/** All members of this type. Warning: this can be expensive to compute! */
final def allMembers(implicit ctx: Context): Seq[SingleDenotation] = track("allMembers") {
final def allMembers(implicit ctx: Context): Seq[SingleDenotation] = {
record("allMembers")
memberDenots(takeAllFilter, (name, buf) => buf ++= member(name).alternatives)
}

Expand All @@ -827,27 +841,31 @@ object Types {
/** This type seen as if it were the type of a member of prefix type `pre`
* declared in class `cls`.
*/
final def asSeenFrom(pre: Type, cls: Symbol)(implicit ctx: Context): Type = track("asSeenFrom") {
final def asSeenFrom(pre: Type, cls: Symbol)(implicit ctx: Context): Type = {
record("asSeenFrom")
if (!cls.membersNeedAsSeenFrom(pre)) this
else ctx.asSeenFrom(this, pre, cls)
}

// ----- Subtype-related --------------------------------------------

/** Is this type a subtype of that type? */
final def <:<(that: Type)(implicit ctx: Context): Boolean = track("<:<") {
final def <:<(that: Type)(implicit ctx: Context): Boolean = {
record("<:<")
ctx.typeComparer.topLevelSubType(this, that)
}

/** Is this type a subtype of that type? */
final def frozen_<:<(that: Type)(implicit ctx: Context): Boolean = track("frozen_<:<") {
final def frozen_<:<(that: Type)(implicit ctx: Context): Boolean = {
record("frozen_<:<")
ctx.typeComparer.isSubTypeWhenFrozen(this, that)
}

/** Is this type the same as that type?
* This is the case iff `this <:< that` and `that <:< this`.
*/
final def =:=(that: Type)(implicit ctx: Context): Boolean = track("=:=") {
final def =:=(that: Type)(implicit ctx: Context): Boolean = {
record("=:=")
ctx.typeComparer.isSameType(this, that)
}

Expand Down Expand Up @@ -905,7 +923,8 @@ object Types {
* (*) when matching with a Java method, we also regard Any and Object as equivalent
* parameter types.
*/
def matches(that: Type)(implicit ctx: Context): Boolean = track("matches") {
def matches(that: Type)(implicit ctx: Context): Boolean = {
record("matches")
ctx.typeComparer.matchesType(this, that, relaxed = !ctx.phase.erasedTypes)
}

Expand All @@ -920,14 +939,16 @@ object Types {
}

/** The basetype of this type with given class symbol, NoType if `base` is not a class. */
final def baseType(base: Symbol)(implicit ctx: Context): Type = /*trace(s"$this baseType $base")*/ /*>|>*/ track("base type") /*<|<*/ {
final def baseType(base: Symbol)(implicit ctx: Context): Type = {
record("baseType")
base.denot match {
case classd: ClassDenotation => classd.baseTypeOf(this)
case _ => NoType
}
}

def & (that: Type)(implicit ctx: Context): Type = track("&") {
def & (that: Type)(implicit ctx: Context): Type = {
record("&")
ctx.typeComparer.glb(this, that)
}

Expand Down Expand Up @@ -956,7 +977,8 @@ object Types {
// superclass.
}

def | (that: Type)(implicit ctx: Context): Type = track("|") {
def | (that: Type)(implicit ctx: Context): Type = {
record("|")
ctx.typeComparer.lub(this, that)
}

Expand Down
26 changes: 15 additions & 11 deletions compiler/src/dotty/tools/dotc/typer/Applications.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package typer
import core._
import ast.{Trees, tpd, untpd}
import util.Spans._
import util.Stats.{track, record}
import util.Stats.record
import util.{SourcePosition, NoSourcePosition, SourceFile}
import Trees.Untyped
import Contexts._
Expand Down Expand Up @@ -805,7 +805,7 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
*/
def typedApply(tree: untpd.Apply, pt: Type)(implicit ctx: Context): Tree = {

def realApply(implicit ctx: Context): Tree = track("realApply") {
def realApply(implicit ctx: Context): Tree = {
val originalProto = new FunProto(tree.args, IgnoredProto(pt))(this, tree.isGivenApply)(argCtx(tree))
record("typedApply")
val fun1 = typedFunPart(tree.fun, originalProto)
Expand Down Expand Up @@ -888,7 +888,7 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
*
* { val xs = es; e' = e' + args }
*/
def typedOpAssign(implicit ctx: Context): Tree = track("typedOpAssign") {
def typedOpAssign(implicit ctx: Context): Tree = {
val Apply(Select(lhs, name), rhss) = tree
val lhs1 = typedExpr(lhs)
val liftedDefs = new mutable.ListBuffer[Tree]
Expand Down Expand Up @@ -939,7 +939,7 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
cpy.NamedArg(arg)(id, argtpt1).withType(argtpt1.tpe)
}

def typedTypeApply(tree: untpd.TypeApply, pt: Type)(implicit ctx: Context): Tree = track("typedTypeApply") {
def typedTypeApply(tree: untpd.TypeApply, pt: Type)(implicit ctx: Context): Tree = {
if (ctx.mode.is(Mode.Pattern)) {
return errorTree(tree, "invalid pattern")
}
Expand Down Expand Up @@ -992,7 +992,8 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
tree
}

def typedUnApply(tree: untpd.Apply, selType: Type)(implicit ctx: Context): Tree = track("typedUnApply") {
def typedUnApply(tree: untpd.Apply, selType: Type)(implicit ctx: Context): Tree = {
record("typedUnApply")
val Apply(qual, args) = tree

def notAnExtractor(tree: Tree) =
Expand Down Expand Up @@ -1239,8 +1240,8 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
* an alternative that takes more implicit parameters wins over one
* that takes fewer.
*/
def compare(alt1: TermRef, alt2: TermRef)(implicit ctx: Context): Int = track("compare") { trace(i"compare($alt1, $alt2)", overload) {

def compare(alt1: TermRef, alt2: TermRef)(implicit ctx: Context): Int = trace(i"compare($alt1, $alt2)", overload) {
record("compare")
assert(alt1 ne alt2)

/** Is alternative `alt1` with type `tp1` as specific as alternative
Expand Down Expand Up @@ -1412,9 +1413,10 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
else 1 // prefer 1st alternative with no implicits
else if (strippedType2 eq fullType2) -1 // prefer 2nd alternative with no implicits
else compareWithTypes(fullType1, fullType2) // continue by comparing implicits parameters
}}
}

def narrowMostSpecific(alts: List[TermRef])(implicit ctx: Context): List[TermRef] = track("narrowMostSpecific") {
def narrowMostSpecific(alts: List[TermRef])(implicit ctx: Context): List[TermRef] = {
record("narrowMostSpecific")
alts match {
case Nil => alts
case _ :: Nil => alts
Expand Down Expand Up @@ -1451,7 +1453,8 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
* Two trials: First, without implicits or SAM conversions enabled. Then,
* if the first finds no eligible candidates, with implicits and SAM conversions enabled.
*/
def resolveOverloaded(alts: List[TermRef], pt: Type)(implicit ctx: Context): List[TermRef] = track("resolveOverloaded") {
def resolveOverloaded(alts: List[TermRef], pt: Type)(implicit ctx: Context): List[TermRef] = {
record("resolveOverloaded")

/** Is `alt` a method or polytype whose result type after the first value parameter
* section conforms to the expected type `resultType`? If `resultType`
Expand Down Expand Up @@ -1547,7 +1550,8 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
* called twice from the public `resolveOverloaded` method, once with
* implicits and SAM conversions enabled, and once without.
*/
private def resolveOverloaded(alts: List[TermRef], pt: Type, targs: List[Type])(implicit ctx: Context): List[TermRef] = track("resolveOverloaded") {
private def resolveOverloaded(alts: List[TermRef], pt: Type, targs: List[Type])(implicit ctx: Context): List[TermRef] = {
record("resolveOverloaded/2")

def isDetermined(alts: List[TermRef]) = alts.isEmpty || alts.tail.isEmpty

Expand Down
Loading