Skip to content

[WIP] Change references to private fields #3134

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 139 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
139 commits
Select commit Hold shift + click to select a range
b6e0335
Introduce AppliedType
odersky Jul 21, 2017
e94fb26
Adapt operations in Types
odersky Jul 21, 2017
199d404
Move givenSelfType to ClassSymbol
odersky Jul 22, 2017
9042e05
Handle AppliedTypes
odersky Jul 23, 2017
0419559
Introduce TypeArgRef
odersky Jul 26, 2017
13d3841
Various fixes
odersky Jul 28, 2017
44506f7
More fixes
odersky Jul 28, 2017
43dce36
Fix stray brace
odersky Jul 29, 2017
736396d
Fix typing of _* arguments
odersky Jul 30, 2017
03e8e73
Fix rebase breakage
odersky Aug 16, 2017
66f0192
Fix debug output to make it more stable
odersky Aug 16, 2017
fd4009a
Fix Stackoverflow in asSeenFrom
odersky Aug 16, 2017
28128c0
Make newScheme non-final
odersky Aug 16, 2017
011b019
Partially revert change in TypeApplications#Reducer
odersky Aug 16, 2017
b2e8d5a
Use atVariance for new cases in TypeMaps and TypeAccumulators
odersky Aug 16, 2017
2591f8d
Fix bounds propagation
odersky Aug 17, 2017
cb66784
Fix variance in avoidParams
odersky Aug 17, 2017
b8f4fab
Fix isSubArg
odersky Aug 17, 2017
4d77489
Avoid infinite expansion in normaizeWildcardArgs
odersky Aug 17, 2017
c0e10b4
Handle parameters from base classes of package objects
odersky Aug 17, 2017
94a173c
More fixes
odersky Aug 18, 2017
3489967
Fix #536 again
odersky Aug 18, 2017
c0eed08
Adapt ClassTypeParamCreationFlags to new scheme
odersky Aug 18, 2017
341c7a9
Fix TypeArgRef and argForParam
odersky Aug 18, 2017
5184f02
Add capture conversion
odersky Aug 18, 2017
a75163b
Fix ExpandSAMs
odersky Aug 18, 2017
de5a18f
Fix implicit scope computation
odersky Aug 18, 2017
8d4b898
Refine typeMismatchMsg
odersky Aug 19, 2017
dc6dcab
Generalize argForParam
odersky Aug 19, 2017
7f70344
Check that class type parameters are only referenced via their this-t…
odersky Aug 20, 2017
4406c37
Check that class type parameters are only referenced via their this-t…
odersky Aug 20, 2017
769955e
Fix illegal select in VCInlineMethods
odersky Aug 20, 2017
a23022a
Fix classBound
odersky Aug 21, 2017
22bd841
Fix t8280
odersky Aug 21, 2017
fb11a11
Adapt flip in Applications to new scheme
odersky Aug 21, 2017
22d84f2
Fix type of outer accessor
odersky Aug 21, 2017
04ca3cd
Fix computation of implicit scope
odersky Aug 22, 2017
ffad6ea
Fix problem in isSubArg
odersky Aug 22, 2017
a6fa7a5
Fix instantiatability checking
odersky Aug 23, 2017
1d2c230
Adapt tpd.ClassDef and tpd.AnonClass to new scheme
odersky Aug 23, 2017
f5d9367
Change capture conversion
odersky Aug 23, 2017
ce080a6
Fix variances for wildcard arguments in TypeMaps and TypeAccumulators
odersky Aug 23, 2017
5fed236
Avoid cyclic reference in normalizeWildcardArgs
odersky Aug 23, 2017
302e0e1
Fix SuperAccessors
odersky Aug 23, 2017
9c001a8
Fix possible hole in constraint handling
odersky Aug 24, 2017
b89acb8
Fix
odersky Aug 24, 2017
a7eff0f
Fix printing of TypeBounds
odersky Aug 24, 2017
8bf268f
Refine Space#refine to handle AppliedTypes
odersky Aug 24, 2017
223f4ae
Fix implicit selection for views
odersky Aug 25, 2017
0c7d208
Fix sigName for AppliedType
odersky Aug 26, 2017
5119502
Handle Java raw types in isSubType
odersky Aug 27, 2017
5d554a5
Don't check variances when comparing type lambdas in Scala2 mode
odersky Aug 27, 2017
c97ab06
Don't try to simplify & / | types written as types
odersky Aug 27, 2017
8972bc0
Hash-cons applied types in their own table
odersky Aug 27, 2017
773094f
Make ParamRefs unique types.
odersky Aug 27, 2017
31bad9f
Refine statistics
odersky Aug 27, 2017
07bd8ab
Make ParamRefs unique types.
odersky Aug 28, 2017
3ac2cd4
Make bound types be uniquely created by their binders
odersky Aug 28, 2017
5b60d72
More detailed stats
odersky Aug 29, 2017
a8bde56
Fix base type computation
odersky Aug 29, 2017
57440d2
Fix tests
odersky Aug 29, 2017
32fe051
Temporarily disable pattern-matching exhaustivity tests
odersky Aug 29, 2017
0db5e86
Temporarily weaken double definition check
odersky Aug 29, 2017
6a53e2d
Temporarily existentials test to pending
odersky Aug 29, 2017
fcc6ade
Ensure type correctness of repeated arguments
odersky Aug 30, 2017
dd72ca4
Update "good bounds" checks
odersky Aug 30, 2017
20a1438
Exclude mixin forwarders from double definition checks
odersky Aug 31, 2017
c2244cd
Adapt superclass inference to new scheme
odersky Aug 31, 2017
883f439
Avoid inifinite loop when comparing & types with class types
odersky Aug 31, 2017
0b66b07
Fix rebase breakage
odersky Aug 31, 2017
77a54c8
Handle TypeArgRefs in UserfacingPrinter
odersky Aug 31, 2017
e38eb41
Fix imports and add explanations in Space
odersky Aug 31, 2017
ccc93e8
Eliminate Config switches
odersky Aug 31, 2017
3b186a2
Get rid of parentRefs and associated operations
odersky Aug 31, 2017
57c07c9
Re-normalize parents methods
odersky Aug 31, 2017
a27103d
Fix rebase breakage, drop old UserfacingPrinter
odersky Aug 31, 2017
820bd17
Use adaptHkVariances when comparing type arguments
odersky Aug 31, 2017
f7a2220
Re-apply change to printing TypeArgRefs in UserfacingPrinter
odersky Aug 31, 2017
4fec222
Fix script check file
odersky Aug 31, 2017
bdd52ef
Drop HKApply
odersky Aug 31, 2017
4bfc78a
Make baseTypeOf more robust
odersky Aug 31, 2017
1aacf4f
Drop uniqueRefinedType and uniqueTypeAlias
odersky Aug 31, 2017
f769b3d
Drop variance in TypeAlias
odersky Aug 31, 2017
797d58f
Fix equals for TypeAlias
odersky Aug 31, 2017
18701bb
Adapt homogenizeArgs to new scheme
odersky Sep 1, 2017
451bad7
Drop AnyAppliedType
odersky Sep 1, 2017
d42808f
Fix printing of infix types
odersky Sep 1, 2017
0c3cb4b
Drop TypeParamAccessor
odersky Sep 1, 2017
84c7dab
Drop BaseTypeArg flag
odersky Sep 1, 2017
c6c728a
Drop withoutArgs
odersky Sep 1, 2017
45a7e42
Drop ClassDenotation.appliedRef and ClassInfo.typeRef
odersky Sep 1, 2017
8630585
Reorder and clean up erasure and sigName
odersky Sep 1, 2017
c8a9f78
More cleanups and removals of now redundant code
odersky Sep 2, 2017
d44668d
Better implementation of mapArgs
odersky Sep 2, 2017
cae299e
Specialize hash-consing of WithFixedSym types
odersky Sep 3, 2017
6b133b8
Avoid creating unnecessary new lists in mapArgs
odersky Sep 4, 2017
2189457
Drop unused RefType and ClassRef
odersky Sep 6, 2017
baaff3a
Remove unused code
odersky Sep 6, 2017
2426f26
Reverted: Refine Space#refine to handle AppliedTypes
odersky Sep 4, 2017
c05bbd3
Disable exhaustivity test
odersky Sep 6, 2017
9a26ec2
fix #3015: use type inference to type child classes
liufengyun Sep 8, 2017
192be73
make exhaustivity check work on native apply
liufengyun Sep 8, 2017
9eb6e83
address review
liufengyun Sep 8, 2017
4a3c36f
Allow TermNames to have signed names
odersky Sep 8, 2017
c15718f
Eliminate loadDenot in TermRefWithSig
odersky Sep 8, 2017
38d71d4
Move two more methods from TermRefWithSig to TermRef
odersky Sep 8, 2017
95c2c1b
Drop all references to TermRefWithSignature
odersky Sep 8, 2017
369d3b6
Eliminate TermRefWithSignature
odersky Sep 9, 2017
957c65e
Some simplifications to creation methods
odersky Sep 9, 2017
f5423fb
Introduce Designator as a superclass of Name and Symbol
odersky Sep 10, 2017
baa471c
Disregard refinements in lifting when checking equality
odersky Sep 10, 2017
1e69217
Simplify withSym
odersky Sep 10, 2017
a3ed56a
Drop sig method in NamedType
odersky Sep 10, 2017
5e4455a
Fix paramForwarding
odersky Sep 10, 2017
85621e3
Restrict handling of OverloadedSignature
odersky Sep 10, 2017
689ebc8
New classification methods ands casts in Designator
odersky Sep 11, 2017
2a984f0
Refactorings
odersky Sep 11, 2017
1611f90
Generalize UniqueNamedTypes
odersky Sep 11, 2017
c3412f4
Allow for late initialization of names
odersky Sep 11, 2017
066dd05
Make desigantors of WithFixedSym classes symbols
odersky Sep 11, 2017
6062913
Cleanups
odersky Sep 11, 2017
c71adc5
Get rid of FixedSymUniques
odersky Sep 11, 2017
ce828cd
Get rid of FixedSymUniques
odersky Sep 11, 2017
95aefce
Get rid of WithFixedSym
odersky Sep 11, 2017
4a5b672
Renamings of creation methods
odersky Sep 12, 2017
37f892c
Drop nonMemberTermRef
odersky Sep 12, 2017
b1d820a
Drop Fresh in mapSymbols
odersky Sep 12, 2017
2ca9e7c
Use a general criterion for when to refer to symbols symbolically
odersky Sep 12, 2017
019b4ca
Streamline NamedType creation methods
odersky Sep 12, 2017
3510ac6
Eliminate TermRef.withSig
odersky Sep 13, 2017
4c28fc4
Eliminate termRefWithSig and valRef
odersky Sep 13, 2017
0f70d93
Eliminate termRefWithSig and valRef
odersky Sep 13, 2017
aefae16
Cleanup pickling of NamedTypes
odersky Sep 13, 2017
c80d051
Eliminate designatorName
odersky Sep 13, 2017
afdff6b
Tweak diagndostic message
odersky Sep 13, 2017
b2e8d33
Rename Designator(s).scala
odersky Sep 13, 2017
e8022c1
Tweak isReferencedSymbolically
odersky Sep 14, 2017
f9135cf
Introduce Namespace field in named types.
odersky Sep 17, 2017
d835a38
Harden IDE: Surive checkNoLeaks assertion
odersky Sep 17, 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
Original file line number Diff line number Diff line change
Expand Up @@ -431,11 +431,11 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
var found = desugared.get(i.tpe)
if (found == null) {
i.tpe match {
case TermRef(prefix: TermRef, name) =>
case TermRef(prefix: TermRef, _) =>
found = tpd.ref(prefix).select(i.symbol)
case TermRef(prefix: ThisType, name) =>
case TermRef(prefix: ThisType, _) =>
found = tpd.This(prefix.cls).select(i.symbol)
case TermRef(NoPrefix, name) =>
case TermRef(NoPrefix, _) =>
if (i.symbol is Flags.Method) found = This(i.symbol.topLevelClass).select(i.symbol) // workaround #342 todo: remove after fixed
case _ =>
}
Expand Down
27 changes: 14 additions & 13 deletions compiler/src/dotty/tools/dotc/Run.scala
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class Run(comp: Compiler, ictx: Context) {
compileUnits()(ctx)
}

protected def compileUnits()(implicit ctx: Context) = Stats.monitorHeartBeat {
protected def compileUnits()(implicit ctx: Context) = Stats.maybeMonitored {
ctx.checkSingleThreaded()

// If testing pickler, make sure to stop after pickling phase:
Expand All @@ -118,20 +118,21 @@ class Run(comp: Compiler, ictx: Context) {
ctx.usePhases(phases)
var lastPrintedTree: PrintedTree = NoPrintedTree
for (phase <- ctx.allPhases)
if (phase.isRunnable) {
val start = System.currentTimeMillis
units = phase.runOn(units)
if (ctx.settings.Xprint.value.containsPhase(phase)) {
for (unit <- units) {
lastPrintedTree =
printTree(lastPrintedTree)(ctx.fresh.setPhase(phase.next).setCompilationUnit(unit))
if (phase.isRunnable)
Stats.trackTime(s"$phase ms ") {
val start = System.currentTimeMillis
units = phase.runOn(units)
if (ctx.settings.Xprint.value.containsPhase(phase)) {
for (unit <- units) {
lastPrintedTree =
printTree(lastPrintedTree)(ctx.fresh.setPhase(phase.next).setCompilationUnit(unit))
}
}
ctx.informTime(s"$phase ", start)
Stats.record(s"total trees at end of $phase", ast.Trees.ntrees)
for (unit <- units)
Stats.record(s"retained typed trees at end of $phase", unit.tpdTree.treeSize)
}
ctx.informTime(s"$phase ", start)
Stats.record(s"total trees at end of $phase", ast.Trees.ntrees)
for (unit <- units)
Stats.record(s"retained typed trees at end of $phase", unit.tpdTree.treeSize)
}
if (!ctx.reporter.hasErrors) Rewrites.writeBack()
}

Expand Down
27 changes: 5 additions & 22 deletions compiler/src/dotty/tools/dotc/ast/Desugar.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package ast
import core._
import util.Positions._, Types._, Contexts._, Constants._, Names._, NameOps._, Flags._
import SymDenotations._, Symbols._, StdNames._, Annotations._, Trees._
import Decorators._
import Decorators._, transform.SymUtils._
import NameKinds.{UniqueName, EvidenceParamName, DefaultGetterName}
import language.higherKinds
import typer.FrontEnd
Expand Down Expand Up @@ -70,7 +70,7 @@ object desugar {
def apply(tp: Type) = tp match {
case tp: NamedType if tp.symbol.exists && (tp.symbol.owner eq originalOwner) =>
val defctx = ctx.outersIterator.dropWhile(_.scope eq ctx.scope).next()
var local = defctx.denotNamed(tp.name).suchThat(_ is ParamOrAccessor).symbol
var local = defctx.denotNamed(tp.name).suchThat(_.isParamOrAccessor).symbol
if (local.exists) (defctx.owner.thisType select local).dealias
else {
def msg =
Expand Down Expand Up @@ -238,23 +238,6 @@ object desugar {
Nil
}

/** Fill in empty type bounds with Nothing/Any. Expand private local type parameters as follows:
*
* class C[v T]
* ==>
* class C { type v C$T; type v T = C$T }
*/
def typeDef(tdef: TypeDef)(implicit ctx: Context): Tree = {
if (tdef.mods is PrivateLocalParam) {
val tparam = cpy.TypeDef(tdef)(name = tdef.name.expandedName(ctx.owner))
.withMods(tdef.mods &~ PrivateLocal)
val alias = cpy.TypeDef(tdef)(rhs = refOfDef(tparam))
.withMods(tdef.mods & VarianceFlags | PrivateLocalParamAccessor | Synthetic)
Thicket(tparam, alias)
}
else tdef
}

@sharable private val synthetic = Modifiers(Synthetic)

private def toDefParam(tparam: TypeDef): TypeDef =
Expand Down Expand Up @@ -696,7 +679,7 @@ object desugar {

def defTree(tree: Tree)(implicit ctx: Context): Tree = tree match {
case tree: ValDef => valDef(tree)
case tree: TypeDef => if (tree.isClassDef) classDef(tree) else typeDef(tree)
case tree: TypeDef => if (tree.isClassDef) classDef(tree) else tree
case tree: DefDef => defDef(tree)
case tree: ModuleDef => moduleDef(tree)
case tree: PatDef => patDef(tree)
Expand Down Expand Up @@ -1074,7 +1057,7 @@ object desugar {
} else if (arity == 1) ts.head
else if (ctx.mode is Mode.Type) AppliedTypeTree(ref(tupleTypeRef), ts)
else if (arity == 0) unitLiteral
else Apply(ref(tupleTypeRef.classSymbol.companionModule.valRef), ts)
else Apply(ref(tupleTypeRef.classSymbol.companionModule.termRef), ts)
case WhileDo(cond, body) =>
// { <label> def while$(): Unit = if (cond) { body; while$() } ; while$() }
val call = Apply(Ident(nme.WHILE_PREFIX), Nil).withPos(tree.pos)
Expand Down Expand Up @@ -1132,7 +1115,7 @@ object desugar {
*/
def refinedTypeToClass(parent: tpd.Tree, refinements: List[Tree])(implicit ctx: Context): TypeDef = {
def stripToCore(tp: Type): List[Type] = tp match {
case tp: RefinedType if tp.argInfos.nonEmpty => tp :: Nil // parameterized class type
case tp: AppliedType => tp :: Nil
case tp: TypeRef if tp.symbol.isClass => tp :: Nil // monomorphic class type
case tp: TypeProxy => stripToCore(tp.underlying)
case AndType(tp1, tp2) => stripToCore(tp1) ::: stripToCore(tp2)
Expand Down
5 changes: 4 additions & 1 deletion compiler/src/dotty/tools/dotc/ast/Trees.scala
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,10 @@ object Trees {
* where we overwrite with a simplified version of the type itself.
*/
private[dotc] def overwriteType(tpe: T) = {
if (this.isInstanceOf[Template[_]]) assert(tpe.isInstanceOf[WithFixedSym], s"$this <--- $tpe")
if (this.isInstanceOf[Template[_]])
tpe match {
case tpe: TermRef => assert(tpe.hasFixedSym , s"$this <--- $tpe")
}
myTpe = tpe
}

Expand Down
30 changes: 15 additions & 15 deletions compiler/src/dotty/tools/dotc/ast/tpd.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import dotty.tools.dotc.transform.{ExplicitOuter, Erasure}
import dotty.tools.dotc.typer.ProtoTypes.FunProtoTyped
import transform.SymUtils._
import core._
import util.Positions._, Types._, Contexts._, Constants._, Names._, Flags._
import util.Positions._, Types._, Contexts._, Constants._, Names._, Flags._, NameOps._
import SymDenotations._, Symbols._, StdNames._, Annotations._, Trees._, Symbols._
import Denotations._, Decorators._, DenotTransformers._
import collection.mutable
Expand Down Expand Up @@ -213,8 +213,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
ta.assignType(untpd.TypeDef(sym.name, TypeTree(sym.info)), sym)

def ClassDef(cls: ClassSymbol, constr: DefDef, body: List[Tree], superArgs: List[Tree] = Nil)(implicit ctx: Context): TypeDef = {
val firstParentRef :: otherParentRefs = cls.info.parents
val firstParent = cls.typeRef.baseTypeWithArgs(firstParentRef.symbol)
val firstParent :: otherParents = cls.info.parents
val superRef =
if (cls is Trait) TypeTree(firstParent)
else {
Expand All @@ -229,7 +228,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
val constr = firstParent.decl(nme.CONSTRUCTOR).suchThat(constr => isApplicable(constr.info))
New(firstParent, constr.symbol.asTerm, superArgs)
}
val parents = superRef :: otherParentRefs.map(TypeTree(_))
val parents = superRef :: otherParents.map(TypeTree(_))

val selfType =
if (cls.classInfo.selfInfo ne NoType) ValDef(ctx.newSelfSym(cls))
Expand All @@ -244,7 +243,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
val localDummy = ((NoSymbol: Symbol) /: body)(findLocalDummy.apply)
.orElse(ctx.newLocalDummy(cls))
val impl = untpd.Template(constr, parents, selfType, newTypeParams ++ body)
.withType(localDummy.nonMemberTermRef)
.withType(localDummy.termRef)
ta.assignType(untpd.TypeDef(cls.name, impl), cls)
}

Expand Down Expand Up @@ -305,7 +304,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
true
case pre: ThisType =>
pre.cls.isStaticOwner ||
tp.symbol.is(ParamOrAccessor) && !pre.cls.is(Trait) && ctx.owner.enclosingClass == pre.cls
tp.symbol.isParamOrAccessor && !pre.cls.is(Trait) && ctx.owner.enclosingClass == pre.cls
// was ctx.owner.enclosingClass.derivesFrom(pre.cls) which was not tight enough
// and was spuriously triggered in case inner class would inherit from outer one
// eg anonymous TypeMap inside TypeMap.andThen
Expand Down Expand Up @@ -381,9 +380,9 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
/** new C(args), calling given constructor `constr` of C */
def New(tp: Type, constr: TermSymbol, args: List[Tree])(implicit ctx: Context): Apply = {
val targs = tp.argTypes
val tycon = tp.withoutArgs(targs)
val tycon = tp.typeConstructor
New(tycon)
.select(TermRef.withSig(tycon, constr))
.select(TermRef(tycon, constr, constr.name))
.appliedToTypes(targs)
.appliedToArgs(args)
}
Expand Down Expand Up @@ -698,19 +697,19 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
*/
def select(sym: Symbol)(implicit ctx: Context): Select = {
val tp =
if (sym.isType)
if (sym.isType) {
assert(!sym.is(TypeParam))
TypeRef(tree.tpe, sym.name.asTypeName)
}
else
TermRef.withSigAndDenot(tree.tpe, sym.name.asTermName,
sym.signature, sym.denot.asSeenFrom(tree.tpe))
untpd.Select(tree, sym.name)
.withType(tp)
TermRef(tree.tpe, sym.name.asTermName, sym.denot.asSeenFrom(tree.tpe))
untpd.Select(tree, sym.name).withType(tp)
}

/** 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.withSig(tree.tpe, name.asTermName, sig))
.withType(TermRef(tree.tpe, name.asTermName.withSig(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 @@ -917,8 +916,9 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
alternatives.head
}
else denot.asSingleDenotation.termRef
val selectedSym = selected.termSymbol.asTerm
val fun = receiver
.select(TermRef.withSig(receiver.tpe, selected.termSymbol.asTerm))
.select(TermRef(receiver.tpe, selectedSym, selectedSym.name))
.appliedToTypes(targs)

def adaptLastArg(lastParam: Tree, expectedType: Type) = {
Expand Down
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/dotc/ast/untpd.scala
Original file line number Diff line number Diff line change
Expand Up @@ -296,9 +296,9 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
(tycon, targs)
case TypedSplice(AppliedTypeTree(tycon, targs)) =>
(TypedSplice(tycon), targs map (TypedSplice(_)))
case TypedSplice(tpt1: Tree) =>
case TypedSplice(tpt1: tpd.Tree) =>
val tycon = tpt1.tpe.typeConstructor
val argTypes = tpt1.tpe.argTypesLo
val tycon = tpt1.tpe.withoutArgs(argTypes)
def wrap(tpe: Type) = TypeTree(tpe) withPos tpt.pos
(wrap(tycon), argTypes map wrap)
case _ =>
Expand Down
20 changes: 10 additions & 10 deletions compiler/src/dotty/tools/dotc/config/Config.scala
Original file line number Diff line number Diff line change
Expand Up @@ -84,19 +84,12 @@ object Config {
/** If this flag is set, take the fast path when comparing same-named type-aliases and types */
final val fastPathForRefinedSubtype = true

/** If this flag is set, `TypeOps.normalizeToClassRefs` will insert forwarders
* for type parameters of base classes. This is an optimization, which avoids
* long alias chains. We should not rely on the optimization, though. So changing
* the flag to false can be used for checking that everything works OK without it.
*/
final val forwardTypeParams = true

/** If this flag is set, and we compute `T1 { X = S1 }` & `T2 { X = S2 }` as a new
* upper bound of a constrained parameter, try to align the refinements by computing
/** If this flag is set, and we compute `T1[X1]` & `T2[X2]` as a new
* upper bound of a constrained parameter, try to align the arguments by computing
* `S1 =:= S2` (which might instantiate type parameters).
* This rule is contentious because it cuts the constraint set.
*
* For more info, see the comment in `TypeComparer#distributeAnd`.
* For more info, see the comment in `TypeComparer#glbArgs`.
*/
final val alignArgsInAnd = true

Expand All @@ -113,6 +106,13 @@ object Config {
*/
final val checkTypeRefCycles = false

/** If this flag is set, it is checked that class type parameters are
* only references with NoPrefix or ThisTypes as prefixes. This option
* is usally disabled, because there are still some legitimate cases where
* this can arise (e.g. for pos/Map.scala, in LambdaType.integrate).
*/
final val checkTypeParamRefs = false

/** The recursion depth for showing a summarized string */
final val summarizeDepth = 2

Expand Down
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/dotc/config/ScalaSettings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ class ScalaSettings extends Settings.SettingGroup {
val Ycheck = PhasesSetting("-Ycheck", "Check the tree at the end of")
val YcheckMods = BooleanSetting("-Ycheck-mods", "Check that symbols and their defining trees have modifiers in sync")
val debug = BooleanSetting("-Ydebug", "Increase the quantity of debugging output.")
val debugAlias = BooleanSetting("-Ydebug-alias", "Never follow alias when printing types")
val debugTrace = BooleanSetting("-Ydebug-trace", "Trace core operations")
val debugFlags = BooleanSetting("-Ydebug-flags", "Print all flags of definitions")
val debugNames = BooleanSetting("-Ydebug-names", "Show internal representation of names")
Expand All @@ -87,7 +86,8 @@ class ScalaSettings extends Settings.SettingGroup {
val YmethodInfer = BooleanSetting("-Yinfer-argument-types", "Infer types for arguments of overriden methods.")
val YtraceContextCreation = BooleanSetting("-Ytrace-context-creation", "Store stack trace of context creations.")
val YshowSuppressedErrors = BooleanSetting("-Yshow-suppressed-errors", "Also show follow-on errors and warnings that are normally supressed.")
val Yheartbeat = BooleanSetting("-Yheartbeat", "show heartbeat stack trace of compiler operations.")
val YdetailedStats = BooleanSetting("-Ydetailed-stats", "show detailed internal compiler stats (needs Stats.enabled to be set to true).")
val Yheartbeat = BooleanSetting("-Ydetailed-stats", "show heartbeat stack trace of compiler operations (needs Stats.enabled to be set to true).")
val Yprintpos = BooleanSetting("-Yprintpos", "show tree positions.")
val YnoDeepSubtypes = BooleanSetting("-Yno-deep-subtypes", "throw an exception on deep subtyping call stacks.")
val YnoPatmatOpt = BooleanSetting("-Yno-patmat-opt", "disable all pattern matching optimizations.")
Expand Down
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/dotc/core/Annotations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ object Annotations {

private def resolveConstructor(atp: Type, args:List[Tree])(implicit ctx: Context): Tree = {
val targs = atp.argTypes
tpd.applyOverloaded(New(atp withoutArgs targs), nme.CONSTRUCTOR, args, targs, atp, isAnnotConstructor = true)
tpd.applyOverloaded(New(atp.typeConstructor), nme.CONSTRUCTOR, args, targs, atp, isAnnotConstructor = true)
}

def applyResolve(atp: Type, args: List[Tree])(implicit ctx: Context): Annotation = {
Expand Down Expand Up @@ -140,7 +140,7 @@ object Annotations {

def makeAlias(sym: TermSymbol)(implicit ctx: Context) =
apply(defn.AliasAnnot, List(
ref(TermRef.withSigAndDenot(sym.owner.thisType, sym.name, sym.signature, sym))))
ref(TermRef(sym.owner.thisType, sym.name, sym))))

def makeChild(delayedSym: Context => Symbol)(implicit ctx: Context): Annotation = {
def makeChildLater(implicit ctx: Context) = {
Expand Down
42 changes: 33 additions & 9 deletions compiler/src/dotty/tools/dotc/core/CheckRealizable.scala
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ object CheckRealizable {
class HasProblemBounds(typ: SingleDenotation)(implicit ctx: Context)
extends Realizability(i" has a member $typ with possibly conflicting bounds ${typ.info.bounds.lo} <: ... <: ${typ.info.bounds.hi}")

class HasProblemBaseArg(typ: Type, argBounds: TypeBounds)(implicit ctx: Context)
extends Realizability(i" has a base type $typ with possibly conflicting parameter bounds ${argBounds.lo} <: ... <: ${argBounds.hi}")

class HasProblemBase(base1: Type, base2: Type)(implicit ctx: Context)
extends Realizability(i" has conflicting base types $base1 and $base2")

class HasProblemField(fld: SingleDenotation, problem: Realizability)(implicit ctx: Context)
extends Realizability(i" has a member $fld which is not a legal path\n since ${fld.symbol.name}: ${fld.info}${problem.msg}")

Expand Down Expand Up @@ -89,18 +95,36 @@ class CheckRealizable(implicit ctx: Context) {
else boundsRealizability(tp).andAlso(memberRealizability(tp))
}

/** `Realizable` if `tp` has good bounds, a `HasProblemBounds` instance
* pointing to a bad bounds member otherwise.
/** `Realizable` if `tp` has good bounds, a `HasProblem...` instance
* pointing to a bad bounds member otherwise. "Has good bounds" means:
*
* - all type members have good bounds
* - all base types are class types, and if their arguments are wildcards
* they have good bounds.
*/
private def boundsRealizability(tp: Type) = {
def hasBadBounds(mbr: SingleDenotation) = {
val bounds = mbr.info.bounds
!(bounds.lo <:< bounds.hi)
}
tp.nonClassTypeMembers.find(hasBadBounds) match {
case Some(mbr) => new HasProblemBounds(mbr)
case _ => Realizable
val mbrProblems =
for {
mbr <- tp.nonClassTypeMembers
if !(mbr.info.loBound <:< mbr.info.hiBound)
}
yield new HasProblemBounds(mbr)

def baseTypeProblems(base: Type) = base match {
case AndType(base1, base2) =>
new HasProblemBase(base1, base2) :: Nil
case base =>
base.argInfos.collect {
case bounds @ TypeBounds(lo, hi) if !(lo <:< hi) =>
new HasProblemBaseArg(base, bounds)
}
}
val baseProblems =
tp.baseClasses.map(_.baseTypeOf(tp)).flatMap(baseTypeProblems)

(((Realizable: Realizability)
/: mbrProblems)(_ andAlso _)
/: baseProblems)(_ andAlso _)
}

/** `Realizable` if all of `tp`'s non-struct fields have realizable types,
Expand Down
Loading