Skip to content

Normalize TypeOf types (second step towards typed transparent methods) #4806

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
wants to merge 128 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
128 commits
Select commit Hold shift + click to select a range
1fa329a
Add `TypeOf` type representation and corresponding case in `TypeMap`
gsps Jun 6, 2018
cad6a10
Add TypeOfTypeTree and update Parser accordingly
OlivierBlanvillain Jun 6, 2018
42eed69
Merge TypeOfTypeTree and SingletonTypeTree
gsps Jun 13, 2018
d61e3ed
Handle TypeOf in pickler
OlivierBlanvillain Jun 6, 2018
bbdbfb5
Handle TypeOf in TypeAssigner
OlivierBlanvillain Jun 13, 2018
75ace99
Add structural equality for `TypeOf`s
gsps Jun 13, 2018
d188933
Add missing case in sameTree
OlivierBlanvillain Jun 12, 2018
9767a70
Detect transparency when typing if and match
OlivierBlanvillain Jun 13, 2018
649aa98
Make TypeOf a subclass of AnnotatedType
OlivierBlanvillain Jun 13, 2018
e55c92f
Override derivedAnnotatedType
OlivierBlanvillain Jun 13, 2018
d3161ef
Swap tree and underlying in TypeOf to match Annot
OlivierBlanvillain Jun 13, 2018
91c72bf
Decompose precise protos during typing
OlivierBlanvillain Jun 13, 2018
8a9e6a1
Avoid infinite loop when printing TypeOf
gsps Jun 13, 2018
116e9bd
Also decompose proto for matches
OlivierBlanvillain Jun 13, 2018
82c3dea
Add tests
OlivierBlanvillain Jun 13, 2018
f3c9235
Implement `derivedTypeOf` in `ApproximatingTypeMap`
gsps Jun 13, 2018
2d4a926
fixup! Avoid infinite loop when printing TypeOf
OlivierBlanvillain Jun 13, 2018
6289f21
TypeOf shouldn't be handled by AnnotatedType logic
OlivierBlanvillain Jun 13, 2018
93fa77a
fixup! Avoid infinite loop when printing TypeOf
OlivierBlanvillain Jun 13, 2018
32d9858
Update TypeMap to use assignTypes
OlivierBlanvillain Jun 13, 2018
3f9d6e6
Fix `TypeMap` and implement `TypeAccumulator` for `TypeOf`
gsps Jun 14, 2018
fed6013
Fix pretty printing of `TypeOf`
gsps Jun 14, 2018
367a44a
Fix `isInTypeOf` state used for pretty printing `TypeOf`s
gsps Jun 14, 2018
a395742
Add orphan check for underlying types of `TypeOf`s
gsps Jun 14, 2018
84cc5bf
Fix pretty printing of `TypeOf`s to reveal types, not trees (which mi…
gsps Jun 14, 2018
705f864
WIP Fixing duplicate TypeOf
gsps Jun 14, 2018
169fa74
Change trees in TypeOf to never loop back to their TypeOf
gsps Jun 14, 2018
43d4d74
Remove TypeOf.fromUntyped
OlivierBlanvillain Jun 15, 2018
a2ebbc4
Create TypeOfAnnot in .pply to prevent ctx capture
OlivierBlanvillain Jun 15, 2018
1198a86
Factor TypeOf and Tree printers
OlivierBlanvillain Jun 15, 2018
004a69c
Minor comment updates
OlivierBlanvillain Jun 15, 2018
4fb78f3
Remove derivedTypeOf as it's never used
OlivierBlanvillain Jun 15, 2018
f200e00
Document TypeOf class
OlivierBlanvillain Jun 15, 2018
bfbfadd
Remove non-sensical example in TypeMap documentation
gsps Jun 15, 2018
f5539bf
Add missing This and Super in assignType(SingletonTypeTree)
OlivierBlanvillain Jun 15, 2018
27b1690
Fix name clash betwen TypeOf and dotty.tools.repl.TypeOf
OlivierBlanvillain Jun 15, 2018
ccd01f8
WIP Add NormalizeMap
gsps Jun 18, 2018
b04b652
Implement TypeOf.Call.unapply and TypeOf.*.derived
OlivierBlanvillain Jun 19, 2018
ff89e96
Fix TypeOf.*.derived by reintroducing the mapConserves
OlivierBlanvillain Jun 19, 2018
987d1e9
Add -Xmax-type-evaluation-steps
OlivierBlanvillain Jun 20, 2018
265941b
Rename tests/disabled/*/Symbols.scala
OlivierBlanvillain Jun 21, 2018
818c501
WIP add transparent mode
OlivierBlanvillain Jun 21, 2018
eed7f5f
Add isTransparentContext
gsps Jun 22, 2018
5cd488b
Fix TypeOf not being widened and return type inference widening when …
gsps Jun 22, 2018
72d94e1
Fix spurious TypeVars showing up during Ychecks
gsps Jun 22, 2018
5a36beb
Fix unstable SingletonTypeTrees not passing PostTyper because of real…
gsps Jun 22, 2018
3b0997e
Normalize eagerly in non-transparent contexts
gsps Jun 27, 2018
f89c8cd
Fix widen not continuing to widen after stripping one TypeOf
gsps Jun 29, 2018
944671b
Disable eager normalization of types assigned to `Select` and `Ident`Fix
gsps Jun 29, 2018
8506c7c
Don't try to widen selections during avoidance in transparent contexts
gsps Jul 4, 2018
09c8cc9
Migrate TypeOf away from being a subclass of AnnotatedType
gsps Jul 4, 2018
a0d15e9
Implement TypeOf.computeHash and add caching
OlivierBlanvillain Jul 4, 2018
cb25777
Enable constant folding during normalization
gsps Jul 4, 2018
b1c1678
Add more Nat tests
gsps Jul 4, 2018
f4328b5
Fix unfolding in the middle of calls
OlivierBlanvillain Jul 4, 2018
13e2c2b
Use structural equality as `eql` of TypeOf
gsps Jul 6, 2018
f6b4e6e
Add missing "// error" marker in negative test transparent-match.scala
gsps Jul 6, 2018
812e863
Replace structural equality test in type comparison of TypeOf by subt…
gsps Jul 6, 2018
c336dc2
Undo prior workarounds for Ychecks
gsps Jul 6, 2018
c4f0408
Avoid normalization in the presence of Null
gsps Jul 6, 2018
66051de
Rearrange unapplys in TypeOf companion
gsps Jul 6, 2018
4b224ad
Normalize during type comparison and compare TypeOfs pointwise (ie. a…
gsps Jul 6, 2018
4a41e08
Rename `Type#stripPoly` to `stripMethodPrefix`, since it also strips …
gsps Jul 9, 2018
da017bb
Fix erasure of Apply not widening TypeOf (stemming from partial appli…
gsps Jul 9, 2018
222a992
Fix FullParameterization forwarders not widening TypeOf to discover M…
gsps Jul 9, 2018
693fa1a
Fix TailRec label def not being typed in context with incorrect owner
gsps Jul 9, 2018
c73229b
Fix TreeChecker running after TailRec not performing avoidance (thoug…
gsps Jul 9, 2018
a5d847b
Support term parameter selection and make companion applys transparent
gsps Jul 9, 2018
690dbb5
Fix TypeOf.New unapply in the presence of TypeApply
OlivierBlanvillain Jul 10, 2018
67d42ab
Add list concat example
OlivierBlanvillain Jul 10, 2018
576ea6d
Pretty print new in TypeOfs
OlivierBlanvillain Jul 12, 2018
05e9d74
Fix bug in TypeOf of new
OlivierBlanvillain Jul 13, 2018
47bed6e
Document what we want to do cycles
OlivierBlanvillain Jul 13, 2018
2e785fd
Add test case inspired from Idris stdlib
OlivierBlanvillain Jul 13, 2018
a4a24e5
Add cached `isTransparent` on Context
gsps Jul 17, 2018
ff0a5ef
Add transparent-patterns.scala test case
OlivierBlanvillain Jul 16, 2018
db60917
Move neg test testing singleton stability to pos
OlivierBlanvillain Jul 17, 2018
1383220
Fix isParameterless
OlivierBlanvillain Jul 17, 2018
5841876
Fix picking of TypeOf to only pickle types
OlivierBlanvillain Jul 17, 2018
eab3b78
Fix pretty printing of TypeOf(new): show typeargs
OlivierBlanvillain Jul 18, 2018
a309a8e
Don't normalize during typing
OlivierBlanvillain Jul 18, 2018
0573dc7
Merge branch 'master' into add-transparent-6
OlivierBlanvillain Jul 31, 2018
9d5d4c3
s/transparent/dependent/g
OlivierBlanvillain Jul 31, 2018
8056dbb
Rename transparent tests to dependent
OlivierBlanvillain Jul 31, 2018
12d8ae2
Fix bug introduced while merging
OlivierBlanvillain Jul 31, 2018
81a6b78
Finish merging (patmat TODO + keyword range)
OlivierBlanvillain Jul 31, 2018
5a517a1
Normalize when looking at underlying of ProxyTypes
OlivierBlanvillain Aug 2, 2018
3a42ac2
Revert "Don't normalize during typing"
OlivierBlanvillain Aug 2, 2018
70bb3f8
Comment out dependent-patterns test
OlivierBlanvillain Aug 2, 2018
c9ab046
Fix name clash with new dependent keyword
OlivierBlanvillain Aug 2, 2018
bd1c9ba
Revert ensureNoLocalRefs in TreeChecker
OlivierBlanvillain Aug 2, 2018
ac6e776
Ignore TypeOf during subtype-checking after Pickler
OlivierBlanvillain Aug 2, 2018
3b5ba97
Merge branch 'master' into add-transparent-6
OlivierBlanvillain Aug 2, 2018
ee5a398
Workaround issue with termref in java patmat
OlivierBlanvillain Aug 2, 2018
1d193ba
Require dependent mod on case classes
OlivierBlanvillain Aug 2, 2018
4b1a0c0
Rename dependent to dependentFlag
OlivierBlanvillain Aug 2, 2018
609776e
Skip over PreprareInline for Dependent
OlivierBlanvillain Aug 3, 2018
aca471c
Partially fix pickling/unpickling
OlivierBlanvillain Aug 3, 2018
aa46b0b
Fix the scope of `dependent class`
OlivierBlanvillain Aug 3, 2018
5d5e812
Make state in Normalize @sharable
OlivierBlanvillain Aug 6, 2018
6a2c9cb
Fix owner in TailRec
OlivierBlanvillain Aug 7, 2018
bc75da2
Pickle TypeOf with richTypes = true
OlivierBlanvillain Aug 7, 2018
0717959
Do not inherit isDependent when entering class ctx
OlivierBlanvillain Aug 7, 2018
acd6a57
Change pickling of TypeOf to use Trees
OlivierBlanvillain Aug 7, 2018
f123449
Merge branch 'master' into add-transparent-6
OlivierBlanvillain Aug 7, 2018
e58a69d
Workaround missing case in TASTY show source code
OlivierBlanvillain Aug 22, 2018
7859aaa
Fix TypeOf pickling
OlivierBlanvillain Aug 22, 2018
80f0f2d
Blacklist dependent5, failure is unrelated
OlivierBlanvillain Aug 22, 2018
9651d10
Merge branch 'master' into add-transparent-6
OlivierBlanvillain Aug 22, 2018
c36433e
Add default case to TypeOf unpickler
OlivierBlanvillain Aug 22, 2018
cbfe46d
Merge branch 'master' into add-transparent-6
OlivierBlanvillain Aug 23, 2018
caf62de
Do not normalizedType in the default code path
OlivierBlanvillain Aug 23, 2018
bad332e
Add back default case in readLengthTerm
OlivierBlanvillain Aug 23, 2018
2b0fb5b
-Ytest-pickler new dependent tests
OlivierBlanvillain Aug 23, 2018
686ff5d
Update collection-strawman to master version
OlivierBlanvillain Aug 23, 2018
3bf80c9
Compute isDependent by looking at owners instead
OlivierBlanvillain Aug 23, 2018
4fa9403
Retract InTypeOf correctly during unpickling
OlivierBlanvillain Aug 24, 2018
fc20007
Trigger CI
OlivierBlanvillain Aug 24, 2018
de99124
Make inner loop of TypeOf#eql tailrec
OlivierBlanvillain Aug 27, 2018
1bfda73
Cache normalized types
OlivierBlanvillain Aug 27, 2018
99b39b9
More 2s
OlivierBlanvillain Aug 27, 2018
1faa331
Make myNormalized @sharable
OlivierBlanvillain Aug 27, 2018
a6fcf22
Georg says caching is a good idea
OlivierBlanvillain Aug 28, 2018
b0fca2f
Merge branch 'master' into add-transparent-6
OlivierBlanvillain Aug 28, 2018
c41b5f3
Fix merge oversight in PrepareInlineable
OlivierBlanvillain Aug 28, 2018
5ce9a06
Make it @sharable
OlivierBlanvillain Aug 28, 2018
988ff0c
Account for canReduce in NormalizeMap.apply
OlivierBlanvillain Aug 29, 2018
251a684
Comment out patterns
OlivierBlanvillain Aug 29, 2018
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
7 changes: 4 additions & 3 deletions compiler/src/dotty/tools/dotc/ast/Desugar.scala
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ object desugar {
val isEnum = mods.isEnumClass && !mods.is(Module)
def isEnumCase = mods.isEnumCase
val isValueClass = parents.nonEmpty && isAnyVal(parents.head)
val dependentFlag = if (mods.is(Dependent)) Dependent else EmptyFlags
// This is not watertight, but `extends AnyVal` will be replaced by `inline` later.

val originalTparams = constr1.tparams
Expand Down Expand Up @@ -423,7 +424,7 @@ object desugar {
// two errors without @uncheckedVariance, one of them spurious.
val caseClassMeths = {
def syntheticProperty(name: TermName, rhs: Tree) =
DefDef(name, Nil, Nil, TypeTree(), rhs).withMods(synthetic)
DefDef(name, Nil, Nil, TypeTree(), rhs).withMods(synthetic | dependentFlag)
def productElemMeths = {
val caseParams = constrVparamss.head.toArray
for (i <- 0 until arity if nme.selectorName(i) `ne` caseParams(i).name)
Expand Down Expand Up @@ -553,12 +554,12 @@ object desugar {
if (mods is Abstract) Nil
else
DefDef(nme.apply, derivedTparams, derivedVparamss, applyResultTpt, widenedCreatorExpr)
.withFlags(Synthetic | (constr1.mods.flags & DefaultParameterized)) :: widenDefs
.withFlags(Synthetic | dependentFlag | (constr1.mods.flags & DefaultParameterized)) :: widenDefs
val unapplyMeth = {
val unapplyParam = makeSyntheticParameter(tpt = classTypeRef)
val unapplyRHS = if (arity == 0) Literal(Constant(true)) else Ident(unapplyParam.name)
DefDef(nme.unapply, derivedTparams, (unapplyParam :: Nil) :: Nil, TypeTree(), unapplyRHS)
.withMods(synthetic)
.withMods(synthetic | dependentFlag)
}
companionDefs(companionParent, applyMeths ::: unapplyMeth :: companionMembers)
}
Expand Down
7 changes: 4 additions & 3 deletions compiler/src/dotty/tools/dotc/ast/Trees.scala
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,9 @@ object Trees {
case y: List[_] => x.corresponds(y)(isSame)
case _ => false
}
case x: Constant => x == y
case _ =>
false
throw new AssertionError(s"Unexpected Tree in Tree comparison $x (comparing to $y)")
}
}
this.getClass == that.getClass && {
Expand Down Expand Up @@ -623,7 +624,7 @@ object Trees {
*/
class TypeVarBinder[-T >: Untyped] extends TypeTree[T]

/** ref.type */
/** ref.type or { ref } */
case class SingletonTypeTree[-T >: Untyped] private[ast] (ref: Tree[T])
extends DenotingTree[T] with TypTree[T] {
type ThisTree[-T >: Untyped] = SingletonTypeTree[T]
Expand Down Expand Up @@ -1243,7 +1244,7 @@ object Trees {
case TypeTree() =>
tree
case SingletonTypeTree(ref) =>
cpy.SingletonTypeTree(tree)(transform(ref))
cpy.SingletonTypeTree(tree)(transform(ref)(ctx.enterTypeOf()))
case AndTypeTree(left, right) =>
cpy.AndTypeTree(tree)(transform(left), transform(right))
case OrTypeTree(left, right) =>
Expand Down
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/dotc/ast/tpd.scala
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
override def If(tree: Tree)(cond: Tree, thenp: Tree, elsep: Tree)(implicit ctx: Context): If = {
val tree1 = untpd.cpy.If(tree)(cond, thenp, elsep)
tree match {
case tree: If if (thenp.tpe eq tree.thenp.tpe) && (elsep.tpe eq tree.elsep.tpe) => tree1.withTypeUnchecked(tree.tpe)
case tree: If if (cond.tpe eq tree.cond.tpe) && (thenp.tpe eq tree.thenp.tpe) && (elsep.tpe eq tree.elsep.tpe) => tree1.withTypeUnchecked(tree.tpe)
case _ => ta.assignType(tree1, thenp, elsep)
}
}
Expand All @@ -587,7 +587,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
override def Match(tree: Tree)(selector: Tree, cases: List[CaseDef])(implicit ctx: Context): Match = {
val tree1 = untpd.cpy.Match(tree)(selector, cases)
tree match {
case tree: Match if sameTypes(cases, tree.cases) => tree1.withTypeUnchecked(tree.tpe)
case tree: Match if (selector.tpe eq tree.selector.tpe) && sameTypes(cases, tree.cases) => tree1.withTypeUnchecked(tree.tpe)
case _ => ta.assignType(tree1, cases)
}
}
Expand Down
2 changes: 2 additions & 0 deletions compiler/src/dotty/tools/dotc/ast/untpd.scala
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
case class Transparent() extends Mod(Flags.Transparent)

case class Enum() extends Mod(Flags.Enum)

case class Dependent() extends Mod(Flags.Dependent)
}

/** Modifiers and annotations for definitions
Expand Down
1 change: 1 addition & 0 deletions compiler/src/dotty/tools/dotc/config/Config.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ object Config {
final val cacheAsSeenFrom = true
final val cacheMemberNames = true
final val cacheImplicitScopes = true
final val cacheNormalizedTypes = true

final val checkCacheMembersNamed = false

Expand Down
3 changes: 2 additions & 1 deletion compiler/src/dotty/tools/dotc/config/ScalaSettings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ class ScalaSettings extends Settings.SettingGroup {

val YnoDecodeStacktraces = BooleanSetting("-Yno-decode-stacktraces", "Show raw StackOverflow stacktraces, instead of decoding them into triggering operations.")

val YtypeNormalizationFuel = IntSetting("-Ytype-normalization-fuel", "Maximal number of steps when evaluating type expressions.", 2222222)

/** Dottydoc specific settings */
val siteRoot = StringSetting(
"-siteroot",
Expand All @@ -154,7 +156,6 @@ class ScalaSettings extends Settings.SettingGroup {
sys.props("user.dir")
)


val projectName = StringSetting (
"-project",
"project title",
Expand Down
8 changes: 6 additions & 2 deletions compiler/src/dotty/tools/dotc/core/Annotations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ object Annotations {
for (ConstantType(c) <- argument(i) map (_.tpe)) yield c

def isEvaluated: Boolean = true
def isEvaluating: Boolean = false

def ensureCompleted(implicit ctx: Context): Unit = tree

Expand Down Expand Up @@ -85,6 +86,7 @@ object Annotations {
myBody
}
override def isEvaluated = evaluated
override def isEvaluating = evaluated && myBody == null
}

object Annotation {
Expand Down Expand Up @@ -170,8 +172,10 @@ object Annotations {

def unapply(ann: Annotation)(implicit ctx: Context): Option[Symbol] =
if (ann.symbol == defn.ChildAnnot) {
val AppliedType(tycon, (arg: NamedType) :: Nil) = ann.tree.tpe
Some(arg.symbol)
ann.tree.tpe match { // TODO: proper fix
case AppliedType(tycon, (arg: NamedType) :: Nil) => Some(arg.symbol)
case _ => None
}
}
else None
}
Expand Down
40 changes: 40 additions & 0 deletions compiler/src/dotty/tools/dotc/core/Contexts.scala
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ object Contexts {
protected def owner_=(owner: Symbol) = _owner = owner
def owner: Symbol = _owner

/** The owner at the point of entering TypeOf (for SingletonTypeTrees) */
private[this] var _inTypeOfOwner: Symbol = _
protected def inTypeOfOwner_=(owner: Symbol) = _inTypeOfOwner = owner
def inTypeOfOwner: Symbol = _inTypeOfOwner

/** The current tree */
private[this] var _tree: Tree[_ >: Untyped]= _
protected def tree_=(tree: Tree[_ >: Untyped]) = _tree = tree
Expand Down Expand Up @@ -162,6 +167,32 @@ object Contexts {
_typeComparer
}

/** Is this context dependent? */
private[this] var _dependentInit: Boolean = true // NOTE: This initial value only applies to InitialContext
private[this] var _dependent: Boolean = false
final def isDependent: Boolean = {
def isDepOwner(owner: Symbol): Boolean =
if ((owner eq NoSymbol) || owner.isClass) false
else if (owner.flagsUNSAFE.is(Flags.Dependent)) true
else isDepOwner(owner.owner)

/** NOTE: The initialization of `_dependent` is rather tricky: We do need to make sure that any
* enclosing context's `_dependent` has been computed, since the property is inherited. In case the
* outer's `dependent` has been accessed before, we inherit the value by way of clone() in fresh(),
* (and as a result `_dependentInit` will be true as well).
* Otherwise we force the enclosing context's `_dependent` here, and, if the outer turns out not to be
* dependent, we finally also compute `_dependent` based on this context.
*/
if (!_dependentInit) {
_dependent = this.isInTypeOf || isDepOwner(this.owner)
_dependentInit = true
}
_dependent
}

final def isInTypeOf: Boolean =
this.inTypeOfOwner == this.owner

/** A map in which more contextual properties can be stored
* Typically used for attributes that are read and written only in special situations.
*/
Expand Down Expand Up @@ -411,6 +442,9 @@ object Contexts {
this.phasedCtxs = null
// See comment related to `creationTrace` in this file
// setCreationTrace()
// The _dependent member was cloned, but is monotonic anyways, so we *could* only recompute in case
// _dependentInit is false, but it turns out that branching here is very costly.
this._dependentInit = false
this
}

Expand Down Expand Up @@ -475,6 +509,7 @@ object Contexts {
def setPeriod(period: Period): this.type = { this.period = period; this }
def setMode(mode: Mode): this.type = { this.mode = mode; this }
def setOwner(owner: Symbol): this.type = { assert(owner != NoSymbol); this.owner = owner; this }
def enterTypeOf(): this.type = { assert(this.owner != NoSymbol); this.inTypeOfOwner = this.owner; this }
def setTree(tree: Tree[_ >: Untyped]): this.type = { this.tree = tree; this }
def setScope(scope: Scope): this.type = { this.scope = scope; this }
def setNewScope: this.type = { this.scope = newScope; this }
Expand Down Expand Up @@ -539,6 +574,8 @@ object Contexts {
final def addMode(mode: Mode): Context = withModeBits(c.mode | mode)
final def maskMode(mode: Mode): Context = withModeBits(c.mode & mode)
final def retractMode(mode: Mode): Context = withModeBits(c.mode &~ mode)

final def enterTypeOf(): Context = if (c.isInTypeOf) c else c.fresh.enterTypeOf()
}

implicit class FreshModeChanges(val c: FreshContext) extends AnyVal {
Expand Down Expand Up @@ -613,6 +650,7 @@ object Contexts {
def initialize()(implicit ctx: Context): Unit = {
_platform = newPlatform
definitions.init()
typeNormalizationFuel = settings.YtypeNormalizationFuel.value
}

def squashed(p: Phase): Phase = {
Expand Down Expand Up @@ -712,6 +750,8 @@ object Contexts {
def checkSingleThreaded() =
if (thread == null) thread = Thread.currentThread()
else assert(thread == Thread.currentThread(), "illegal multithreaded access to ContextBase")

private[dotc] var typeNormalizationFuel: Int = 0
}

class GADTMap(initBounds: SimpleIdentityMap[Symbol, TypeBounds]) {
Expand Down
17 changes: 13 additions & 4 deletions compiler/src/dotty/tools/dotc/core/Flags.scala
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,9 @@ object Flags {
/** Labeled with `erased` modifier (erased value) */
final val Erased = termFlag(42, "erased")

/** Labelled with `dependent` modifier */
final val Dependent = commonFlag(43, "dependent")

// Flags following this one are not pickled

/** Symbol is not a member of its owner */
Expand Down Expand Up @@ -436,7 +439,7 @@ object Flags {

/** Flags representing source modifiers */
final val SourceModifierFlags =
commonFlags(Private, Protected, Abstract, Final, Rewrite | Transparent,
commonFlags(Private, Protected, Abstract, Final, Rewrite | Transparent, Dependent,
Sealed, Case, Implicit, Override, AbsOverride, Lazy, JavaStatic, Erased)

/** Flags representing modifiers that can appear in trees */
Expand All @@ -457,7 +460,7 @@ object Flags {
Scala2ExistentialCommon | Mutable.toCommonFlags | Touched | JavaStatic |
CovariantOrOuter | ContravariantOrLabel | CaseAccessor.toCommonFlags |
NonMember | ImplicitCommon | Permanent | Synthetic |
SuperAccessorOrScala2x | Rewrite | Transparent
SuperAccessorOrScala2x | Rewrite | Transparent | Dependent

/** Flags that are not (re)set when completing the denotation, or, if symbol is
* a top-level class or object, when completing the denotation once the class
Expand Down Expand Up @@ -551,8 +554,8 @@ object Flags {
/** Assumed to be pure */
final val StableOrErased = Stable | Erased

/** Labeled `private`, `final`, `rewrite` or `transparent` */
final val EffectivelyFinal = Private | Final | Rewrite | Transparent
/** Labeled `private`, `final`, or `transparent` */
final val EffectivelyFinal = Private | Final | Rewrite | Transparent | Dependent

/** A private method */
final val PrivateMethod = allOf(Private, Method)
Expand All @@ -566,6 +569,12 @@ object Flags {
/** A rewrite method */
final val RewriteMethod = allOf(Rewrite, Method)

/** A dependent method */
final val DependentMethod = allOf(Dependent, Method)

/** A transparent implicit method */
final val TransparentImplicitMethod = allOf(Transparent, Rewrite, Implicit, Method)

/** An implicit rewrite method */
final val ImplicitRewriteMethod = allOf(Rewrite, Implicit, Method)

Expand Down
3 changes: 3 additions & 0 deletions compiler/src/dotty/tools/dotc/core/Mode.scala
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,7 @@ object Mode {

/** Read comments from definitions when unpickling from TASTY */
val ReadComments = newMode(22, "ReadComments")

/** We are in TypeOf, e.g. to type a SingletonTypeTree or to compute a derived TypeOf */
val InTypeOf = newMode(23, "InTypeOf")
}
Loading