Skip to content

Generalize RefTypes #3087

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 146 commits into from
Sep 22, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
146 commits
Select commit Hold shift + click to select a range
8fa29ad
Introduce AppliedType
odersky Jul 21, 2017
7be50a6
Adapt operations in Types
odersky Jul 21, 2017
2ec644b
Move givenSelfType to ClassSymbol
odersky Jul 22, 2017
b219c74
Handle AppliedTypes
odersky Jul 23, 2017
6a63549
Introduce TypeArgRef
odersky Jul 26, 2017
4b64c00
Various fixes
odersky Jul 28, 2017
76d1194
More fixes
odersky Jul 28, 2017
cf491ff
Fix stray brace
odersky Jul 29, 2017
08ff2b2
Fix typing of _* arguments
odersky Jul 30, 2017
b17f5de
Fix rebase breakage
odersky Aug 16, 2017
9b59150
Fix debug output to make it more stable
odersky Aug 16, 2017
c3daec5
Fix Stackoverflow in asSeenFrom
odersky Aug 16, 2017
4a6df0e
Make newScheme non-final
odersky Aug 16, 2017
0228613
Partially revert change in TypeApplications#Reducer
odersky Aug 16, 2017
c65c10a
Use atVariance for new cases in TypeMaps and TypeAccumulators
odersky Aug 16, 2017
83fb812
Fix bounds propagation
odersky Aug 17, 2017
6c5106e
Fix variance in avoidParams
odersky Aug 17, 2017
965a8e4
Fix isSubArg
odersky Aug 17, 2017
d947614
Avoid infinite expansion in normaizeWildcardArgs
odersky Aug 17, 2017
abde37e
Handle parameters from base classes of package objects
odersky Aug 17, 2017
ef086ce
More fixes
odersky Aug 18, 2017
357e2ae
Fix #536 again
odersky Aug 18, 2017
f9520cb
Adapt ClassTypeParamCreationFlags to new scheme
odersky Aug 18, 2017
842ac4b
Fix TypeArgRef and argForParam
odersky Aug 18, 2017
baf6bf5
Add capture conversion
odersky Aug 18, 2017
90fd77f
Fix ExpandSAMs
odersky Aug 18, 2017
0e4a3ea
Fix implicit scope computation
odersky Aug 18, 2017
d71dc4b
Refine typeMismatchMsg
odersky Aug 19, 2017
850e5d9
Generalize argForParam
odersky Aug 19, 2017
584eaef
Check that class type parameters are only referenced via their this-t…
odersky Aug 20, 2017
dcec2da
Check that class type parameters are only referenced via their this-t…
odersky Aug 20, 2017
588f1dc
Fix illegal select in VCInlineMethods
odersky Aug 20, 2017
596fa17
Fix classBound
odersky Aug 21, 2017
5bfa153
Fix t8280
odersky Aug 21, 2017
b9f3084
Adapt flip in Applications to new scheme
odersky Aug 21, 2017
756238e
Fix type of outer accessor
odersky Aug 21, 2017
471e62b
Fix computation of implicit scope
odersky Aug 22, 2017
2b10447
Fix problem in isSubArg
odersky Aug 22, 2017
27dbeef
Fix instantiatability checking
odersky Aug 23, 2017
a3d96f1
Adapt tpd.ClassDef and tpd.AnonClass to new scheme
odersky Aug 23, 2017
0a27a7f
Change capture conversion
odersky Aug 23, 2017
891022b
Fix variances for wildcard arguments in TypeMaps and TypeAccumulators
odersky Aug 23, 2017
52dd131
Avoid cyclic reference in normalizeWildcardArgs
odersky Aug 23, 2017
51e67d1
Fix SuperAccessors
odersky Aug 23, 2017
9f3b5a5
Fix possible hole in constraint handling
odersky Aug 24, 2017
536c597
Fix
odersky Aug 24, 2017
c4def34
Fix printing of TypeBounds
odersky Aug 24, 2017
6a02717
Refine Space#refine to handle AppliedTypes
odersky Aug 24, 2017
2da0049
Fix implicit selection for views
odersky Aug 25, 2017
9063347
Fix sigName for AppliedType
odersky Aug 26, 2017
b0a2aa2
Handle Java raw types in isSubType
odersky Aug 27, 2017
36b1550
Don't check variances when comparing type lambdas in Scala2 mode
odersky Aug 27, 2017
dcd8fd3
Don't try to simplify & / | types written as types
odersky Aug 27, 2017
59ce28f
Hash-cons applied types in their own table
odersky Aug 27, 2017
60d7b85
Make ParamRefs unique types.
odersky Aug 27, 2017
bec92d1
Refine statistics
odersky Aug 27, 2017
f92b5fc
Make ParamRefs unique types.
odersky Aug 28, 2017
184ff81
Make bound types be uniquely created by their binders
odersky Aug 28, 2017
5a2c35d
More detailed stats
odersky Aug 29, 2017
4b34d68
Fix base type computation
odersky Aug 29, 2017
25b9bb0
Fix tests
odersky Aug 29, 2017
1daca6c
Temporarily disable pattern-matching exhaustivity tests
odersky Aug 29, 2017
26a327d
Temporarily weaken double definition check
odersky Aug 29, 2017
95720b0
Temporarily existentials test to pending
odersky Aug 29, 2017
3c4b6bd
Ensure type correctness of repeated arguments
odersky Aug 30, 2017
41d6d9e
Update "good bounds" checks
odersky Aug 30, 2017
88953fa
Exclude mixin forwarders from double definition checks
odersky Aug 31, 2017
77077a5
Adapt superclass inference to new scheme
odersky Aug 31, 2017
89d9ef9
Avoid inifinite loop when comparing & types with class types
odersky Aug 31, 2017
6f49cfd
Fix rebase breakage
odersky Aug 31, 2017
e631f38
Handle TypeArgRefs in UserfacingPrinter
odersky Aug 31, 2017
c3d44d7
Fix imports and add explanations in Space
odersky Aug 31, 2017
812373f
Eliminate Config switches
odersky Aug 31, 2017
adde88e
Get rid of parentRefs and associated operations
odersky Aug 31, 2017
0b4c35c
Re-normalize parents methods
odersky Aug 31, 2017
f65162b
Fix rebase breakage, drop old UserfacingPrinter
odersky Aug 31, 2017
99f6bf2
Use adaptHkVariances when comparing type arguments
odersky Aug 31, 2017
0db4ed4
Re-apply change to printing TypeArgRefs in UserfacingPrinter
odersky Aug 31, 2017
0fd92da
Fix script check file
odersky Aug 31, 2017
871a178
Drop HKApply
odersky Aug 31, 2017
cdb34e5
Make baseTypeOf more robust
odersky Aug 31, 2017
babc490
Drop uniqueRefinedType and uniqueTypeAlias
odersky Aug 31, 2017
a78c26f
Drop variance in TypeAlias
odersky Aug 31, 2017
f4d0942
Fix equals for TypeAlias
odersky Aug 31, 2017
b665f13
Adapt homogenizeArgs to new scheme
odersky Sep 1, 2017
e3c3dda
Drop AnyAppliedType
odersky Sep 1, 2017
80ce8d2
Fix printing of infix types
odersky Sep 1, 2017
7de2c12
Drop TypeParamAccessor
odersky Sep 1, 2017
9c28187
Drop BaseTypeArg flag
odersky Sep 1, 2017
476e952
Drop withoutArgs
odersky Sep 1, 2017
77a09c7
Drop ClassDenotation.appliedRef and ClassInfo.typeRef
odersky Sep 1, 2017
5dd8846
Reorder and clean up erasure and sigName
odersky Sep 1, 2017
636e30e
More cleanups and removals of now redundant code
odersky Sep 2, 2017
0a5dfe9
Better implementation of mapArgs
odersky Sep 2, 2017
975a29b
Specialize hash-consing of WithFixedSym types
odersky Sep 3, 2017
db28f49
Avoid creating unnecessary new lists in mapArgs
odersky Sep 4, 2017
7cf4637
Drop unused RefType and ClassRef
odersky Sep 6, 2017
eddc4a4
Remove unused code
odersky Sep 6, 2017
417ca7e
Reverted: Refine Space#refine to handle AppliedTypes
odersky Sep 4, 2017
8456b37
Disable exhaustivity test
odersky Sep 6, 2017
826f14e
fix #3015: use type inference to type child classes
liufengyun Sep 8, 2017
196b008
make exhaustivity check work on native apply
liufengyun Sep 8, 2017
0de8041
address review
liufengyun Sep 8, 2017
ad04a98
Address reviewers comments
odersky Sep 14, 2017
a0b6910
Eliminate some redundant code
odersky Sep 14, 2017
acb6165
Address other reviewer comments
odersky Sep 14, 2017
48a2ab3
Make hkResult work for curried type lambdas
odersky Sep 14, 2017
fe470c4
Adapt reduction of applications to new scheme
odersky Sep 14, 2017
22440f3
Fix test
odersky Sep 14, 2017
d2b7080
Avoid returning stale symbols from NamedType#symbol
odersky Sep 20, 2017
2e65bd5
Fix stale symbol avoidance
odersky Sep 20, 2017
38995a3
Allow TermNames to have signed names
odersky Sep 8, 2017
9e8bcef
Eliminate loadDenot in TermRefWithSig
odersky Sep 8, 2017
02444c9
Move two more methods from TermRefWithSig to TermRef
odersky Sep 8, 2017
e46df82
Drop all references to TermRefWithSignature
odersky Sep 8, 2017
6aa6d3f
Eliminate TermRefWithSignature
odersky Sep 9, 2017
dd9269b
Some simplifications to creation methods
odersky Sep 9, 2017
9acb05d
Introduce Designator as a superclass of Name and Symbol
odersky Sep 10, 2017
60ad829
Disregard refinements in lifting when checking equality
odersky Sep 10, 2017
7d6305c
Simplify withSym
odersky Sep 10, 2017
1ec6708
Drop sig method in NamedType
odersky Sep 10, 2017
8662c76
Fix paramForwarding
odersky Sep 10, 2017
5b20c53
Restrict handling of OverloadedSignature
odersky Sep 10, 2017
02e268d
New classification methods ands casts in Designator
odersky Sep 11, 2017
a0b7e47
Refactorings
odersky Sep 11, 2017
4d7a736
Generalize UniqueNamedTypes
odersky Sep 11, 2017
f7a81e2
Allow for late initialization of names
odersky Sep 11, 2017
12cd6bb
Make desigantors of WithFixedSym classes symbols
odersky Sep 11, 2017
fea46e0
Cleanups
odersky Sep 11, 2017
6bca2da
Get rid of FixedSymUniques
odersky Sep 11, 2017
a3c69a5
Get rid of FixedSymUniques
odersky Sep 11, 2017
d868f33
Get rid of WithFixedSym
odersky Sep 11, 2017
2539e47
Renamings of creation methods
odersky Sep 12, 2017
b82b2fa
Drop nonMemberTermRef
odersky Sep 12, 2017
df0057c
Drop Fresh in mapSymbols
odersky Sep 12, 2017
1ec7fe5
Use a general criterion for when to refer to symbols symbolically
odersky Sep 12, 2017
483a8f3
Streamline NamedType creation methods
odersky Sep 12, 2017
760479b
Eliminate TermRef.withSig
odersky Sep 13, 2017
98d8ecf
Eliminate termRefWithSig and valRef
odersky Sep 13, 2017
f941b4f
Eliminate termRefWithSig and valRef
odersky Sep 13, 2017
66d61d4
Cleanup pickling of NamedTypes
odersky Sep 13, 2017
5cd5ff0
Eliminate designatorName
odersky Sep 13, 2017
24c2909
Tweak diagndostic message
odersky Sep 13, 2017
b08b1a9
Rename Designator(s).scala
odersky Sep 13, 2017
4241475
Tweak isReferencedSymbolically
odersky Sep 14, 2017
2f9d66c
Go back to `withSym` creation methods for NamedTypes
odersky Sep 20, 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
29 changes: 14 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.withSym(tycon, constr))
.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 @@ -918,7 +917,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
}
else denot.asSingleDenotation.termRef
val fun = receiver
.select(TermRef.withSig(receiver.tpe, selected.termSymbol.asTerm))
.select(TermRef.withSym(receiver.tpe, selected.termSymbol.asTerm))
.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
45 changes: 36 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,39 @@ 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.
* - base types do not appear in multiple instances with different arguments.
* (depending on the simplification scheme for AndTypes employed, this could
* also lead to base types with bad 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