Skip to content

Rework NamedTypes #3494

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 58 commits into from
Dec 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
94f8041
Generalize symbolic named types
odersky Nov 17, 2017
9d962b6
Change isLocallyDefined criterion for TreePickler
odersky Nov 17, 2017
30395c8
Cater for external symbolic references in pickler
odersky Nov 17, 2017
e0866d4
Allow pickling of general symbolic references
odersky Nov 18, 2017
68760a4
Create OverloadedSymbol and OverloadedDenotation
odersky Nov 18, 2017
0864141
More robust implementation of requiredMethod
odersky Nov 18, 2017
12c4429
Optionally make NamedTypes symbolic
odersky Nov 18, 2017
2399c68
Fix Erasure's transformDenot for SingleDenotations
odersky Nov 19, 2017
cea1823
Drop OverloadedSymbol/Denotation
odersky Nov 19, 2017
8326890
Don't interpolate or simplify overloaded references
odersky Nov 19, 2017
a9291b4
Rework denotations
odersky Nov 19, 2017
7e32751
Handle shadowed refs under new scheme
odersky Nov 19, 2017
d3b04aa
Refine Erasure#transform
odersky Nov 19, 2017
c247850
Fixes to handling of overloaded references
odersky Nov 19, 2017
7069e63
Bugfix in ensureAccessible
odersky Nov 20, 2017
17606c9
Better diagnostics for implicit shadowing errors
odersky Nov 20, 2017
0a471ee
Improve "not found" message.
odersky Nov 20, 2017
5b6657d
Better error message for merge errors
odersky Nov 20, 2017
fc85a41
Never change the symbol of a symbolic NamedType
odersky Nov 22, 2017
5e584a8
Fixes to the new scheme
odersky Nov 23, 2017
d42da02
Commit to new scheme where symbols of symbolic references never change
odersky Nov 24, 2017
6aa350a
Drop hack that hides stale package members
odersky Nov 24, 2017
3d63680
Fix definition of Throwable
odersky Nov 24, 2017
a76e884
Refine determination when denotations can be private
odersky Nov 24, 2017
f1d0dbe
Avoid stackoverflow in compileNeg
odersky Nov 24, 2017
b363633
Remove special case in substSym
odersky Nov 24, 2017
89ec7d6
Cleanup
odersky Nov 24, 2017
6b6523a
Replace references to hasFixedSym
odersky Nov 24, 2017
c4f0a3e
Weaken post condition in FirstTransform
odersky Nov 24, 2017
da99504
Always reload denotation with initial name of last symbol.
odersky Nov 24, 2017
614daaa
Avoid stale symbol errors via isStatic
odersky Nov 24, 2017
1ad2157
Refine bringForward
odersky Nov 24, 2017
18a16e9
Fix pickling of refs to shadowed inner classes
odersky Nov 24, 2017
03d7e3f
Allow -uniqid printing on the fly.
odersky Nov 25, 2017
5b818c4
Revert implementation of stableInRunSymbol
odersky Nov 25, 2017
4dea7de
Allow for aut-updating of package members
odersky Nov 25, 2017
37a76d3
Make isStatic force less.
odersky Nov 25, 2017
65b30a2
Add missing case in TypeComparer
odersky Nov 25, 2017
25af9f6
Switch to new Scheme
odersky Nov 25, 2017
6dcfc63
Move test to pending
odersky Nov 25, 2017
49b78c3
Fail on all stale references by default
odersky Nov 26, 2017
c3be42e
Change treatment of signatures in TermRefs
odersky Nov 26, 2017
24ca6c0
Drop all code under !newScheme
odersky Nov 26, 2017
a1ae7f9
Drop NamedType.withSym
odersky Nov 26, 2017
939d1e2
Replace invalidateDenot by reloadDenot
odersky Nov 26, 2017
5b49561
Change visibility of some NamedType operations
odersky Nov 26, 2017
0c87b7b
Resolve previously marked issues
odersky Nov 26, 2017
c3f43f9
Polishings
odersky Nov 27, 2017
6953dfb
Make sure bringForward returns a denotation valid in current period
odersky Nov 27, 2017
68cd5e6
Handle import aliases of implicit definitions
odersky Nov 27, 2017
f33529c
Fix rebase breakage
odersky Nov 27, 2017
c81f282
Rename ImplicitDef -> ImplicitRef
odersky Nov 27, 2017
6ff60da
More tests
odersky Nov 27, 2017
8578fa1
Add original test that caused the whole rewrite
odersky Nov 27, 2017
dd95817
Fix rebase breakage
odersky Nov 27, 2017
eb93112
Harden IDE
odersky Nov 28, 2017
2524788
Some renamings
odersky Nov 29, 2017
759af1e
Adress reviewers comments
odersky Dec 6, 2017
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: 1 addition & 6 deletions compiler/src/dotty/tools/dotc/ast/Trees.scala
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,8 @@ object Trees {
* which implements copy-on-write. Another use-case is in method interpolateAndAdapt in Typer,
* where we overwrite with a simplified version of the type itself.
*/
private[dotc] def overwriteType(tpe: T) = {
if (this.isInstanceOf[Template[_]])
tpe match {
case tpe: TermRef => assert(tpe.hasFixedSym , s"$this <--- $tpe")
}
private[dotc] def overwriteType(tpe: T) =
myTpe = tpe
}

/** The type of the tree. In case of an untyped tree,
* an UnAssignedTypeException is thrown. (Overridden by empty trees)
Expand Down
9 changes: 4 additions & 5 deletions compiler/src/dotty/tools/dotc/ast/tpd.scala
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
val targs = tp.argTypes
val tycon = tp.typeConstructor
New(tycon)
.select(TermRef.withSym(tycon, constr))
.select(TermRef(tycon, constr))
.appliedToTypes(targs)
.appliedToArgs(args)
}
Expand Down Expand Up @@ -709,7 +709,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
val tp =
if (sym.isType) {
assert(!sym.is(TypeParam))
TypeRef(tree.tpe, sym.name.asTypeName)
TypeRef(tree.tpe, sym.asType)
}
else
TermRef(tree.tpe, sym.name.asTermName, sym.denot.asSeenFrom(tree.tpe))
Expand All @@ -718,8 +718,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {

/** A select node with the given selector name and signature and a computed type */
def selectWithSig(name: Name, sig: Signature)(implicit ctx: Context): Tree =
untpd.SelectWithSig(tree, name, sig)
.withType(TermRef(tree.tpe, name.asTermName.withSig(sig)))
untpd.SelectWithSig(tree, name, sig).withType(tree.tpe.select(name.asTermName, sig))

/** A select node with selector name and signature taken from `sym`.
* Note: Use this method instead of select(sym) if the referenced symbol
Expand Down Expand Up @@ -927,7 +926,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
}
else denot.asSingleDenotation.termRef
val fun = receiver
.select(TermRef.withSym(receiver.tpe, selected.termSymbol.asTerm))
.select(TermRef(receiver.tpe, selected.termSymbol.asTerm))
.appliedToTypes(targs)

def adaptLastArg(lastParam: Tree, expectedType: Type) = {
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/core/Contexts.scala
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ object Contexts {
def implicits: ContextualImplicits = {
if (implicitsCache == null )
implicitsCache = {
val implicitRefs: List[TermRef] =
val implicitRefs: List[ImplicitRef] =
if (isClassDefContext)
try owner.thisType.implicitMembers
catch {
Expand Down
9 changes: 6 additions & 3 deletions compiler/src/dotty/tools/dotc/core/Definitions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ class Definitions {
* members at runtime.
*/
lazy val ScalaShadowingPackageVal = ctx.requiredPackage(nme.scalaShadowing)
lazy val ScalaShadowingPackageClass = ScalaShadowingPackageVal.moduleClass.asClass
def ScalaShadowingPackageClass(implicit ctx: Context) = ScalaShadowingPackageVal.moduleClass.asClass

/** Note: We cannot have same named methods defined in Object and Any (and AnyVal, for that matter)
* because after erasure the Any and AnyVal references get remapped to the Object methods
Expand Down Expand Up @@ -510,7 +510,6 @@ class Definitions {
lazy val IndexOutOfBoundsException = ctx.requiredClass("java.lang.IndexOutOfBoundsException")
lazy val ClassClass = ctx.requiredClass("java.lang.Class")
lazy val BoxedNumberClass = ctx.requiredClass("java.lang.Number")
lazy val ThrowableClass = ctx.requiredClass("java.lang.Throwable")
lazy val ClassCastExceptionClass = ctx.requiredClass("java.lang.ClassCastException")
lazy val ArithmeticExceptionClass = ctx.requiredClass("java.lang.ArithmeticException")
lazy val ArithmeticExceptionClass_stringConstructor = ArithmeticExceptionClass.info.member(nme.CONSTRUCTOR).suchThat(_.info.firstParamTypes match {
Expand All @@ -525,6 +524,8 @@ class Definitions {

// in scalac modified to have Any as parent

lazy val ThrowableType: TypeRef = ctx.requiredClassRef("java.lang.Throwable")
def ThrowableClass(implicit ctx: Context) = ThrowableType.symbol.asClass
lazy val SerializableType: TypeRef = ctx.requiredClassRef("scala.Serializable")
def SerializableClass(implicit ctx: Context) = SerializableType.symbol.asClass
lazy val StringBuilderType: TypeRef = ctx.requiredClassRef("scala.collection.mutable.StringBuilder")
Expand Down Expand Up @@ -680,7 +681,6 @@ class Definitions {
// Derived types

def RepeatedParamType = RepeatedParamClass.typeRef
def ThrowableType = ThrowableClass.typeRef

def ClassType(arg: Type)(implicit ctx: Context) = {
val ctype = ClassClass.typeRef
Expand Down Expand Up @@ -829,6 +829,9 @@ class Definitions {
def isTupleClass(cls: Symbol) = isVarArityClass(cls, str.Tuple)
def isProductClass(cls: Symbol) = isVarArityClass(cls, str.Product)

def isScalaShadowingPackageClass(cls: Symbol) =
cls.name == tpnme.scalaShadowing && cls.owner == RootClass

/** Returns the erased class of the function class `cls`
* - FunctionN for N > 22 becomes FunctionXXL
* - FunctionN for 22 > N >= 0 remains as FunctionN
Expand Down
Loading