Skip to content

Change hk take 2 #802

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 44 commits into from
Sep 25, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
8e1f0da
Clean up of logic in typeDefSig
odersky Jul 11, 2015
e2e71dc
Avoid cyclic references in containsRefinedThis
odersky Jul 12, 2015
92fe081
Eta expand type arguments corresponding to lambdas
odersky Jul 14, 2015
3eb1143
Check argument lengths in typedAppliedTypeTree
odersky Jul 14, 2015
b10b93e
Better diagnostics for failed sigName calls.
odersky Jul 14, 2015
0bdee32
Black hole detection for LazyRefs
odersky Jul 14, 2015
0d95c76
Turn assertion into a test in etaExpandArgs.
odersky Jul 14, 2015
fdf8f86
Fix argument eta expansion
odersky Jul 14, 2015
5f7eadf
Strenghten condition in EtaExpandIfLambda
odersky Jul 14, 2015
f192203
Adapt arguments in all type applications
odersky Jul 14, 2015
c28f023
Avoid generating companion-methods for non-class types.
odersky Jul 15, 2015
8c6b709
Add EtaReduce method.
odersky Jul 16, 2015
a4d51ed
Add comment.
odersky Jul 17, 2015
c8b22f5
Add a test that logs the classpath to pinpoint setup failures.
odersky Jul 17, 2015
36ea476
Don't eta expand in appliedTo
odersky Jul 14, 2015
60b231c
Always lambda abstract TempPolyTypes representing types.
odersky Jul 15, 2015
525e0ac
Lambda abstract all TypeRefs when unpickling.
odersky Jul 15, 2015
eb0b288
A non-class typeref has type parameters only if subtype of a lambda c…
odersky Jul 15, 2015
e2aa258
Drop parameterizeWith
odersky Jul 17, 2015
b12edd1
Allow to use safe substitution in LambdaAbstract
odersky Jul 19, 2015
3be3aa3
Use EtaExpand instead of LambdaAbstract when unpickling typerefs
odersky Jul 19, 2015
4704996
Avoid cycles when eliminating existentials in unpickling
odersky Jul 19, 2015
094c3bd
Don't lambda abstract derived types
odersky Jul 19, 2015
31f9da1
Temporary fix to testLifted
odersky Jul 19, 2015
05a4660
Follow alias types when computing type params.
odersky Jul 19, 2015
83ae926
Try to eta reduce type applications.
odersky Jul 19, 2015
965e7e3
Project all high-kinded types with #Apply
odersky Jul 19, 2015
c0918c6
Better error reporting in TreePickler
odersky Jul 19, 2015
09ebc0f
Adapt type arguments in typedAppliedTypeTree
odersky Jul 19, 2015
caae19b
Add missing position to error
odersky Jul 19, 2015
2634498
Rename Apply -> hkApply
odersky Jul 20, 2015
845a5d6
Simplify EtaReduce
odersky Jul 20, 2015
31048ad
Rename of hk args HK$x -> hk$x
odersky Jul 20, 2015
5a9a48d
Remove magic from derivedRefinedType.
odersky Jul 20, 2015
38ac029
Replace isLambda with ifHK
odersky Jul 20, 2015
ab6e5ce
Rewrite compareHK to be kind-correct
odersky Jul 20, 2015
4aa1d5e
Fix problem in typeParams
odersky Jul 20, 2015
4148970
Generalize eta reduction to partially applied types.
odersky Jul 21, 2015
e8aecfa
Disallow wildcard arguments to higher-kinded types...
odersky Jul 21, 2015
d1cd3d7
Keep track of parameter bounds in LambdaAbstract and EtaReduce
odersky Jul 21, 2015
5ee7b9e
Avoid orphan RefinedThis types in glb/lub.
odersky Jul 22, 2015
154f351
Move failing test to pending.
odersky Jul 22, 2015
71e3133
Eta expand $apply projected types if needed
odersky Sep 21, 2015
1ba3d61
Fixes to comments suggested by reviewer
odersky Sep 21, 2015
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
5 changes: 5 additions & 0 deletions src/dotty/tools/dotc/config/Config.scala
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ 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, $apply projections are checked that they apply to a
* higher-kinded type.
*/
final val checkProjections = false

/** When set, use new signature-based matching.
* Advantage of doing so: It's supposed to be faster
* Disadvantage: It might hide inconsistencies, so while debugging it's better to turn it off
Expand Down
14 changes: 7 additions & 7 deletions src/dotty/tools/dotc/core/Definitions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ class Definitions {
/** The set of HigherKindedXYZ traits encountered so far */
def lambdaTraits: Set[Symbol] = myLambdaTraits

private var lambdaTraitForVariances = mutable.Map[List[Int], ClassSymbol]()
private var LambdaTraitForVariances = mutable.Map[List[Int], ClassSymbol]()

/** The HigherKinded trait corresponding to symbols `boundSyms` (which are assumed
* to be the type parameters of a higher-kided type). This is a class symbol that
Expand All @@ -513,7 +513,7 @@ class Definitions {
* - for each positive or negative variance v_i there is a parent trait Pj which
* is the same as LambdaXYZ except that it has `I` in i-th position.
*/
def lambdaTrait(vcs: List[Int]): ClassSymbol = {
def LambdaTrait(vcs: List[Int]): ClassSymbol = {
assert(vcs.nonEmpty)

def varianceFlags(v: Int) = v match {
Expand All @@ -527,17 +527,17 @@ class Definitions {
val cls = denot.asClass.classSymbol
val paramDecls = newScope
for (i <- 0 until vcs.length)
newTypeParam(cls, tpnme.lambdaArgName(i), varianceFlags(vcs(i)), paramDecls)
newTypeField(cls, tpnme.Apply, Covariant, paramDecls)
newTypeParam(cls, tpnme.LambdaArgName(i), varianceFlags(vcs(i)), paramDecls)
newTypeField(cls, tpnme.hkApply, Covariant, paramDecls)
val parentTraitRefs =
for (i <- 0 until vcs.length if vcs(i) != 0)
yield lambdaTrait(vcs.updated(i, 0)).typeRef
yield LambdaTrait(vcs.updated(i, 0)).typeRef
denot.info = ClassInfo(
ScalaPackageClass.thisType, cls, ObjectClass.typeRef :: parentTraitRefs.toList, paramDecls)
}
}

val traitName = tpnme.lambdaTraitName(vcs)
val traitName = tpnme.LambdaTraitName(vcs)

def createTrait = {
val cls = newClassSymbol(
Expand All @@ -549,7 +549,7 @@ class Definitions {
cls
}

lambdaTraitForVariances.getOrElseUpdate(vcs, createTrait)
LambdaTraitForVariances.getOrElseUpdate(vcs, createTrait)
}

// ----- primitive value class machinery ------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion src/dotty/tools/dotc/core/NameOps.scala
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ object NameOps {
/** The index of the higher-kinded type parameter with this name.
* Pre: isLambdaArgName.
*/
def lambdaArgIndex: Int =
def LambdaArgIndex: Int =
name.drop(tpnme.LAMBDA_ARG_PREFIX.length).toString.toInt

/** If the name ends with $nn where nn are
Expand Down
8 changes: 4 additions & 4 deletions src/dotty/tools/dotc/core/StdNames.scala
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ object StdNames {
final val WILDCARD_STAR: N = "_*"
final val REIFY_TREECREATOR_PREFIX: N = "$treecreator"
final val REIFY_TYPECREATOR_PREFIX: N = "$typecreator"
final val LAMBDA_ARG_PREFIX: N = "HK$"
final val LAMBDA_ARG_PREFIX: N = "hk$"
final val LAMBDA_ARG_PREFIXhead: Char = LAMBDA_ARG_PREFIX.head

final val Any: N = "Any"
Expand Down Expand Up @@ -311,7 +311,7 @@ object StdNames {

val AnnotatedType: N = "AnnotatedType"
val AppliedTypeTree: N = "AppliedTypeTree"
val Apply: N = "Apply"
val hkApply: N = "$apply"
val ArrayAnnotArg: N = "ArrayAnnotArg"
val Constant: N = "Constant"
val ConstantType: N = "ConstantType"
Expand Down Expand Up @@ -739,8 +739,8 @@ object StdNames {
def syntheticTypeParamNames(num: Int): List[TypeName] =
(0 until num).map(syntheticTypeParamName)(breakOut)

def lambdaTraitName(vcs: List[Int]): TypeName = LambdaPrefix ++ vcs.map(varianceSuffix).mkString
def lambdaArgName(n: Int) = LAMBDA_ARG_PREFIX ++ n.toString
def LambdaTraitName(vcs: List[Int]): TypeName = LambdaPrefix ++ vcs.map(varianceSuffix).mkString
def LambdaArgName(n: Int) = LAMBDA_ARG_PREFIX ++ n.toString

final val Conforms = encode("<:<")

Expand Down
27 changes: 27 additions & 0 deletions src/dotty/tools/dotc/core/Substituters.scala
Original file line number Diff line number Diff line change
Expand Up @@ -277,4 +277,31 @@ trait Substituters { this: Context =>
final class SubstParamsMap(from: BindingType, to: List[Type]) extends DeepTypeMap {
def apply(tp: Type) = substParams(tp, from, to, this)
}

/** A map for "cycle safe substitutions" which do not force the denotation
* of a TypeRef unless the name matches up with one of the substituted symbols.
*/
final class SafeSubstMap(from: List[Symbol], to: List[Type]) extends TypeMap {
def apply(tp: Type): Type = tp match {
case tp: NamedType =>
try {
var sym: Symbol = null
var fs = from
var ts = to
while (fs.nonEmpty) {
if (fs.head.name == tp.name) {
if (sym == null) sym = tp.symbol
if (fs.head eq sym) return ts.head
}
fs = fs.tail
ts = ts.tail
}
tp.newLikeThis(apply(tp.prefix))
}
catch {
case ex: CyclicReference => tp.derivedSelect(apply(tp.prefix))
}
case _ => mapOver(tp)
}
}
}
Loading